Declares a variable.
The value for data-type can be any data type supported by Mimer SQL, see Data Types in SQL Statements.
More than one variable of the same type can be declared in a single declaration.
It is possible to declare a variable as a record, by using the row specification.
The fields in a record may themselves be records, to an unlimited depth. To reference a field in a record the notation
A record can be declared as being the same as a table or a part of table with the
ASclause. This means that the fields in the record will have the same name and type as the columns in the table. If the column list is omitted, all columns are used.
DEFAULTclause may be used to specify an initial value for the variable(s). A value of null is permitted as the value for the
ROWdata type definition has been specified for data-type, a row value expression can be specified for expression in the
DEFAULTclause is not specified, the variable(s) will be set to null initially.
In the case of a variable declared with the
ROWdata type, each field in the variable is set to null initially if a
DEFAULTclause is not specified.
A domain cannot be used to specify the data type in a variable declaration.
The name of a variable cannot be the same as any of the routine parameter names.
A function with
MODIFIES SQL DATAspecified for its access clause cannot be used as
It is possible to declare a variable with the same name as that of a column in a table. In such a situation, an unqualified name will always resolve to the table column name and not the variable. We recommend that a suitable naming convention be adhered to that distinguishes between the two.
ExamplesDECLARE orderNumber INTEGER DEFAULT 0; DECLARE firstName,lastName VARCHAR(30); DECLARE purchase row(customerId integer, orderNumber integer, purchaseDate date, productId integer, quantity integer) DEFAULT (0,0,current_date,0,0); DECLARE book ROW AS (mimer_store_book.details); DECLARE bookTitle ROW AS(mimer_store_book.details(isbn,title));
For more information, see Mimer SQL Programmer's Manual, Declaring Variables.
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40