Navigation:  NexusDB Guide > SQL Reference > SQL Statements > Control Statements >

SIGNAL statement

Previous pageReturn to chapter overviewNext page

NexusDB V3 Manual

SIGNAL statement

button_main button_prev button_next

NexusDB Manual V3 > SQL Reference > SQL Statements > Control Statements

Signal an exception condition.

 

Syntax

 

<signal statement> ::= SIGNAL <character string literal>

 

 

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"

 

© Nexus Database Systems Pty Ltd.

nexus_logo