Functions

This section describes the SDL declarations pertaining to functions.

Declare a custom function that concatenates the length of a string to the end of the that string:

function foo(s: str) -> str
    from EdgeQL $$
        SELECT s ++ <str>len(a)
    $$;

Define a new function corresponding to the more explicit DDL commands.

function name ([ argspec ] [, ... ]) -> returnspec
from language functionbody ;

function name ([ argspec ] [, ... ]) -> returnspec
"{"
    session_only := {true | false} ;
    [ annotation-declarations ]
    from language functionbody ;
"}" ;

where argspec is:

[ argkind ] argname: [ typequal ] argtype [ = default ]

argkind is:

[ { variadic | named only } ]

typequal is:

[ { set of | optional } ]

and returnspec is:

[ typequal ] rettype

The core of the declaration is identical to CREATE FUNCTION, while the valid SDL sub-declarations are listed below:

annotation-declarations

Set function annotation to a given value.