例如有一SQL块:
declare
num number(1) := 0;
total number(3):=0;
para_optsn varchar(30):='2';
type cursor_type is ref cursor;
CSR_CURSOR CURSOR_TYPE;
begin
-- DBMS_OUTPUT.PUT_LINE('开始执行');
open CSR_CURSOR for
select para_optsn from oper.t_optrsqlrec;
loop fetch CSR_CURSOR into para_optsn;
exit when CSR_CURSOR%notfound;
total:=total+1;
if para_optsn ='2' then
update oper.t_optrsqlrec set content='9999999' where optsn =para_optsn;
end if;
end loop;
CLOSE CSR_CURSOR;
end;
我想把以上sql块作为字符变量传给一存储过程,并让EXECUTE IMMEDIATE 执行,我试过了不行。请问如何做到呢?十分急!!!!!
declare
num number(1) := 0;
total number(3):=0;
para_optsn varchar(30):='2';
type cursor_type is ref cursor;
CSR_CURSOR CURSOR_TYPE;
begin
-- DBMS_OUTPUT.PUT_LINE('开始执行');
open CSR_CURSOR for
select para_optsn from oper.t_optrsqlrec;
loop fetch CSR_CURSOR into para_optsn;
exit when CSR_CURSOR%notfound;
total:=total+1;
if para_optsn ='2' then
update oper.t_optrsqlrec set content='9999999' where optsn =para_optsn;
end if;
end loop;
CLOSE CSR_CURSOR;
end;
我想把以上sql块作为字符变量传给一存储过程,并让EXECUTE IMMEDIATE 执行,我试过了不行。请问如何做到呢?十分急!!!!!
解决方案 »
- 2008下的oracle10g,注册表HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE下没有\HOME0
- 相同语句创建的表与视图,对其中的同一个字段做全表sum的结果不一致,怎么入手解释这个现象?
- 为什么完全相同的语句,执行计划差别那么大呢
- [高手帮忙]SQl Server语句转Oracle
- 关于oracle得plsql中使用操作系统命令,急!急!急! (100分)
- 深圳地区急求 Oracle数据库管理员技术指南(作者:Sumit Sarin) 书一本,要第2版的!
- 怎么更改spfile的路径?为什么我show parameter spfile出来的spfile的路径是空的?
- exec 语法问题
- 游标?
- VERTICA数据库中的字符长度问题
- proc中如何操纵timestamp 数据
- oracle怎么装啊?
-- Created on 2007-3-27 by ADMINISTRATOR
declare
-- Local variables here
i integer;
s varchar2(500);
begin
-- Test statements here
s:='declare begin dbms_output.put_line(1); end;';
execute immediate s;
end;
你看看这个语句执行的行不,错误的原因不在于execute支不支持,而是有其它原因。检查一下字符串的长度是否够用,要不把错误代码贴出来看一下下