The SQLERRMESSAGE variable holds the error message corresponding to the last SQL error.
SQLERRMESSAGE
The SQLERRMESSAGE predefined variable returns the error message if an SQL error occurred.
The variable is NULL if the last SQL statement was successfull.
MAIN DATABASE stores WHENEVER ERROR CONTINUE SELECT foo FROM bar DISPLAY SQLERRMESSAGE END MAIN