SQL Syntax Reference : SQLSTATE
 
SQLSTATE
Remarks
The SQLSTATE value corresponds to a success, warning, or exception condition. The complete list of SQLSTATE values defined by ODBC can be found in the Microsoft ODBC documentation.
When a handler executes, the statements within it affect the SQLSTATE value in the same way as statements in the main body of the compound statement. However, a handler that is intended to take specific action for a specific condition can optionally leave that condition unaffected, by reassigning that condition at its conclusion. This does not cause the handler to be invoked again; that would cause a loop. Instead, PSQL treats the exception condition as an unhandled exception condition, and execution stops.
See Also
CREATE PROCEDURE
SELECT
SIGNAL