The simplest possible SQL function has no arguments and simply returns a base type : Create Function « Store Procedure Function « PostgreSQL






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=#

           
       








Related examples in the same category

1.Create a simeple function
2.Case insensitive
3.Add three parameters together in a function
4.Functions with Output Parameters
5.Pass in entire table row to a function