views:

26

answers:

1

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.

+5  A: 

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.

Alex Poole
Thank you so much.
mrp
Yes that was the case. It works fine now.
mrp
@mrp: if this is the case, accept this answer. That way other users know this is the answer to your question. (Is know SO works). You have a 39% accept rate... low accept rates could make people think twice before taking the time and effort needed to answer your questions.
jachguate