DECLARE VARIABLE
Declares a local variable
DECLARE [VARIABLE] varname
<domain_or_non_array_type> [NOT NULL] [COLLATE collation]
[{DEFAULT | = } <initvalue>];
<domain_or_non_array_type> ::=
!! See Scalar Data Types Syntax !!
<initvalue> ::= <literal> | <context_var>
| Argument | Description |
|---|---|
varname |
Name of the local variable |
collation |
Collation |
initvalue |
Initial value for this variable |
literal |
Literal of a type compatible with the type of the local variable |
context_var |
Any context variable whose type is compatible with the type of the local variable |
The statement DECLARE [VARIABLE] is used for declaring a local variable.One DECLARE [VARIABLE] statement is required for each local variable.Any number of DECLARE [VARIABLE] statements can be included and in any order.The name of a local variable must be unique among the names of local variables and input and output parameters declared for the module.
A special case of DECLARE [VARIABLE] — declaring cursors — is covered separately in [fblangref50-psql-declare-cursor]