oracle PL/SQL 中变量绑定用法

Code
type cursorType is ref cursor;

然后:

declare

cur_temp cursortype;

c_temp table_a
%rowtype;

begin

open cur_temp for 'select * from table_a where a=:1' using 91;

loop

fetch cur_temp into c_temp;

exit when cur_temp%notfound;

execute immediate 'insert into b values (:1)' using c_temp.a;

end loop;

close cur_temp;

commit;

end;

上面是在PL/SQL 块中的写法,这个写法也同样适用于存储过程,触发器,函数,包等可以用PL/SQL 的地方。

对于需要用 INTO 的地方,可以如下使用:

Code
i number(6);

execute immediate 'select count(*) from table_a where a =:1' into i using 89;

执行后,取出的值存放在了变量 i 中。

在PL/SQL 中,变量绑定的常见用法基本如上所示,建议全部使用变量绑定。

转载于:https://www.cnblogs.com/libiao/archive/2008/11/10/1330861.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值