CREATE or replace PROCEDURE abc as
ret number;
msg varchar2(1000);
Begin
execute immediate 'truncate table OBSPROJ';
execute immediate 'exec obsproj_full_rebuild(:ret,:msg)';
End abc;
尝试执行以下查询时会导致“查询无效”
我认为问题在于第二次执行查询。
答案 0 :(得分:2)
请参阅以下内容:内联阅读评论。
CREATE OR REPLACE PROCEDURE abc
AS
ret NUMBER;
msg VARCHAR2 (1000);
BEGIN
EXECUTE IMMEDIATE 'truncate table OBSPROJ';
--This is how you call a procedure inside a procedure.
obsproj_full_rebuild(ret,msg); -- I guess your procedure accepts some values. .Here you are just passing the variables you declared.
END abc;
执行:
sql> exec abc;
答案 1 :(得分:0)
首先:exec既不是SQL也不是PL / SQL命令 - 这就是你得到错误的原因。如果您仍想使用动态SQL来调用过程,可以将其包装在PL / SQL块中并绑定ret和msg变量:
execute immediate 'begin obsproj_full_rebuild(:ret,:msg); end;' using ret, msg;
但实际上你不必使用动态sql来执行这个过程。你可以简单地调用程序
CREATE OR REPLACE PROCEDURE abc AS
ret NUMBER;
msg VARCHAR2(1000);
BEGIN
EXECUTE IMMEDIATE 'truncate table OBSPROJ';
obsproj_full_rebuild(ret,msg);
END abc;