Define function to add two parameters together : Function Return « Store Procedure Function « PostgreSQL






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








Related examples in the same category

1.Return entire row
2.Using the result set returned from the function
3.Returning a concatenated string
4.Return 'double' from function
5.A SQL function that returns a book title based on the ID number passed to the function
6.Return a table from a function