SQLCODE

<< ROW_COUNT | FB 2.1 Language Reference | UPDATING >>
<< ROW_COUNT | FB 2.0 Language Reference | 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

back to top of page
<< ROW_COUNT | FB 2.1 Language Reference | UPDATING >>
<< ROW_COUNT | FB 2.0 Language Reference | UPDATING >>