Add three parameters together in a function
postgres=#
postgres=# CREATE FUNCTION add_three_values(v1 anyelement, v2 anyelement, v3 anyelement)
postgres-# RETURNS anyelement AS $$
postgres$# DECLARE
postgres$# result ALIAS FOR $0;
postgres$# BEGIN
postgres$# result := v1 + v2 + v3;
postgres$# RETURN result;
postgres$# END;
postgres$# $$ LANGUAGE plpgsql;
CREATE FUNCTION
postgres=#
postgres=# select add_three_values(1,2,3);
REATE
add_three_values
------------------
6
(1 row)
postgres=#
postgres=# drop function add_three_values(v1 anyelement, v2 anyelement, v3 anyelement);
DROP FUNCTION
postgres=#
postgres=#
Related examples in the same category