DECLARE Constants
You can define constants in SQL Script by declaring them with unique names.
Syntax
DECLARE [PUBLIC] <variableName>[,…] <type> DEFAULT <valueExpression>]
Remarks
|
•
|
You must declare a CONSTANT before using it. |
|
•
|
DEFAULT initializes the variable. |
|
•
|
If you declare multiple variables (for example, ROW (a INT, b CHAR)), enclose a comma-separated list of default values in parentheses in the same order (for example, DEFAULT (1, 'abc')). |
|
•
|
A PUBLIC constant should be declared at a global level. |
|
•
|
You can use a constant wherever you can use a literal. |
|
•
|
Constants are not modifiable. |
Example
PROCEDURE constants ( )
BEGIN
DECLARE PUBLIC x CONSTANT INT DEFAULT 1234;
DECLARE PUBLIC y CONSTANT ROW (a INT, b CHAR) DEFAULT (1, 'abc');
END