SQLSTATE
SQLSTATE code of the Firebird error in a WHEN … DO
block
PSQL
CHAR(5)
SQLSTATE
In a “WHEN … DO
” error handler, the SQLSTATE
context variable contains the 5-character, SQL-compliant status code of the current error.Outside error handlers, SQLSTATE
is always '00000'
.Outside PSQL, it is not available at all.
Note
|
|
when any
do
begin
Msg = case sqlstate
when '22003' then 'Numeric value out of range.'
when '22012' then 'Division by zero.'
when '23000' then 'Integrity constraint violation.'
else 'Something bad happened! SQLSTATE = ' || sqlstate
end;
exception ex_custom Msg;
end