ACTION
DEFINE ACTION
Specifies a named action that is a parameterizable block of multiple top-level expressions.
Syntax
DEFINE ACTION: action definition.- Action name that will be used to access the defined action further in the query.
 - The values of parameter names are listed in parentheses.
 ASkeyword.- List of top-level expressions.
 END DEFINE: The marker of the last expression inside the action.
One or more of the last parameters can be marked with a question mark ? as optional. If they are omitted during the call, they will be assigned the NULL value.
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.
Example
DEFINE ACTION $hello_world($name, $suffix?) AS
    $name = $name ?? ($suffix ?? "world");
    SELECT "Hello, " || $name || "!";
END DEFINE;
DO EMPTY_ACTION();
DO $hello_world(NULL);
DO $hello_world("John");
DO $hello_world(NULL, "Earth");
        
    BEGIN .. END DO
Performing an action without declaring it (anonymous action).
Syntax
BEGIN.- List of top-level expressions.
 END DO.
An anonymous action can't include any parameters.
Example
DO BEGIN
    SELECT 1;
    SELECT 2 -- here and in the previous example, you might omit ';' before END
END DO
        
    Was the article helpful?
Previous