Hi,
I have a simple bit of SQL to pull out details about supervisor chains in HR in Oracle EBS:
SELECT LPAD(' ', (LEVEL - 1) * 10, ' ') || person_id level_label
, LEVEL
, description
FROM applsys.fnd_user u
, hr.per_all_assignments_f h
WHERE u.employee_id = h.person_id
START WITH SYSDATE BETWEEN effective_start_date AND effective_end_date
AND person_id = :personid
CONNECT BY PRIOR person_id = supervisor_id
AND SYSDATE BETWEEN effective_start_date AND effective_end_date
It'll normally return data without a problem - e.g. dummy data below - looks fine. Names and person_ids made up.
LEVEL_LABEL LEVEL DESCRIPTION
000001 1 Person Person 1
000002 2 Harry Marry
000003 3 John Smith
000004 4 Jenna Jones
000005 4 Her Name
000006 4 His Name
000007 4 Joseph Coat
000008 4 Les Miserables
000009 3 Mister Smith
000010 3 Miss Jones
000011 3 Andrew And
000012 4 Claire So
000013 4 Hilary Hi
000014 2 Jenny Jones
000015 3 Amanda Mandy
000016 4 James Jim
000017 4 William Wonder
000018 4 Crazy Cat
000019 4 Silly Cat
000020 4 Tall Hill
000021 4 Amazing Grace
000022 3 Lovely Mountain
000023 4 Joyous Spring
000024 4 Anonymous Name
000025 4 Brian Binky
However, if I try for another person_id, for which a user is getting an error in part of Oracle EBS, I get this error:
ORA-01436: CONNECT BY loop in user data
I'm guessing there is a supervisor loop happening somewhere, but I don't know how to investigate where it might be happening.
I wondered if there is any way I can modify the SQL to be able to work out where the loop might be, as there are about 50 staff involved in the dept. for this user and I have been through all of their records and can't see a loop from looking through the Oracle HR screens.
I know it's a "big ask", to ask a vague question about some oracle SQL, so apologies for that.
Any advice much appreciated.
Thanks