Create data type
postgres=#
postgres=#
postgres=# CREATE TYPE sum_prod AS (sum int, product int);
CREATE TYPE
postgres=#
postgres=# CREATE FUNCTION sum_n_product (int, int) RETURNS sum_prod
postgres-# AS 'SELECT $1 + $2, $1 * $2'
postgres-# LANGUAGE SQL;
CREATE FUNCTION
postgres=#
postgres=# select sum_n_product (2, 1);
REATE
sum_n_product
---------------
(3,2)
(1 row)
postgres=#
postgres=# drop function sum_n_product (int, int) cascade;
DROP FUNCTION
postgres=# drop type sum_prod cascade;
DROP TYPE
postgres=#
postgres=#
Related examples in the same category