Signal an exception condition.
Syntax
Usage
The SIGNAL statement is used to throw an exception with the message specified by the character string literal.
Examples
1) | The following example throws an exception: |
SIGNAL 'Dummy Exception.';
2) | The following example shows the SIGNAL statement used in a conditional computation: |
DECLARE v1, v2 DOUBLE PRECISION;
SET v1 = RAND;
SET v2 = RAND;
IF ( v1 = v2 ) THEN
SIGNAL 'The values are equal.';
ELSE
SIGNAL 'The values are different.';
END IF;
3) The following example shows the SIGNAL statement used in the CATCH clause of a TRY statement:
START TRANSACTION;
TRY
DROP TABLE garbage;
COMMIT;
CATCH POSITION( 'Unable to open table' IN ERROR_MESSAGE ) <> 0
ROLLBACK;
SIGNAL 'The table couldn''t be dropped.' || CHR(13) || 'The transaction was rolled back.';
END;
Conformance
SQL:2003 standard |
- |
SQL/PSM Feature P002-14 "SIGNAL statement" |