A nested block which declares and prints a variable of the same name : Nested Block « PL SQL Statements « Oracle PL/SQL Tutorial






SQL>
SQL> set echo on
SQL> set serveroutput on
SQL> declare
  2    state_name  varchar2(30);
  3
  4  begin
  5    state_name := 'A';
  6
  7    declare
  8      state_name  varchar2(30);
  9    begin
 10      state_name := 'B';
 11      dbms_output.put_line(state_name);
 12    end;
 13
 14    --Now print the state_name variable's value in the outer block.
 15    dbms_output.put_line (state_name);
 16  end;
 17  /
B
A

PL/SQL procedure successfully completed.

SQL>
SQL>








22.12.Nested Block
22.12.1.Nested Blocks
22.12.2.A nested block which declares and prints a variable of the same name
22.12.3.This is an example of nested anonymous blocks
22.12.4.Nesting Functions and Procedures
22.12.5.Call function in PL/SQL