sprintf(sqlstr,"select count(*) into :tmpRecord from %s where acno='%s' and trdt between %s and %s;",tabname,sAcno,sBeginDate,sEndDate);
如上述代码,若要保存tmpRecord 是不能实现的,解决办法:
??? 定义动态SQL语句:
sprintf(sqlstr,"select count(*) from %s where acno='%s' and trdt between %s and %s;",tabname,sAcno,sBeginDate,sEndDate);?
??? 动态定义游标,并查询记录集,若为单条数据,fetch一次即可。
EXEC SQL PREPARE viewsql from :sqlstr;EXEC SQL declare cur_count1 CURSOR FOR viewsql;EXEC SQL OPEN cur_count1;while(1){ EXEC SQL fetch cur_count1 into:tmpRecord; if ( SQLCODE == SQLNOTFOUND ) break;}?