帮帮忙!
#include <stdio.h>以下的嵌入SQL语句的C语言程序在用NSQLPREP.EXE预编译的时候总是出现如下提示,不知那位高手能为我答疑解惑,该怎么修改?这里先行谢过
C:\Program Files\Microsoft SQL Server\MSSQL\Binn>NSQLPREP Ex.sqc
Microsoft (R) Embedded SQL for C Pre-Compiler. Version 8.00.194.
Copyright (c) Microsoft Corp 1993-1998. All rights reserved.
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
Ex.sqc
Warning: Ex.sqc, line 25: syntax error.
EXEC SQL DECLARE SX CURSOR FOR
SQLPREP: SQL Compile Error at line 45
UPDATE Student SET Sage=@p1 where CURRENT OF SX
Error code: -19946
Cursor SX not declared
SQLPREP: SQL Compile Error at line 50
CLOSE SX
Error code: -19946
Cursor SX not declared
Warning: Ex.sqc, line 53: syntax error.
}
C:\Program Files\Microsoft SQL Server\MSSQL\Binn>
程序如下:
EXEC SQL BEGIN DECLARE SECTION;
char deptname[20];
char HSno[9];
char HSname[20];
char HSsex[2];
int HSage;
int NEWAGE;
EXEC SQL END DECLARE SECTION;
long SQLCODE;
EXEC SQL INCLUDE sqlca;
int main()
{
int count=0;
char yn;
printf("Please choose the department name(CS/MA/IS): ");
scanf("%s",&deptname);
EXEC SQL CONNECT TO COMPUTER;
EXEC SQL DECLARE SX CURSOR FOR
select Sno,Sname,Ssex,Sage
from Student
where SDept=:deptname;
EXEC SQL OPEN SX;
for( ; ; ){
EXEC SQL FETCH SX INTO :HSno,:HSname,:HSsex,:HSage;
if(sqlca.sqlcode != 0)
break;
if(count++ = 0)
printf("\n%-10s%-20s%-10s%-10s\n","Sno","Sname","Ssex","Sage");
printf("%-10s%-20s%-10s%-10s\n",HSno,HSname,HSsex,HSage);
printf("UPDATE AGE(y/n)?");
do{
scanf("%c",&yn);
}while(yn!='N'&&yn!='n'&&yn!='Y'&&yn!='y');
if(yn == 'y' || yn == 'Y'){
printf("INPUT NEW AGE:");
scanf("%d",&NEWAGE);
EXEC SQL UPDATE Student
SET Sage=:NEWAGE
where CURRENT OF SX;
}
}
EXEC SQL CLOSE SX;
EXEC SQL COMMIT WORK;
EXEC SQL DISCONNECT COMPUTER;
}