Block Labels in pl/sql developer

Marlon

Member
I'm attempting to use the block labels in anonymous blocks and it does not appear to be working out of the box.

Here is some sample code with being the block label of the outer block and referenced within the inner block in a dbms_output call.

declare
l_var number;
l_outer number;
begin
l_outer := 1;
l_var := 1;

dbms_output.put_line('OUTER ANON BLOCK');
dbms_output.put_line('l_var = ' || l_var);

declare
l_var number;
l_inner number;
begin
l_inner := 2;
l_var := 2;
dbms_output.put_line('INNER ANON BLOCK');
dbms_output.put_line('parent.l_var = ' || parent.l_var );
end;
end;

When I attempt to run this code through a SQL Window, I am presented with the following error:

ORA-06550: line 5, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

* & = - + ; < / > at in is mod remainder not rem
or != or ~= >=
 
The SQL window is only for SQL statements. To run scripts, you need to use the command window.

I don't use labels a lot, but I have always put them inside a begin. This works for me:

Code:
BEGIN
   <<PARENT>>
   DECLARE
      l_var   NUMBER;
      l_outer NUMBER;
   BEGIN
      l_outer := 1;
      l_var   := 1;

      dbms_output.put_line('OUTER ANON BLOCK');
      dbms_output.put_line('l_var = ' || l_var);

      DECLARE
         l_var   NUMBER;
         l_inner NUMBER;
      BEGIN
         l_inner := 2;
         l_var   := 2;
         dbms_output.put_line('INNER ANON BLOCK');
         dbms_OUTPUT.PUT_LINE('l_var = ' || l_var);
         dbms_output.put_line('parent.l_var = ' || parent.l_var);
      END;
   END;
END;
/
 
Looks the outer label is only parsed in a Test window.

I'd say it really ought to work in a Command window as well, to emulate SQL*Plus. I'm not sure how much PL/SQL support we should expect in a SQL window.
 
Back
Top