variable scope with nested block : Variable Scope « PL SQL « Oracle PL / SQL






variable scope with nested block

  
SQL>
SQL>  declare
  2      l_parent_number number;
  3    begin
  4      
  5      l_parent_number := 1;
  6
  7      declare
  8        l_child_number number := 2;
  9      begin
 10        
 11        dbms_output.put_line('parent + child = ' ||
 12                              to_char(l_parent_number + l_child_number));
 13      end;
 14
 15      
 16      l_child_number := 2;
 17    end;
 18    /
    l_child_number := 2;
    *
ERROR at line 16:
ORA-06550: line 16, column 5:
PLS-00201: identifier 'L_CHILD_NUMBER' must be declared
ORA-06550: line 16, column 5:
PL/SQL: Statement ignored


SQL>

   
  








Related examples in the same category

1.Variable scope in variable 'declare' block
2.Illustrates the scope of various identifiers
3.Variable scope in a PL/SQL
4.Identifiers defined in the declaration of the child block are only in scope and visible within the child block itself.
5.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
6.This type is local to this block
7.Reference Type in another block as well
8.Override your scope access to containing blocks by reusing an identifier in a nested block