Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute immediate a procedure call

Sri GJan 9 2014 — edited Jan 9 2014

Hi,

I need some help, can some one EXPLAIN why its failing when i don't specify the test_proc in spec.

i know this is not the right way of doing things. want to know why i need to specify the procedure name in spec.

{

SQL> select * from v$version;

BANNER                                                                         

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production   

PL/SQL Release 11.2.0.2.0 - Production                                         

CORE 11.2.0.2.0 Production                                                     

TNS for Linux: Version 11.2.0.2.0 - Production                                 

NLSRTL Version 11.2.0.2.0 - Production                                         

SQL> CREATE OR REPLACE PACKAGE PkgTest AS

  2 

  3    --PROCEDURE test_proc;

  4    PROCEDURE run_proc;

  5  END PkgTest;

  6  /

Package created.

SQL>

SQL>

SQL> CREATE OR REPLACE PACKAGE BODY PkgTest AS

  2 

  3  PROCEDURE test_proc IS

  4    BEGIN

  5      dbms_output.put_line(' Test Proc');

  6  END test_proc;

  7 

  8  PROCEDURE run_proc IS

  9  BEGIN

10      EXECUTE IMMEDIATE 'begin  PkgTest.test_proc; end;';

11  END run_proc;

12  END PkgTest;

13  /

Package body created.

SQL> exec pkgtest.run_proc;

BEGIN pkgtest.run_proc; END;

*

ERROR at line 1:

ORA-06550: line 1, column 16:

PLS-00302: component 'TEST_PROC' must be declared

ORA-06550: line 1, column 8:

PL/SQL: Statement ignored

ORA-06512: at "MPIEFP_DEV.PKGTEST", line 10

ORA-06512: at line 1

SQL> CREATE OR REPLACE PACKAGE PkgTest AS

  2 

  3    PROCEDURE test_proc;

  4    PROCEDURE run_proc;

  5  END PkgTest;

  6  /

Package created.

SQL> exec pkgtest.run_proc;

Test Proc                                                                      

PL/SQL procedure successfully completed.

SQL> spool off

}

This post has been answered by Frank Kulash on Jan 9 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2014
Added on Jan 9 2014
5 comments
1,199 views