Oracle包创建错误
我创建了一个包和一个包体,如下所示:
Create or replace Package pkg_1
as
procedure main(param1 varchar2, param2 varchar2, param3 int);
procedure one(param1 varchar2, param2 varchar2);
procedure two(param1 varchar2, param2 varchar2);
end pkg_1;
/
create or replace package body pkg_1
as
procedure main (param1 varchar2, param2 varchar2, param3 int)
is
v_sql_script varchar2(1000);
begin
case param3
when 1 then
v_sql_script := 'begin exec pkg_1.one(:param1,:param2); end;';
execute immediate v_sql_script using param1, param2;
end case;
end;
现在,当我使用以下语句执行包过程时:
exec pkg_1.main('p1','p2',1);
I got the following error:
ORA-06550: line 1, column 12:
PLS-00103: Encountered the symbol "PKG_1" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "PKG_1" to continue.
有人可以建议我在这里做错了什么吗?
谢谢。
I created a package and a package body as below:
Create or replace Package pkg_1
as
procedure main(param1 varchar2, param2 varchar2, param3 int);
procedure one(param1 varchar2, param2 varchar2);
procedure two(param1 varchar2, param2 varchar2);
end pkg_1;
/
create or replace package body pkg_1
as
procedure main (param1 varchar2, param2 varchar2, param3 int)
is
v_sql_script varchar2(1000);
begin
case param3
when 1 then
v_sql_script := 'begin exec pkg_1.one(:param1,:param2); end;';
execute immediate v_sql_script using param1, param2;
end case;
end;
Now when I execute the package procedure with following statement:
exec pkg_1.main('p1','p2',1);
I got the following error:
ORA-06550: line 1, column 12:
PLS-00103: Encountered the symbol "PKG_1" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "PKG_1" to continue.
Can someone please suggest me what I have done wrong here?
Thank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正在 PL/SQL 块内执行它,在这种情况下您不需要
exec
。只需单独执行pkg_1.main('p1','p2',1);
即可。与这个问题的部分非常相似。
It appears you're executing it inside a PL/SQL block, in which case you do not need the
exec
. Just dopkg_1.main('p1','p2',1);
on its own.Quite similar to part of this question.