用不着这么绑定变量的吧,用带参数的游标不就可以了cursor c1(varchar2 in p_code) is select serno,USERID,CODE,CURRTYPE,BALANCE from GRKH.MAG_CHECKINFO where flag='1' code= p_code;....open c1(code);...
For c1 in ('select serno,USERID,CODE,CURRTYPE,BALANCE from GRKH.MAG_CHECKINFO where flag=''1'') loopINSERT INTO .....c1.serno,c1.USERID.....end loop;
借宝地问个相似的问题, 比如在不同的条件下SQL语句会有所不同(增加或减少查询条件) 如: 在情况一时: select * from table where 条件1 在情况二时: select * from table where 条件1 AND 条件2请问该游标该怎么写? 这样子? DECLARE TYPE c1 is REF CURSOR; if 情况一 then c1 is select * from table where 条件1 else c1 is select * from table where 条件1 AND 条件2
比如在不同的条件下SQL语句会有所不同(增加或减少查询条件)
如:
在情况一时:
select * from table
where 条件1 在情况二时:
select * from table
where 条件1
AND 条件2请问该游标该怎么写?
这样子?
DECLARE
TYPE c1 is REF CURSOR;
if 情况一 then
c1 is select * from table
where 条件1
else
c1 is select * from table
where 条件1
AND 条件2
code 在哪里定义的???