Available in versions: Dev (3.19) | Latest (3.18) | 3.17 | 3.16 | 3.15

SIGNAL

Applies to ❌ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The standard SQL way to raise exceptions is via the SIGNAL statement, which is supported natively in a few dialects, and can be emulated in some others.

Some example SIGNAL invocations.

begin(signalSQLState("45000")).execute();
begin(signalSQLState("45000").setMessageText("Custom message")).execute();

Dialect support

This example using jOOQ:

signalSQLState("45000").setMessageText("Custom message")

Translates to the following dialect specific expressions:

-- DB2, HSQLDB, MARIADB, MYSQL
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Custom message'

-- HANA
SIGNAL SQL_ERROR_CODE '45000' SET MESSAGE_TEXT = 'Custom message'

-- POSTGRES, YUGABYTEDB
RAISE SQLSTATE '45000' USING MESSAGE = 'Custom message'

-- ACCESS, ASE, AURORA_MYSQL, AURORA_POSTGRES, BIGQUERY, COCKROACHDB, DERBY, DUCKDB, EXASOL, FIREBIRD, H2, INFORMIX, 
-- MEMSQL, ORACLE, REDSHIFT, SNOWFLAKE, SQLDATAWAREHOUSE, SQLITE, SQLSERVER, SYBASE, TERADATA, TRINO, VERTICA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.19, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo