Syntax
Parameters
- Recursive definition is NOT supported at present. For example, the statement
create function recursive(INT, INT) returns int language sql as 'select recursive($1, $2) + recursive($1, $2)';will fail.
Examples
At present, we support SQL UDFs with unnamed and named parameters. This section offers examples of the current supported syntax. We will offer some basic examples first to help you understand and grasp them. Then, we will offer more examples that are closer to real-world scenarios, such as a mock table, for your further practice and understanding.Basic examples for SQL UDFs with unnamed and named parameters
- Create a SQL UDF with unnamed parameters and double dollar definition.
Create function
Call function
- Create a SQL UDF with unnamed parameters and single quote definition.
Create function
Call function
- Create a SQL UDF with unnamed parameters that calls other pre-defined SQL UDFs.
Create function
Call function
- Create a SQL UDF with named parameters and single quote definition.
Create function
Call function
- Create a SQL UDF with named parameters and double dollar definition.
Create function
Call function
- Create a SQL UDF with mixed named and unnamed parameters.
Create function
Call function
- Call a SQL UDF with unnamed parameters inside a SQL UDF with named parameters.
Create function
Call function
- Create a SQL UDF with unnamed parameters and a return expression.
Create function
Create function
- Create a SQL UDF with a return expression using previously defined UDFs.
Create function
Call function
- Create a SQL UDF with multiple types of parameters.
Create function
Call function
- Create a SQL UDF with complex types of unnamed parameters.
Create function
Call function
- Create a wrapper function.
Create function
Call function
Basic SQL UDFs integrated with the use of mock tables
The examples in this section are a basic simulation of real-world use cases.Create table
Insert data
Create function
Call function
Create function
Call function
Create function
Call function
Examples of corner and special cases tests
Create function
Call function
Create function
Call function
Create function
Call function
Create function
Call function
Note that double dollar signs should be used otherwise the parsing will fail.
Create function
Call function
Create function
Call function