VALUE

The VALUE statement declares global values.  It exists in two forms: the full form used to declare global values and a short form that omits the expression.  

 

VALUE @<value> <type> = <expression>

VALUE @<value> <type>

 

Examples

 

VALUE @deg2rad FLOAT64 = Pi / 180;

 

VALUE @angle FLOAT64 = 30;

 

VALUE @anglerad FLOAT64 = @angle * @deg2rad;

 

In the above, a type is required. The type can be TABLE.  A global variable can be redefined and assigned a different type and value. When this happens, previous references to the global variable will continue to use its former type and value,  similar to what happens when overriding functions.

 

Short form example

 

VALUE @name NVARCHAR;

 

The short form of VALUE takes an existing value and converts it to the specified type. If there is no value with the specified name defined, the short form defines it and sets it to a NULL value.  The short form is useful for handling query parameters.

 

Additional Examples

Add a computed field that uses a global value:

 

ALTER TABLE t (

  ADD d INT32

    WITH [[ VALUE @mul INT32 = 500; ]]

    AS [[ a * @mul ]]

);

 

Add a constraint that uses a global value:

 

ALTER TABLE t (

  ADD CONSTRAINT a_c

    WITH [[ VALUE @min INT32 = 0; ]]

    AS [[ a>=@min ]]

);

 

 

See Also

Queries

 

Command Window

 

Query Builder

 

SQL Statements

 

EXECUTE

 

GROUP BY

 

SPLIT

 

TABLE

 

UNION / EXCEPT / INTERSECT

 

VALUES