Declares a variable.






where row-specification is:






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 recordVariable.fieldName is used.

A record can be declared as being the same as a table or a part of table with the AS clause. 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.

The optional DEFAULT clause may be used to specify an initial value for the variable(s). A value of null is permitted as the value for the DEFAULT clause.

If a ROW data type definition has been specified for data-type, a row value expression can be specified for expression in the DEFAULT clause.

If the DEFAULT clause is not specified, the variable(s) will be set to null initially.

In the case of a variable declared with the ROW data type, each field in the variable is set to null initially if a DEFAULT clause is not specified.


The name of a variable cannot be the same as any of the routine parameter names.

A function with MODIFIES SQL DATA specified for its access clause cannot be used as expression in the DEFAULT clause.


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.

If a variable is defined as using a domain, any assignment to this parameter will be verified to ensue that any check constraint is not violated. If the domain has a default value, the variable will be initialized with this value unless there is an explicit default clause in the declaration.




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.

Standard Compliance





Features outside core

Feature P002, ‚ÄúComputational completeness‚ÄĚ.


Mimer SQL extension

The use of AS-clause is a Mimer SQL extension.


Mimer SQL extension

The possibility to use domains in PSM is a Mimer SQL extension.