在命令窗口中是绝对可以执行的,但我现在不知道在(比如)存储过程中如何来执行这个块呢
不能用游标,我的意思是我把这个块读到一个变量中。然后用execute immediate 变量名来执行这个块,但是立即执行不支持执行块的语句,只能单条语句执行。请教大侠用哪个命令可以执行块语句呢?
不能用游标,我的意思是我把这个块读到一个变量中。然后用execute immediate 变量名来执行这个块,但是立即执行不支持执行块的语句,只能单条语句执行。请教大侠用哪个命令可以执行块语句呢?
调试欢乐多
create table test(a varchar2(1000),id);
insert into test values ('declare b varchar2(1000);
begin
select a into b from test where id=1;
insert into test values (b,2);
commit;
end;',1);在存储过程中执行:
create procedure aa as
v_sql varchar2(1000);
begin
select a into v_sql from test where id=1;
execute immediate v_sql;
end;这样执行就会出现错误。还有没有别的办法呢?
execute immediate v_sql;
怎么能这样做,当然错了
你直接写insert into test values (v_sql,2);就可以了要不也可以execute immediate 'insert into test values (v_sql,2)';
execute immediate 'insert into test values (:1,2)' using v_sql;
v_sql varchar2(1000);
num number;
begin
v_sql:='select a into num from test where id=1';
execute immediate v_sql;
end;
这样才对