CREATE OR REPLACE FUNCTION fn_person_and_phones (
personId IN NUMBER )
RETURN SYS_REFCURSOR
IS
personAndPhones SYS_REFCURSOR;
BEGIN
OPEN personAndPhones FOR
SELECT
pr.id AS \"pr.id\",
pr.name AS \"pr.name\",
pr.nickName AS \"pr.nickName\",
pr.address AS \"pr.address\",
pr.createdOn AS \"pr.createdOn\",
pr.version AS \"pr.version\",
ph.id AS \"ph.id\",
ph.person_id AS \"ph.person_id\",
ph.phone_number AS \"ph.phone_number\"
FROM person pr
JOIN phone ph ON pr.id = ph.person_id
WHERE pr.id = personId;
RETURN personAndPhones;
END;