Mega Code Archive

 
Categories / PostgreSQL / Store Procedure Function
 

Define function to add two parameters together

postgres=# postgres=# CREATE FUNCTION add_em(integer, integer) RETURNS integer AS $$ postgres$#    SELECT $1 + $2; postgres$# $$ LANGUAGE SQL; CREATE FUNCTION postgres=# postgres=# SELECT add_em(1, 2) AS answer;  answer --------       3 (1 row) postgres=# postgres=# drop function add_em(integer, integer); DROP FUNCTION postgres=# postgres=#