Icon ERRORMSG

Returns the current error message.

Syntax
ERRORMSG()

Returns
VARCHAR

Usage
The ERRORMSG function returns the current error message. This function can only be called from within an EXCEPTION block or from within an error trigger. See the CREATE TRIGGER topic for more information on error triggers.

Examples
-- This procedure uses an exception
-- block to handle any exceptions while
-- executing a CREATE TABLE statement

CREATE PROCEDURE CreateTestTable()
BEGIN
   DECLARE stmt STATEMENT;

   PREPARE stmt FROM 'CREATE TEMPORARY TABLE "TestTable"
                     (
                     "FirstColumn" INTEGER,
                     "SecondColumn" VARCHAR(30),
                     "ThirdColumn" CLOB,
                     PRIMARY KEY ("FirstColumn")
                     )

                     DESCRIPTION ''Test Table''';

   EXECUTE stmt;
EXCEPTION
   IF ERRORCODE()=700 THEN
      RAISE ERROR CODE 10000 MESSAGE 'Syntax error';
   ELSE
      RAISE ERROR CODE 10000 MESSAGE 'Unexpected error - ' +
           ERRORMSG();
   END IF;
END

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image