I have a stored procedure:
CREATE OR REPLACE FUNCTION postalcode_lookup(ccode character(6))
RETURNS SETOF postalcode AS $BODY$
BEGIN
WITH RECURSIVE tblParent AS
(
SELECT *
FROM postalcode
WHERE postalcode.code = ccode
UNION ALL
SELECT postalcode.*
FROM postalcode
JOIN tblParent ON postalcode.code = tblParent.parent
)
SELECT * FROM tblParent;
END;$BODY$ LANGUAGE plpgsql;
Compile successfully but when running I have
error: query has no destination for result data;SQL state: 42601;
Hint:> If you want to discard the results of a SELECT, use PERFORM instead. Context: PL/pgSQL function postalcode_lookup(character) line 3 at SQL statement
Please help me fix. Many thanks.