In Oracle PL/SQL, SQLCODE is an error trapping function which returns a predefined error number associated with the last standard exception raised by the Oracle Server. It is a negative number except for the NO_DATA_FOUND exception, which has a SQLCODE of 100. It is defined in the Oracle STANDARD package.
If SQLCODE is invoked in execution block, its value is 0, i.e. "successful operation". For user defined exceptions the value of SQLCODE is 1 or the number which is associated with the exception in PRAGMA EXCEPTION_INIT.
Note that SQLCODE is a function; therefore it must be assigned to a local variable to capture its value.
The PL/SQL block below raises the ZERO_DIVIDE exception and displays the Exception Number.
L_NUM1 := 10;
L_NUM2 := 0;
WHEN OTHERS THEN
PL/SQL procedure successfully completed.