linux - 把输出结果到文件中,利用c语言中的文件创建读写txt
PHP中文网
PHP中文网 2017-04-17 13:35:30
0
1
421

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 ;
      }
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
小葫芦

What does it mean to put the code directly?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!