Oracle包创建错误

发布于 2024-09-29 14:39:12 字数 888 浏览 3 评论 0原文

我创建了一个包和一个包体,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薯片软お妹 2024-10-06 14:39:12

看起来您正在 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 do pkg_1.main('p1','p2',1); on its own.

Quite similar to part of this question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文