pro*c 动态sql一ITeye - 亚美娱乐

pro*c 动态sql一ITeye

2019年03月13日10时37分03秒 | 作者: 智晖 | 标签: 数据,过错,成功 | 浏览: 2646

[code=c]void Query()rnrn char *datainfo;rn char c_DateTime[50]; /*输出的时刻变量*/rn int i = 0;rn int j=0;rn GetDateTime(c_DateTime);rn char msg[DEFAULT_FILEBUFFER_LEN];rn char C_SP_TYPE_CODE[DEFAULT_FILEBUFFER_LEN];rn EXEC SQL INCLUDE SQLCA;rn EXEC SQL BEGIN DECLARE SECTION;rn VARCHAR count[20];rn VARCHAR c_SqlStr[5000];rn rn VARCHAR SP_TYPE[20];rn VARCHAR SP_TYPE_CODE[DEFAULT_BUF_SIZE];rn EXEC SQL END DECLARE SECTION;rn strcpy ((char *)c_SqlStr.arr,param.c_SqlStr);rn if (ConnectDB(param.USER_PASSWORD) 0)rn rn EXEC SQL SELECT count(*) INTO :count FROM TD_B_SPTYPE;rn if (sqlca.sqlcode 0)rn rn DisconnectDB(); /*断开数据库衔接*/rnrn printf( 树立游标过错!过错代码:%d\n , sqlca.sqlcode);rn exit(-1);rn rn strcpy((char*)msg, (char*)count.arr);rn rn rn if ((in_fp = fopen(param.FILENAME, w )) != NULL)rn rn printf( 翻开%s文件成功\n\n , param.FILENAME); rn printf( -%s 开端处理数据-\n\n , c_DateTime);rnrn if (setvbuf(in_fp, msg, _IONBF, DEFAULT_FILEBUFFER_LEN) != 0)rn printf( 设置缓冲失利\n rn elsern rn printf( 设置缓冲成功:%d\n , setvbuf(in_fp, msg, _IONBF, DEFAULT_FILEBUFFER_LEN));rn rn [color=#FF0000]rn EXEC SQL PREPARE s from :c_SqlStr;rn EXEC SQL DECLARE cur_out CURSOR for s;rn EXEC SQL OPEN cur_out;rn EXEC SQL WHENEVER NOT FOUND GOTO notfound;rn for (;;) rn rn [/color] EXEC SQL FETCH cur_out into :SP_TYPE_CODE;rn printf( %s\n ,SP_TYPE_CODE);rn /*EXEC SQL ;*/rn strcpy((char*)C_SP_TYPE_CODE, (char*)SP_TYPE_CODE.arr);rn while (C_SP_TYPE_CODE[i] (i strlen(C_SP_TYPE_CODE)))rn SELECT replace(replace(SP_TYPE_CODE||chr(01)||SP_TYPE,chr(10)),chr(13)) INTO :SP_TYPE_CODE FROM TD_B_SPTYPE where SP_TYPE_CODE=66rn fputc(C_SP_TYPE_CODE[i], in_fp);rn i++;rn rn rn notfound:rn EXEC SQL CLOSE cur_out;rn EXEC SQL COMMIT RELEASE;rn printf( Have a good day!\n rn exit(0);rn printf( 共处理%d条数据-\n\n , msg);rnrn fclose(in_fp);rn rn rn[/code]rnrn我的sql是:SELECT replace(replace(SP_TYPE_CODE||chr(01)||SP_TYPE,chr(10)),chr(13)) INTO :SP_TYPE_CODE FROM TD_B_SPTYPE where SP_TYPE_CODE=66,按理说只查出一天数据,可为什么循环的时分一向循环

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表亚美娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章