Mega Code Archive

 
Categories / PostgreSQL / Store Procedure Function
 

Call function in select statement

postgres=# CREATE FUNCTION "test" (integer) RETURNS integer AS ' postgres'# postgres'#  DECLARE postgres'#   variable ALIAS FOR $1; postgres'#  BEGIN postgres'#   return variable * 2; postgres'#  END; postgres'#  ' LANGUAGE 'plpgsql'; CREATE FUNCTION postgres=# postgres=# select test(1);  test ------     2 (1 row) postgres=# postgres=# drop function test(integer); DROP FUNCTION postgres=# postgres=#