106: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
107: and nvl(STATUS, 'A') in ('A','I')
108: and exists
109: (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
110: or exists (select 'Y' from HZ_RELATIONSHIPS
111: xx where xx.OBJECT_ID = temp.party_id
112: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
113: AND directional_flag = 'F')
114: and exists
116: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
117: and nvl(STATUS, 'A') in ('A','I')
118: and exists
119: (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
120: or exists (select 'Y' from HZ_RELATIONSHIPS
121: xx where xx.PARTY_ID = temp.party_id
122: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
123: AND directional_flag = 'F')
124: and exists
126: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
127: and nvl(STATUS, 'A') in ('A','I')
128: and exists
129: (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
130: or exists (select 'Y' from HZ_RELATIONSHIPS
131: xx where xx.SUBJECT_ID = temp.party_id
132: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
133: AND directional_flag = 'F')
134: and exists
205: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
206: and nvl(STATUS, 'A') in ('A','I')
207: and exists
208: (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
209: or exists (select 'Y' from HZ_RELATIONSHIPS
210: xx where xx.OBJECT_ID = temp.party_id
211: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
212: AND directional_flag = 'F')
213: and exists
215: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
216: and nvl(STATUS, 'A') in ('A','I')
217: and exists
218: (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
219: or exists (select 'Y' from HZ_RELATIONSHIPS
220: xx where xx.PARTY_ID = temp.party_id
221: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
222: AND directional_flag = 'F')
223: and exists
225: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
226: and nvl(STATUS, 'A') in ('A','I')
227: and exists
228: (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
229: or exists (select 'Y' from HZ_RELATIONSHIPS
230: xx where xx.SUBJECT_ID = temp.party_id
231: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
232: AND directional_flag = 'F')
233: and exists
306:
307: or exists (select 'Y' from HZ_CUSTOMER_PROFILES xx where xx.PARTY_ID = temp.party_id
308: and (nvl(STATUS, 'A') in ('A','I')))
309:
310: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.OBJECT_ID = temp.party_id
311: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
312: AND directional_flag = 'F'))
313:
314: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.SUBJECT_ID = temp.party_id
310: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.OBJECT_ID = temp.party_id
311: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
312: AND directional_flag = 'F'))
313:
314: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.SUBJECT_ID = temp.party_id
315: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
316: AND directional_flag = 'F'));
317: else
318: delete from hz_purge_gt temp where
337:
338: or exists (select 'Y' from HZ_CUSTOMER_PROFILES xx where xx.PARTY_ID = temp.party_id
339: and (nvl(STATUS, 'A') in ('A','I')))
340:
341: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.OBJECT_ID = temp.party_id
342: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
343: AND directional_flag = 'F'))
344:
345: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.SUBJECT_ID = temp.party_id
341: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.OBJECT_ID = temp.party_id
342: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
343: AND directional_flag = 'F'))
344:
345: or exists (select 'Y' from HZ_RELATIONSHIPS xx where xx.SUBJECT_ID = temp.party_id
346: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
347: AND directional_flag = 'F'));
348: end if;
349:
1211: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
1212: and nvl(STATUS, 'A') in ('A','I')
1213: and exists
1214: (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1215: or exists (select 'Y' from HZ_RELATIONSHIPS
1216: xx where xx.OBJECT_ID = temp.party_id
1217: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1218: AND directional_flag = 'F')
1219: and exists
1221: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1222: and nvl(STATUS, 'A') in ('A','I')
1223: and exists
1224: (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1225: or exists (select 'Y' from HZ_RELATIONSHIPS
1226: xx where xx.PARTY_ID = temp.party_id
1227: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1228: AND directional_flag = 'F')
1229: and exists
1231: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1232: and nvl(STATUS, 'A') in ('A','I')
1233: and exists
1234: (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1235: or exists (select 'Y' from HZ_RELATIONSHIPS
1236: xx where xx.SUBJECT_ID = temp.party_id
1237: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1238: AND directional_flag = 'F')
1239: and exists
1285: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
1286: and nvl(STATUS, 'A') in ('A','I')
1287: and exists
1288: (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1289: or exists (select 'Y' from HZ_RELATIONSHIPS
1290: xx where xx.OBJECT_ID = temp.party_id
1291: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1292: AND directional_flag = 'F')
1293: and exists
1295: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1296: and nvl(STATUS, 'A') in ('A','I')
1297: and exists
1298: (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1299: or exists (select 'Y' from HZ_RELATIONSHIPS
1300: xx where xx.PARTY_ID = temp.party_id
1301: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1302: AND directional_flag = 'F')
1303: and exists
1305: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1306: and nvl(STATUS, 'A') in ('A','I')
1307: and exists
1308: (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1309: or exists (select 'Y' from HZ_RELATIONSHIPS
1310: xx where xx.SUBJECT_ID = temp.party_id
1311: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1312: AND directional_flag = 'F')
1313: and exists
1397: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
1398: and nvl(STATUS, 'A') in ('A','I')
1399: and exists
1400: (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1401: or exists (select 'Y' from HZ_RELATIONSHIPS
1402: xx where xx.OBJECT_ID = temp.party_id
1403: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1404: AND directional_flag = 'F')
1405: and exists
1407: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1408: and nvl(STATUS, 'A') in ('A','I')
1409: and exists
1410: (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1411: or exists (select 'Y' from HZ_RELATIONSHIPS
1412: xx where xx.PARTY_ID = temp.party_id
1413: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1414: AND directional_flag = 'F')
1415: and exists
1417: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1418: and nvl(STATUS, 'A') in ('A','I')
1419: and exists
1420: (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1421: or exists (select 'Y' from HZ_RELATIONSHIPS
1422: xx where xx.SUBJECT_ID = temp.party_id
1423: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1424: AND directional_flag = 'F')
1425: and exists
1530: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
1531: and nvl(STATUS, 'A') in ('A','I')
1532: and exists
1533: (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1534: or exists (select 'Y' from HZ_RELATIONSHIPS
1535: xx where xx.OBJECT_ID = temp.party_id
1536: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1537: AND directional_flag = 'F')
1538: and exists
1540: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1541: and nvl(STATUS, 'A') in ('A','I')
1542: and exists
1543: (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1544: or exists (select 'Y' from HZ_RELATIONSHIPS
1545: xx where xx.PARTY_ID = temp.party_id
1546: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1547: AND directional_flag = 'F')
1548: and exists
1550: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1551: and nvl(STATUS, 'A') in ('A','I')
1552: and exists
1553: (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1554: or exists (select 'Y' from HZ_RELATIONSHIPS
1555: xx where xx.SUBJECT_ID = temp.party_id
1556: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1557: AND directional_flag = 'F')
1558: and exists
1604: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
1605: and nvl(STATUS, 'A') in ('A','I')
1606: and exists
1607: (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1608: or exists (select 'Y' from HZ_RELATIONSHIPS
1609: xx where xx.OBJECT_ID = temp.party_id
1610: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1611: AND directional_flag = 'F')
1612: and exists
1614: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1615: and nvl(STATUS, 'A') in ('A','I')
1616: and exists
1617: (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1618: or exists (select 'Y' from HZ_RELATIONSHIPS
1619: xx where xx.PARTY_ID = temp.party_id
1620: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1621: AND directional_flag = 'F')
1622: and exists
1624: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1625: and nvl(STATUS, 'A') in ('A','I')
1626: and exists
1627: (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1628: or exists (select 'Y' from HZ_RELATIONSHIPS
1629: xx where xx.SUBJECT_ID = temp.party_id
1630: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1631: AND directional_flag = 'F')
1632: and exists
1716: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
1717: and nvl(STATUS, 'A') in ('A','I')
1718: and exists
1719: (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1720: or exists (select 'Y' from HZ_RELATIONSHIPS
1721: xx where xx.OBJECT_ID = temp.party_id
1722: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1723: AND directional_flag = 'F')
1724: and exists
1726: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1727: and nvl(STATUS, 'A') in ('A','I')
1728: and exists
1729: (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1730: or exists (select 'Y' from HZ_RELATIONSHIPS
1731: xx where xx.PARTY_ID = temp.party_id
1732: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1733: AND directional_flag = 'F')
1734: and exists
1736: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
1737: and nvl(STATUS, 'A') in ('A','I')
1738: and exists
1739: (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1740: or exists (select 'Y' from HZ_RELATIONSHIPS
1741: xx where xx.SUBJECT_ID = temp.party_id
1742: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
1743: AND directional_flag = 'F')
1744: and exists
2349: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
2350: and nvl(STATUS, 'A') in ('A','I')
2351: and exists
2352: (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2353: or exists (select 'Y' from HZ_RELATIONSHIPS
2354: xx where xx.OBJECT_ID = temp.party_id
2355: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
2356: AND directional_flag = 'F')
2357: and exists
2359: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
2360: and nvl(STATUS, 'A') in ('A','I')
2361: and exists
2362: (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2363: or exists (select 'Y' from HZ_RELATIONSHIPS
2364: xx where xx.PARTY_ID = temp.party_id
2365: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
2366: AND directional_flag = 'F')
2367: and exists
2369: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
2370: and nvl(STATUS, 'A') in ('A','I')
2371: and exists
2372: (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2373: or exists (select 'Y' from HZ_RELATIONSHIPS
2374: xx where xx.SUBJECT_ID = temp.party_id
2375: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
2376: AND directional_flag = 'F')
2377: and exists
2535: yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
2536: and nvl(STATUS, 'A') in ('A','I')
2537: and exists
2538: (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2539: or exists (select 'Y' from HZ_RELATIONSHIPS
2540: xx where xx.OBJECT_ID = temp.party_id
2541: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
2542: AND directional_flag = 'F')
2543: and exists
2545: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
2546: and nvl(STATUS, 'A') in ('A','I')
2547: and exists
2548: (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2549: or exists (select 'Y' from HZ_RELATIONSHIPS
2550: xx where xx.PARTY_ID = temp.party_id
2551: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
2552: AND directional_flag = 'F')
2553: and exists
2555: yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID
2556: and nvl(STATUS, 'A') in ('A','I')
2557: and exists
2558: (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2559: or exists (select 'Y' from HZ_RELATIONSHIPS
2560: xx where xx.SUBJECT_ID = temp.party_id
2561: and (nvl(STATUS, 'A') in ('A','I') AND subject_table_name = 'HZ_PARTIES' AND object_table_name = 'HZ_PARTIES'
2562: AND directional_flag = 'F')
2563: and exists