现在好象有点明白了:
我在2000下用记事本写了一个程序,然后用proc来进行预编译,最后用tc来编译,结果出现这样一个错误:undefined symbol "_sqlctx" in module oracle.c,可是sqlctx在我本身程序是没有的,而是proc预编译加上去,难道它预也会出错???请大家看看我的程序帮忙调试下,谢谢:
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20];
VARCHAR password[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca;
void sqlerror();
main()
{
EXEC SQL BEGIN DECLARE SECTION;
int emp_number;
VARCHAR emp_name[15];
float salary;
float commission;
EXEC SQL END DECLARE SECTION;
int total_number;
strcpy(username.arr,"SYSTEM");
username.len=strlen(username.arr);
strcpy(password.arr,"MANAGER");
password.len=strlen(password.arr);
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("\nConnected to ORACLE as user:%s\n",username.arr);
total_number=0;
while(1)
{
emp_number=0;
printf("\nEnter employee number (0 to quit):");
scanf("%d",&emp_number);
if(emp_number==0)break;
EXEC SQL WHENEVER NOT FOUND GOTO notfound;
EXEC SQL SELECT ENAME,SAL,COMM
INTO :emp_name, :salary, :commission
FROM EMP
WHERE EMPNO=:emp_number;
printf("\n\n\Employee\tSalary\tCommission\n");
printf("-----------\t---------\t---------\n");
emp_name.arr[emp_name.len]='\0';
printf("%8s\t%6.2f\t%6.2f\n",emp_name.arr,salary,commission);
total_number=total_number+1;
continue;
notfound:
printf("\nNot a valid employee number-try again.\n");
}
printf("\n\nTotal number queried was:%d\n",total_number);
printf("\nHave a good day.\n");
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void sqlerror()
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\nORACLE error detected:\n");
printf("\n%.70s\n",sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}