Skip to content

RETURNS

CREATE OR REPLACE FUNCTION getFullName(firstName text, lastName text)
RETURNS text AS
$BODY$
BEGIN
RETURN firstName || ' ' || lastName;
END;
$BODY$
LANGUAGE plpgsql;
SELECT getFullName('John', 'Doe');
'John Doe'

In the provided example, a function called getFullName is created, which concatenates two input texts firstName and lastName with a space in between. The RETURNS keyword indicates the data type of the output from this function, which in this case is ‘text’. The function is then invoked using a SELECT statement, returning ‘John Doe’.