我是用写字板写好程序(.txt)然后拿到Oracle的pro*c/c++中编译出现如下错误
CC-S-02021, 在扫描字符串常数时发现新行
PCC-F-02102, C 预处理时,发生严重错误
程序如下
#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, "SCOTT ")
username.len=strlen(username.arr);
strcpy(password.arr, "TIGER ");
password.len=strlen(password.arr);
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT:username IDENTIFILD BY :password;
username.arr[len]= '\0 ';
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\nEmployee\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);
}
请问我先在写字板中书写程序,再去Oracle编译是否得当,(因为我发现在Oracle中不能直接书写.pc程序吧)还有 编译好的C文件能在BCB中编译吗?
------解决方案--------------------
程序没看,这种是编译错误,说明你程序有地方有问题。一般他会给出错误的行数便于你找。另外,PC 程序我都用UE写,也就是个文档编译器,没啥特别要求