Introduction

The scope of a variable is a region of a program unit where you can reference the variable.

All identifiers within the same scope must be unique.

declare 
      v_amount_nr NUMBER; 
      v_amount_nr BINARY_INTEGER; -- duplicate!!! 
begin 
       ...   

You should never use variable names that could match column names in the database.

In SQL statements, the names of database columns take precedence over the names of local variables and formal parameters:

declare 
     ename VARCHAR2(10):='KING'; 
begin 
     update emp 
      set sal = sal * 10 
     where eName = eName; -- WRONG!!! 
end; 

To fix this

declare 
     v_eName_tx VARCHAR2(10):='KING'; 
begin 
     update emp 
      set sal = sal * 10 
     where eName = v_eName_tx; -- CORRECT! 
end; 

Related Topic