ACTION
An action that is a parameterizable block of multiple top-level expressions.
DEFINE ACTION
defines an action that can then be accessed repeatedly using DO
.
You can use DO ACTION
in the body of the EVALUATE IF
condition or EVALUATE FOR
cycle.
DEFINE ACTION
Defines an ACTION
consisting of the specified expressions.
Syntax
DEFINE ACTION
: action definition.- A named expression that will be used to access the defined action further in the query.
- The round brackets contain a list of named expressions you can use to access parameters inside the action.
AS
keyword.- List of top-level expressions.
END DEFINE
: The marker of the last expression inside the action.
DO
Executes an ACTION
with the specified parameters.
Syntax
DO
: Executing an action.- The named expression for which the action is defined.
- The values to be used as parameters are listed in parentheses.
EMPTY_ACTION
: An action that does nothing.
Note
In large queries, you can use separate files for action definition and include them to the main query using EXPORT + IMPORT
. To define actions on tables by using a separate library, make sure to include USE my_cluster;
in it: action compilation depends on the cluster type.
Example
DEFINE ACTION $hello_world($name) AS
$name = $name ?? "world";
SELECT "Hello, " || $name || "!";
END DEFINE;
DO EMPTY_ACTION();
DO $hello_world(NULL);
DO $hello_world("John");