DECLARE
Declares a typified named expression whose value will be passed by a parameter separately from the query's text. With parameterization, you can separately develop an analytical solution and then launch it sequentially with different input values.
In the case of transactional load, parameters let you avoid recompilation of queries when repeating calls of the same type. This way you can reduce server utilization and exclude compilation time from the total time of query execution.
Passing of parameters is supported in the SDK, CLI, and graphical interfaces.
Syntax
DECLARE $named-node AS data_type;
DECLARE
keyword.$named-node
: The name by which you can access the passed value. It must start with$
.AS
keyword.data_type
is the data type represented as a string in the accepted format.
Only serializable data types are allowed:
- Primitive types.
- Optional types.
- Containers except for
Stream<Type>
. Void
andNull
are the supported special types.
Example
DECLARE $x AS String;
DECLARE $y AS String?;
DECLARE $z AS List<String>;
SELECT $x, $y, $z;