Firebird Documentation IndexFirebird 2.0 Language Ref. UpdateContext variables → SQLCODE
Firebird Home Firebird Home Prev: ROW_COUNTFirebird Documentation IndexUp: Context variablesNext: UPDATING

SQLCODE

Available in: PSQL

Added in: 1.5

Description: In a WHEN SQLCODE handling block, the SQLCODE context variable contains the current SQL error code. The same is true in a WHEN ANY block if its execution was triggered by an SQL error; otherwise it contains 0. SQLCODE is also 0 in WHEN GDSCODE and WHEN EXCEPTION handlers, as well as everywhere else in PSQL.

Type: INTEGER

Example: 

when any
do
begin
  if (sqlcode <> 0) then
    Msg = 'An SQL error occurred!';
  else
    Msg = 'Something bad happened!';
  exception ex_custom Msg;
end
Prev: ROW_COUNTFirebird Documentation IndexUp: Context variablesNext: UPDATING
Firebird Documentation IndexFirebird 2.0 Language Ref. UpdateContext variables → SQLCODE