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

DECLARE variable statement

Previous pageReturn to chapter overviewNext page

NexusDB V3 Manual

DECLARE variable statement

button_main button_prev button_next

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

Declare one or more SQL variables.

 

Syntax

 

<SQL variable declaration> ::=

 

 

 

DECLARE <SQL variable name list> <data type> [ <default clause> ]

<SQL variable name list> ::= variable-name [ { , variable-name }... ]

 

 

Usage

 

The DECLARE statement is used to declare SQL variables. SQL variables that are declared in the context of triggers, procedures and functions are local to the statement block where they are declared. SQL variables that are declared in the context of the main executing statement block are global session variables.

 

 

Notes

 

§

SQL variable names shall conform to the rules for identifiers in NexusDB SQL.

 

§

One ore more SQL variables can be declared with the same data type.

 

§

The DEFAULT clause is used to specify an initial value for the variable, and is similar to setting a default value for a column.

 

Examples

 

1)

The following examples declares two SQL variables with the same data type:

 

      DECLARE min, max INTEGER;

 

2)

The following example declares two SQL variables with different data types:

 

      DECLARE count INTEGER DEFAULT 0;

      DECLARE total DOUBLE PRECISION DEFAULT 0;

 


Conformance

 

SQL:2003 standard

-

SQL/PSM Feature P002-04 "SQL variable declaration"

 

© Nexus Database Systems Pty Ltd.

nexus_logo