我想实现实现这样的功能
select aa into :aa from aa where...
其中where后面的条件是动态的,可能在一个变量中,比如vs_filter中
但是 sql='select aa into :aa from aa where'+vs_filter
execute immediate:sql;
也是不正确的,请问大虾们,怎么解决?
string sql,ls_filter,ls_end,ls_code
ls_filter = "dor_code = '001'"
//下句的sql缺點:只能返回一筆數據。
sql ="select ratem.dor_nm from ratem where "+ls_filter+" "
DECLARE CUR_PERWK DYNAMIC CURSOR FOR SQLSA ;
PREPARE SQLSA FROM :sql ;
OPEN DYNAMIC CUR_PERWK ;
FETCH CUR_PERWK INTO :ls_end ;
//處理數據
do while sqlca.sqlcode =0
INSERT INTO "test"
( "name",
"number",
"month",
"no" )
VALUES ( :ls_end,
66,
'',
'' ) ;
FETCH CUR_PERWK INTO :ls_end ;
loop;
CLOSE CUR_PERWK ;
if sqlca.sqlcode =0 then
commit;
MESSAGEBOX("提示",string(ls_end))
else
rollback;
messagebox("提示","錯誤~為:"+sqlca.sqlerrtext)
end if