Skip to main content
Skip table of contents

Declaration Statement

A declaration statement declares a variable and its type. After you declare a variable, you can use it in that block within the procedure and any sub-blocks. A variable is initialized to null by default, but it can also be assigned the value of an expression as part of the declaration statement. 

Usage

SQL
DECLARE <type> [VARIABLES.]<name> [= <expression>];

Syntax

  • You cannot redeclare a variable with a duplicate name in a sub-block;
  • The VARIABLES group is always implied even if it is not specified;
  • The assignment value follows the same rules as for an assignment statement;
  • In addition to the standard types, you may specify EXCEPTION if declaring an exception variable.

Example

SQL
BEGIN 
    DECLARE INTEGER x;
    DECLARE STRING VARIABLES.myvar = 'value';
END
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.