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!

how to declare package in plsql anonymous block

prakashJan 31 2012 — edited Feb 1 2012
hi all,

How to write a package in plsql block .

i tried the following its says errors , please share your thoughts on it .
SQL> declare
  2    package mypack
  3    is
  4         procedure print(p_str in varchar2)
  5         is
  6          begin
  7               dbms_output.put_line(p_str);
  8          end ;
  9   end mypack;
 10  begin
 11    mypack.print('HELLO World !!!!!!!');
 12  
 13  end ;
 14  /
        begin
        *
ERROR at line 6:
ORA-06550: line 6, column 9:
PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
language
ORA-06550: line 9, column 6:
PLS-00103: Encountered the symbol "MYPACK" when expecting one of the following:
;
ORA-06550: line 13, column 5:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
end not pragma final instantiable order overriding static
member constructor map


SQL> 
SQL> set serveroutput on
SQL> ;
  1  declare
  2         procedure print(p_str in varchar2)
  3         is
  4          begin
  5               dbms_output.put_line(p_str);
  6          end ;
  7  begin
  8   print('HELLO World !!!!!!!');
  9* end ;
SQL> /
HELLO World !!!!!!!

PL/SQL procedure successfully completed.

SQL> 


This is working fine , but why i cant declare package in declaration part of plsql block .
Thanks,
P Prakash

Edited by: prakash on Jan 30, 2012 11:01 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 29 2012
Added on Jan 31 2012
4 comments
1,510 views