SQL Functions

User defined SQL functions can be created to process the results of SQL queries.

See create_function() for further details. 

A SQL function must have a body which consists of a single valid SQL SELECT statement which can refer to zero, one or more of the function arguments. The statement should be terminated with a semicolon.

The following provide valid examples of a SQL function body for a function with X and Y arguments:

SELECT 1; -- always returns 1
SELECT X+Y; -- returns the sum of the function arguments
SELECT count(*) FROM mytable WHERE name=X; -- returns count of rows where name is the first argument

Have more questions? Submit a request

Comments

Article is closed for comments.

Powered by Zendesk