Introduction

You can use the same variable name for multiple levels of anonymous blocks.

Only local variables are visible:

declare 
     v_str1_tx VARCHAR2(10); 
begin 
     declare 
          v_str1_tx VARCHAR2(2); 
     begin 
          v_str1_tx:='ABC'; -- INVALID 
          v_str1_tx:='AB';   -- valid 
     end; 
     v_str1_tx:='ABC'; -- valid 
end; 

Because variable V_STR1_tx is declared in both blocks, in the inner block only the local one is visible.

You can assign only a two-character value to it.

Outside the inner block, you can assign up to a ten-character value to the variable because now the visible variable V_STR1_txis of type VARCHAR2(10).

Related Topic