NexusDB Starter Edition DCU added to your shopping cart.

Specify a statement block.


Syntax

<compound statement> ::=

BEGIN [ [ NOT ] ATOMIC ]

[ <local declaration list> ]

[ <SQL statement list> ]

END

<local declaration list> ::= { <SQL variable declaration> ; }...

<SQL statement list> ::= { <SQL procedure statement> ; }...


Usage

The Compound statement is used to specify a sequence of SQL procedure statements inside a BEGIN..END block.


Notes

NOT ATOMIC is implicit if neither ATOMIC nor NOT ATOMIC is specified.
If ATOMIC is specified, then an internal transaction is started before the statement block is executed. The transaction is committed only if all the statements in the block executed successfully, otherwise the transaction is rolled back.
All SQL variable declarations shall be specified before other SQL statements.


Examples

1) The following example shows a Compound statement with parameter declarations:

       DROP FUNCTION IF EXISTS dummyFunc;

       CREATE FUNCTION dummyFunc ()

       RETURNS DOUBLE PRECISION

       BEGIN

DECLARE v1, v2 DOUBLE PRECISION;

SET v1 = 25;

SET v2 = 4;

RETURN v1 * v2;

       END;

       SELECT dummyFunc FROM #dummy;


Conformance

SQL:2003 standard

-

-

SQL/PSM Feature P002-01 "Compound statement"

Beginning and ending statement labels are not supported

Home | Site Contents | Documentation | NexusDB Manual V4 | SQL Reference | SQL Statements | Control Statements