create_replace_function1.htm
Objectives:
  • The example below, shows how to use PostgreSQL sum function, which would return concatenated string embedded in a packet "$$' . This packet suffices as an Alias of a PL/pgSQL function
  • You may call this SUM function using server side scripts like PHP, using SQL constructs.

write this code

CREATE OR REPLACE FUNCTION sum (text, text)
RETURNS text AS $$
DECLARE
add text;
BEGIN
RETURN $1 || ' ' || $2;
END;
$$ LANGUAGE plpgsql;
SELECT sum('hello', 'world');

Now open psql command line too and call this function with two parameters

 

Using numeric as string

Use psql as calculator

Using PHP tool: