esql 游标查询时,最后一条记录重复?
这是我写的esql,查询。。。EXECSQLBEGINDECLARESECTION;INTstatus;CHARsno[10],sname[15],city[20];EX...
这是我写的esql,查询。。。
EXEC SQL BEGIN DECLARE SECTION ;
INT status;
CHAR sno[10],sname[15],city[20];
EXEC SQL END DECLARE SECTION ;
EXEC SQL INCLUDE SQLCA;
main()
{
int i;
EXEC SQL DATABASE "sx";
EXEC SQL DECLARE cursor1 CURSOR FOR SELECT * FROM S_TEST;
EXEC SQL OPEN cursor1 ;
printf("sno sname status city\n ");
while(SQLCODE==0)
{
EXEC SQL FETCH NEXT cursor1 INTO :sno,:sname,:status,:city ;
printf("%8s %8s %8d %8s \n",sno,sname,status,city);
}
EXEC SQL CLOSE cursor1 ;
EXEC SQL DISCONNECT CURRENT;
} 展开
EXEC SQL BEGIN DECLARE SECTION ;
INT status;
CHAR sno[10],sname[15],city[20];
EXEC SQL END DECLARE SECTION ;
EXEC SQL INCLUDE SQLCA;
main()
{
int i;
EXEC SQL DATABASE "sx";
EXEC SQL DECLARE cursor1 CURSOR FOR SELECT * FROM S_TEST;
EXEC SQL OPEN cursor1 ;
printf("sno sname status city\n ");
while(SQLCODE==0)
{
EXEC SQL FETCH NEXT cursor1 INTO :sno,:sname,:status,:city ;
printf("%8s %8s %8d %8s \n",sno,sname,status,city);
}
EXEC SQL CLOSE cursor1 ;
EXEC SQL DISCONNECT CURRENT;
} 展开
1个回答
2013-12-18
展开全部
,要想使SQL语言能与宿主语言通讯,ESQL提供了游标操作, ... ESQL中的DECLARE CURSOR语句定义游标,赋给它一个与查询相关的游标名.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询