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

Compound statement

Previous pageReturn to chapter overviewNext page

NexusDB V3 Manual

Compound statement

button_main button_prev button_next

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

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

 

© Nexus Database Systems Pty Ltd.

nexus_logo