SQLCODE function in Oracle

SQLCODE function is used within the Exception Handling section of a code. It is used to get the error number. Here, the error number is associated with the most recently raised error exception.

Syntax:

SQLCODE

Example:

EXCEPTION
WHEN OTHERS THEN
Raise_application_error (-20001, 'Error detected - '||SQLCODE||' -ERROR- '||SQLERRM);
END;