EXEC SQL BEGIN DECLARE SECTION; int iMaxRowCount = MAX_ROWCOUNT; char name_list [MAX_ROWCOUNT +1][NAME_LEN +1]="\0"; char vv_name [NAME_LEN +1]="\0";
EXEC SQL END DECLARE SECTION;
memset(name_list, 0,sizeof(name_list));
EXEC SQL select name into :name_list from tab_student where rownum <:iMaxRowCount; // 判斷sql是否執行成功
...
//sqlerrd[2] - Numbers of rows processed by the most recent SQL statement. for(int i = 0; i < sqlca.sqlerrd[2]; i++) { memset(vv_name);
snprintf(vv_name,sizeof(vv_name),"%s", name_list);
rtrim(vv_name);//刪除末尾空格