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!

local procedure definition in pl/sql

575531May 24 2007 — edited May 24 2007

Peace be with you all,

Why is it that you can't declare a variable after a local function
or procedure definition (within a stand-alone script)?

This fails:

declare
   procedure impeachBush
   is
   begin
      dbms_output.put_line( 'pardon my frustration' );
   end;
   
   n int;

begin
   impeachBush();
   n := 1;
end;

This is the error:

ORA-06550: line 8, column 4:
PLS-00103: Encountered the symbol "N" when expecting one of the following:
   begin function package pragma procedure form

But, if I put the 'n int;' above the procedure, everything is ok, as such:

declare
   n int;

   procedure impeachBush
   is
   begin
      dbms_output.put_line( 'pardon my frustration' );
   end;
   
begin
   impeachBush();
   n := 1;
end;

The reason I'd rather have some of my variables defined below
my procedure and function definitions is to ensure that the vars
are not referenced by the procedures and functions. As well,
I'd rather not have to declare a nested declare/begin/end block
within the begin/end block of the script.

And, believe it or not, I do spend a lot of time reading the SQL,
PL/SQL and Database Reference manuals, and if someone can
point me to where the declaration semantics are defined, I'd be
very appreciative.

Kind Regards,
Robert

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2007
Added on May 24 2007
5 comments
733 views