statement

CREATE FUNCTION

Defines a callable SQL function. This PostgreSQL example returns an integer; function languages and security rules vary. Example target: PostgreSQL 17. Use only the isolated starter dataset; setup and expected results are in the batch evidence.

Formal Syntax & Structure

sql syntaxsql
CREATE FUNCTION name(type) RETURNS type LANGUAGE SQL AS body

Working Example

Example Snippetsql
CREATE FUNCTION lab_double(integer) RETURNS integer LANGUAGE SQL AS 'SELECT $1 * 2';
SQL Reference