Command
CREATE FUNCTION functionname(arguments) RETURNS return_type AS $$ BEGIN ... END; $$ LANGUAGE plpgsql;
Explanation
Creates a new function in the current database.
Examples
Create function to add two numbers
CREATE FUNCTION add_two_numbers(a int, b int) RETURNS int AS $$ BEGIN RETURN a + b; END; $$ LANGUAGE plpgsql;