Variable scope in a PL/SQL : Variable Scope « PL SQL « Oracle PL / SQL






Variable scope in a PL/SQL

 

SQL>
SQL>
SQL> declare                                -- begin first block
  2    l_text varchar2(20);
  3    begin
  4      l_text := 'First Block';
  5      dbms_output.put_line(l_text);
  6      declare                            -- begin second block
  7        l_more_text varchar2(20);
  8      begin
  9        l_more_text := 'Second Block';
 10        dbms_output.put_line(l_more_text);
 11      end;                               -- end second block
 12    end;                                 -- end first block
 13  /
First Block
Second Block

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
           
         
  








Related examples in the same category

1.Variable scope in variable 'declare' block
2.Illustrates the scope of various identifiers
3.Identifiers defined in the declaration of the child block are only in scope and visible within the child block itself.
4.if you try to reference a variable before you declare it because PL/SQL requires an identifier be declared before we use it in our code
5.This type is local to this block
6.Reference Type in another block as well
7.variable scope with nested block
8.Override your scope access to containing blocks by reusing an identifier in a nested block