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

SQLCODE

Tip

Find a more recent version at Firebird 5.0 Language Reference: 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. In a WHEN ANY block it contains the SQL error code if indeed an SQL error occurred; 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 1.5 Language Ref. UpdateContext variables → SQLCODE