Variable scope : Variable Scope « PL SQL Data Types « Oracle PL/SQL Tutorial






SQL> <<l_outer_block>>
  2  DECLARE
  3     v_visible VARCHAR2(30);
  4     v_hidden VARCHAR2(30);
  5  BEGIN
  6     v_visible := 'v_visible in the outer block';
  7     v_hidden := 'v_hidden in the outer block';
  8
  9     DBMS_OUTPUT.PUT_LINE('*** OUTER BLOCK ***');
 10     DBMS_OUTPUT.PUT_LINE(v_visible);
 11     DBMS_OUTPUT.PUT_LINE(v_hidden);
 12     DBMS_OUTPUT.PUT_LINE('     ');
 13
 14     DECLARE
 15        v_hidden NUMBER(10);
 16     BEGIN
 17        DBMS_OUTPUT.PUT_LINE('*** INNER BLOCK ***');
 18        l_outer_block.v_hidden := 'v_hidden in the inner block';
 19        DBMS_OUTPUT.PUT_LINE(l_outer_block.v_hidden);
 20     EXCEPTION
 21        WHEN OTHERS
 22        THEN
 23           DBMS_OUTPUT.PUT_LINE('v_hidden of type VARCHAR2 was...hidden');
 24     END;
 25  END;
 26  /
*** OUTER BLOCK ***
v_visible in the outer block
v_hidden in the outer block
*** INNER BLOCK ***
v_hidden in the inner block

PL/SQL procedure successfully completed.








21.37.Variable Scope
21.37.1.Variable visibility
21.37.2.Variable scope
21.37.3.The scope test script