main()
{
EXEC SQL BEGIN DECLARE SECTION;
char dbname[21];
char qyrq[31];
char comm[201];
int i=0;
EXEC SQL END DECLARE SECTION;
sprintf(dbname,"%s",getenv("DBNAME")) ;
EXEC SQL DATABASE :dbname ;
if( sqlca.sqlcode ) {
printf("code=[%d]",sqlca.sqlcode) ;
return -1 ;
}
sprintf( comm, "SELECT qyrq FROM Ggll WHERE %s ", "Llbh='100'") ;
printf("comm=[%s]\n",comm) ;
EXEC SQL PREPARE wi94178 FROM :comm;
if( sqlca.sqlcode ) {
printf("code=[%d]",sqlca.sqlcode) ;
return -1 ;
EXEC SQL DECLARE ws94178 CURSOR FOR wi94178;
EXEC SQL OPEN ws94178;
while(1) {
EXEC SQL FETCH ws94178 into :qyrq ;
if( sqlca.sqlcode==100 )
break ;
if( sqlca.sqlcode ) {
printf("code=[%d]",sqlca.sqlcode) ;
return -1 ;
}
printf("zh=[%s]\n",qyrq) ;
if(i==100)
break ;
i=i+1 ;
}
EXEC SQL CLOSE ws94178 ;
if( sqlca.sqlcode ) {
printf("code=[%d]",sqlca.sqlcode) ;
return -1 ;
}
EXEC SQL FREE ws94178 ;
EXEC SQL CLOSE DATABASE ;
return 0 ;
}