DECLARE
CURSOR cur_main
IS
SELECT DISTINCT person_id, full_name
FROM per_all_people_f
WHERE PERSON_ID = 1234; -- person id
CURSOR cur_sup (p_person_id NUMBER)
IS
SELECT DISTINCT paf.person_id,
ppf.full_name,
LEVEL,
ppf.email_address
FROM per_all_people_f ppf, per_all_assignments_f PAF
WHERE 1 = 1 AND ppf.person_id = PAF.PERSON_ID
CONNECT BY PRIOR paf.supervisor_id = ppf.person_id
START WITH paf.person_id = 1234 -- person id
ORDER BY LEVEL;
BEGIN
DBMS_OUTPUT.enable (1000000);
BEGIN
--dbms_output.put_line('Approver','Level','Supervisor');
FOR cur_main_rec IN cur_main
LOOP
FOR cur_sup_rec IN cur_sup (cur_main_rec.person_id)
LOOP
DBMS_OUTPUT.put_line (
cur_sup_rec.full_name || ' ' || CUR_SUP_REC.PERSON_ID);
END LOOP;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error in updation ' || SQLERRM);
END;
END;
No comments:
Post a Comment