Posted on 2008-09-10 10:31
Prayer 阅读(125)
评论(0) 编辑 收藏 引用 所属分类:
数据库,SQL 、
C/C++
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlca.h>
int main()
{
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
char cd[13+1];
char nm[255+1];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO INFDB USER usr USING pwd;
EXEC SQL DECLARE SX CURSOR FOR
SELECT CD,NM FROM TBL;
EXEC SQL OPEN SX;
for(;;)
{
EXEC SQL FETCH SX INTO :cd,:nm;
if(sqlca.sqlcode!=0)
break;
printf("ID is %s,NAME is %s\n",cd,nm);
}
EXEC SQL CLOSE SX;
EXEC SQL DISCONNECT CURRENT;
return 0;
}