RDB$ERROR()
Returns PSQL error information inside a WHEN … DO block
PSQL
Varies (see table below)
RDB$ERROR (<context>) <context> ::= GDSCODE | SQLCODE | SQLSTATE | EXCEPTION | MESSAGE
| Context | Result type | Description | 
|---|---|---|
| 
 | 
 | Firebird error code, see also  | 
| 
 | 
 | (deprecated) SQL code, see also  | 
| 
 | 
 | SQLstate, see also  | 
| 
 | 
 | Name of the active user-defined exception or  | 
| 
 | 
 | Message text of the active exception | 
RDB$ERROR returns data of the specified context about the active PSQL exception.Its scope is confined to exception-handling blocks in PSQL (WHEN … DO).Outside the exception handling blocks, RDB$ERROR always returns NULL.This function cannot be called from DSQL.