Mega Code Archive

 
Categories / PostgreSQL / Store Procedure Function
 

The simplest possible SQL function has no arguments and simply returns a base type

postgres=# postgres=# -- The simplest possible SQL function has no arguments and simply returns a base type postgres=# postgres=# CREATE FUNCTION one() RETURNS integer AS $$ postgres$#    SELECT 1 AS result; postgres$# $$ LANGUAGE SQL; CREATE FUNCTION postgres=# postgres=# select one();  one -----    1 (1 row) postgres=# postgres=# drop function one(); DROP FUNCTION postgres=# postgres=#