DBA Data[Home] [Help]

PACKAGE BODY: APPS.HZ_PURGE_GEN

Source


1 PACKAGE BODY HZ_PURGE_GEN AS
2 PROCEDURE IDENTIFY_CANDIDATES(p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
3                          x_return_status  OUT NOCOPY  VARCHAR2,
4                          x_msg_count OUT NOCOPY  NUMBER,
5                          x_msg_data OUT NOCOPY   VARCHAR2,
6                          check_flag boolean, con_prg boolean, regid_proc boolean) IS
7 appid number;
8 sql_count number;
9 total_parties number;
10 parties_count1 number;
11 parties_count2 number;
12 single_party number;
13 
14 
15 cursor repopulate is
16 select party_id from hz_purge_gt;
17 
18 
19 BEGIN
20 
21 
22 SAVEPOINT identify_candidates;
23 IF FND_API.to_Boolean(p_init_msg_list) THEN
24 FND_MSG_PUB.initialize;
25 END IF;
26 x_return_status := FND_API.G_RET_STS_SUCCESS;
27 delete from hz_application_trans_gt; 
28 open repopulate;
29 fetch repopulate into single_party;
30 close repopulate;
31 --delete and insert records into hz_purge_gt for an application
32 appid:=8404;
33  if(regid_proc = true) then 
34 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp where 
35 
36 
37  exists (select 'Y' from IGW_PROP_PERSONS_TCA_V xx where xx.PERSON_PARTY_ID =  temp.party_id 
38  );
39  else 
40 delete from hz_purge_gt temp where 
41 
42 
43  exists (select 'Y' from IGW_PROP_PERSONS_TCA_V xx where xx.PERSON_PARTY_ID =  temp.party_id 
44  );
45 end if;
46 
47 
48 --delete and insert records into hz_purge_gt for an application
49 appid:=691;
50  if(regid_proc = true) then 
51 insert into hz_application_trans_gt(app_id,party_id) select 691, temp.party_id from hz_purge_gt temp where 
52 
53 
54  exists (select 'Y' from PV_PARTNER_PROFILES xx where xx.PARTNER_ID =  temp.party_id 
55  )
56 
57  or exists (select 'Y' from PV_ENTY_ATTR_VALUES xx where xx.ENTITY_ID =  temp.party_id 
58  )
59 
60  or exists (select 'Y' from PV_LEAD_ASSIGNMENTS xx where xx.PARTNER_ID =  temp.party_id 
61  )
62 
63  or exists (select 'Y' from PV_ASSIGNMENT_LOGS xx where xx.PARTNER_ID =  temp.party_id 
64  )
65 
66  or exists (select 'Y' from PV_SEARCH_ATTR_VALUES xx where xx.PARTY_ID =  temp.party_id 
67  )
68 
69  or exists (select 'Y' from PV_GE_PTNR_RESPS xx where xx.PARTNER_ID =  temp.party_id 
70  )
71 
72  or exists (select 'Y' from PV_LEAD_PSS_LINES xx where xx.PARTNER_ID =  temp.party_id 
73  )
74 
75  or exists (select 'Y' from PV_GE_PARTY_NOTIFICATIONS xx where xx.PARTNER_ID =  temp.party_id 
76  )
77 
78  or exists (select 'Y' from PV_PG_ENRL_REQUESTS xx where xx.PARTNER_ID =  temp.party_id 
79  )
80 
81  or exists (select 'Y' from PV_PG_MEMBERSHIPS xx where xx.PARTNER_ID =  temp.party_id 
82  )
83 
84  or exists (select 'Y' from PV_PARTNER_PROFILES xx where xx.PARTNER_PARTY_ID =  temp.party_id 
85  )
86 
87  or exists (select 'Y' from PV_REFERRALS_B xx where xx.PARTNER_ID =  temp.party_id 
88  )
89 
90  or exists (select 'Y' from PV_REFERRALS_B xx where xx.CUSTOMER_PARTY_ID =  temp.party_id 
91  )
92 
93  or exists (select 'Y' from HZ_PARTY_SITES
94  xx where xx.PARTY_ID =  temp.party_id 
95  and (nvl(STATUS, 'A') in ('A','I'))
96  and exists
97 (select 'Y' from PV_REFERRALS_B
98  yy where yy.CUSTOMER_PARTY_SITE_ID=xx.PARTY_SITE_ID
99 ))
100 
101  or exists (select 'Y' from HZ_PARTY_SITES
102  xx where xx.PARTY_ID =  temp.party_id 
103  and (nvl(STATUS, 'A') in ('A','I'))
104  and exists 
105  (select 'Y' from HZ_ORG_CONTACTS
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 
115  (select 'Y' from HZ_ORG_CONTACTS
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 
125  (select 'Y' from HZ_ORG_CONTACTS
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 
135  (select 'Y' from HZ_ORG_CONTACTS
136  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
137  and nvl(STATUS, 'A') in ('A','I')
138  and exists 
139  (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
140 
141  or exists (select 'Y' from PV_REFERRALS_B xx where xx.CUSTOMER_CONTACT_PARTY_ID =  temp.party_id 
142  )
143 
144  or exists (select 'Y' from PV_LEAD_ASSIGNMENTS xx where xx.RELATED_PARTY_ID =  temp.party_id 
145  )
146 
147  or exists (select 'Y' from PV_PARTNER_ACCESSES xx where xx.PARTNER_ID =  temp.party_id 
148  );
149  else 
150 delete from hz_purge_gt temp where 
151 
152 
153  exists (select 'Y' from PV_PARTNER_PROFILES xx where xx.PARTNER_ID =  temp.party_id 
154  )
155 
156  or exists (select 'Y' from PV_ENTY_ATTR_VALUES xx where xx.ENTITY_ID =  temp.party_id 
157  )
158 
159  or exists (select 'Y' from PV_LEAD_ASSIGNMENTS xx where xx.PARTNER_ID =  temp.party_id 
160  )
161 
162  or exists (select 'Y' from PV_ASSIGNMENT_LOGS xx where xx.PARTNER_ID =  temp.party_id 
163  )
164 
165  or exists (select 'Y' from PV_SEARCH_ATTR_VALUES xx where xx.PARTY_ID =  temp.party_id 
166  )
167 
168  or exists (select 'Y' from PV_GE_PTNR_RESPS xx where xx.PARTNER_ID =  temp.party_id 
169  )
170 
171  or exists (select 'Y' from PV_LEAD_PSS_LINES xx where xx.PARTNER_ID =  temp.party_id 
172  )
173 
174  or exists (select 'Y' from PV_GE_PARTY_NOTIFICATIONS xx where xx.PARTNER_ID =  temp.party_id 
175  )
176 
177  or exists (select 'Y' from PV_PG_ENRL_REQUESTS xx where xx.PARTNER_ID =  temp.party_id 
178  )
179 
180  or exists (select 'Y' from PV_PG_MEMBERSHIPS xx where xx.PARTNER_ID =  temp.party_id 
181  )
182 
183  or exists (select 'Y' from PV_PARTNER_PROFILES xx where xx.PARTNER_PARTY_ID =  temp.party_id 
184  )
185 
186  or exists (select 'Y' from PV_REFERRALS_B xx where xx.PARTNER_ID =  temp.party_id 
187  )
188 
189  or exists (select 'Y' from PV_REFERRALS_B xx where xx.CUSTOMER_PARTY_ID =  temp.party_id 
190  )
191 
192  or exists (select 'Y' from HZ_PARTY_SITES
193  xx where xx.PARTY_ID =  temp.party_id 
194  and (nvl(STATUS, 'A') in ('A','I'))
195  and exists
196 (select 'Y' from PV_REFERRALS_B
197  yy where yy.CUSTOMER_PARTY_SITE_ID=xx.PARTY_SITE_ID
198 ))
199 
200  or exists (select 'Y' from HZ_PARTY_SITES
201  xx where xx.PARTY_ID =  temp.party_id 
202  and (nvl(STATUS, 'A') in ('A','I'))
203  and exists 
204  (select 'Y' from HZ_ORG_CONTACTS
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 
214  (select 'Y' from HZ_ORG_CONTACTS
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 
224  (select 'Y' from HZ_ORG_CONTACTS
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 
234  (select 'Y' from HZ_ORG_CONTACTS
235  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
236  and nvl(STATUS, 'A') in ('A','I')
237  and exists 
238  (select 'Y' from PV_REFERRALS_B zz where zz.CUSTOMER_ORG_CONTACT_ID = yy.ORG_CONTACT_ID )))
239 
240  or exists (select 'Y' from PV_REFERRALS_B xx where xx.CUSTOMER_CONTACT_PARTY_ID =  temp.party_id 
241  )
242 
243  or exists (select 'Y' from PV_LEAD_ASSIGNMENTS xx where xx.RELATED_PARTY_ID =  temp.party_id 
244  )
245 
246  or exists (select 'Y' from PV_PARTNER_ACCESSES xx where xx.PARTNER_ID =  temp.party_id 
247  );
248 end if;
249 
250 
251 --delete and insert records into hz_purge_gt for an application
252 appid:=665;
253  if(regid_proc = true) then 
254 insert into hz_application_trans_gt(app_id,party_id) select 665, temp.party_id from hz_purge_gt temp where 
255 
256 
257  exists (select 'Y' from WSH_CARRIERS xx where xx.CARRIER_ID =  temp.party_id 
258  )
259 
260  or exists (select 'Y' from HZ_PARTY_SITES
261  xx where xx.PARTY_ID =  temp.party_id 
262  and (nvl(STATUS, 'A') in ('A','I'))
263  and exists
264 (select 'Y' from WSH_CARRIER_SITES
265  yy where yy.CARRIER_SITE_ID=xx.PARTY_SITE_ID
266 ));
267  else 
268 delete from hz_purge_gt temp where 
269 
270 
271  exists (select 'Y' from WSH_CARRIERS xx where xx.CARRIER_ID =  temp.party_id 
272  )
273 
274  or exists (select 'Y' from HZ_PARTY_SITES
275  xx where xx.PARTY_ID =  temp.party_id 
276  and (nvl(STATUS, 'A') in ('A','I'))
277  and exists
278 (select 'Y' from WSH_CARRIER_SITES
279  yy where yy.CARRIER_SITE_ID=xx.PARTY_SITE_ID
280 ));
281 end if;
282 
283 
284 --delete and insert records into hz_purge_gt for an application
285 appid:=222;
286  if(regid_proc = true) then 
287 insert into hz_application_trans_gt(app_id,party_id) select 222, temp.party_id from hz_purge_gt temp where 
288 
289 
290  exists (select 'Y' from HZ_ORGANIZATION_PROFILES xx where xx.DISPLAYED_DUNS_PARTY_ID =  temp.party_id 
291  and (nvl(STATUS, 'A') in ('A','I')))
292 
293  or exists (select 'Y' from HZ_CUST_ACCOUNTS xx where xx.PARTY_ID =  temp.party_id 
294  and (nvl(STATUS, 'A') in ('A','I')))
295 
296  or exists (select 'Y' from HZ_PARTY_SITES
297  xx where xx.PARTY_ID =  temp.party_id 
298  and (nvl(STATUS, 'A') in ('A','I'))
299  and exists
300 (select 'Y' from HZ_CUST_ACCT_SITES_ALL
301  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
302  and nvl(STATUS, 'A') in ('A','I')))
303 
304  or exists (select 'Y' from HZ_CUST_ACCOUNTS xx where xx.SELLING_PARTY_ID =  temp.party_id 
305  and (nvl(STATUS, 'A') in ('A','I')))
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 
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 
319 
320 
321  exists (select 'Y' from HZ_ORGANIZATION_PROFILES xx where xx.DISPLAYED_DUNS_PARTY_ID =  temp.party_id 
322  and (nvl(STATUS, 'A') in ('A','I')))
323 
324  or exists (select 'Y' from HZ_CUST_ACCOUNTS xx where xx.PARTY_ID =  temp.party_id 
325  and (nvl(STATUS, 'A') in ('A','I')))
326 
327  or exists (select 'Y' from HZ_PARTY_SITES
328  xx where xx.PARTY_ID =  temp.party_id 
329  and (nvl(STATUS, 'A') in ('A','I'))
330  and exists
331 (select 'Y' from HZ_CUST_ACCT_SITES_ALL
332  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID
333  and nvl(STATUS, 'A') in ('A','I')))
334 
335  or exists (select 'Y' from HZ_CUST_ACCOUNTS xx where xx.SELLING_PARTY_ID =  temp.party_id 
336  and (nvl(STATUS, 'A') in ('A','I')))
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 
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 
350 
351 --delete and insert records into hz_purge_gt for an application
352 appid:=671;
353  if(regid_proc = true) then 
354 insert into hz_application_trans_gt(app_id,party_id) select 671, temp.party_id from hz_purge_gt temp where 
355 
356 
357  exists (select 'Y' from IBE_SH_SHP_LISTS_ALL xx where xx.PARTY_ID =  temp.party_id 
358  )
359 
360  or exists (select 'Y' from IBE_ORD_ONECLICK_ALL xx where xx.PARTY_ID =  temp.party_id 
361  )
362 
363  or exists (select 'Y' from HZ_PARTY_SITES
364  xx where xx.PARTY_ID =  temp.party_id 
365  and (nvl(STATUS, 'A') in ('A','I'))
366  and exists
367 (select 'Y' from IBE_ORD_ONECLICK_ALL
368  yy where yy.BILL_TO_PTY_SITE_ID=xx.PARTY_SITE_ID
369 ))
370 
371  or exists (select 'Y' from HZ_PARTY_SITES
372  xx where xx.PARTY_ID =  temp.party_id 
373  and (nvl(STATUS, 'A') in ('A','I'))
374  and exists
375 (select 'Y' from IBE_ORD_ONECLICK_ALL
376  yy where yy.SHIP_TO_PTY_SITE_ID=xx.PARTY_SITE_ID
377 ))
378 
379  or exists (select 'Y' from IBE_MSITE_PRTY_ACCSS xx where xx.PARTY_ID =  temp.party_id 
380  );
381  else 
382 delete from hz_purge_gt temp where 
383 
384 
385  exists (select 'Y' from IBE_SH_SHP_LISTS_ALL xx where xx.PARTY_ID =  temp.party_id 
386  )
387 
388  or exists (select 'Y' from IBE_ORD_ONECLICK_ALL xx where xx.PARTY_ID =  temp.party_id 
389  )
390 
391  or exists (select 'Y' from HZ_PARTY_SITES
392  xx where xx.PARTY_ID =  temp.party_id 
393  and (nvl(STATUS, 'A') in ('A','I'))
394  and exists
395 (select 'Y' from IBE_ORD_ONECLICK_ALL
396  yy where yy.BILL_TO_PTY_SITE_ID=xx.PARTY_SITE_ID
397 ))
398 
399  or exists (select 'Y' from HZ_PARTY_SITES
400  xx where xx.PARTY_ID =  temp.party_id 
401  and (nvl(STATUS, 'A') in ('A','I'))
402  and exists
403 (select 'Y' from IBE_ORD_ONECLICK_ALL
404  yy where yy.SHIP_TO_PTY_SITE_ID=xx.PARTY_SITE_ID
405 ))
406 
407  or exists (select 'Y' from IBE_MSITE_PRTY_ACCSS xx where xx.PARTY_ID =  temp.party_id 
408  );
409 end if;
410 
411 
412 --delete and insert records into hz_purge_gt for an application
413 appid:=682;
414  if(regid_proc = true) then 
415 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp where 
416 
417 
418  exists (select 'Y' from OZF_CUST_TRD_PRFLS_ALL xx where xx.PARTY_ID =  temp.party_id 
419  )
420 
421  or exists (select 'Y' from OZF_CLAIMS_ALL xx where xx.BROKER_ID =  temp.party_id 
422  )
423 
424  or exists (select 'Y' from OZF_CLAIMS_ALL xx where xx.CONTACT_ID =  temp.party_id 
425  )
426 
427  or exists (select 'Y' from OZF_ACT_BUDGETS xx where xx.BUDGET_SOURCE_ID =  temp.party_id 
428  and (BUDGET_SOURCE_TYPE='PTNR'))
429 
430  or exists (select 'Y' from OZF_ACT_BUDGETS xx where xx.VENDOR_ID =  temp.party_id 
431  )
432 
433  or exists (select 'Y' from OZF_OFFERS xx where xx.BUYING_GROUP_CONTACT_ID =  temp.party_id 
434  )
435 
436  or exists (select 'Y' from OZF_REQUEST_HEADERS_ALL_B xx where xx.PARTNER_ID =  temp.party_id 
437  )
438 
439  or exists (select 'Y' from OZF_CODE_CONVERSIONS_ALL xx where xx.PARTY_ID =  temp.party_id 
440  )
441 
442  or exists (select 'Y' from OZF_RESALE_BATCHES_ALL xx where xx.PARTNER_PARTY_ID =  temp.party_id 
443  )
444 
445  or exists (select 'Y' from OZF_REQUEST_HEADERS_ALL_B xx where xx.PARTNER_ID =  temp.party_id 
446  );
447  else 
448 delete from hz_purge_gt temp where 
449 
450 
451  exists (select 'Y' from OZF_CUST_TRD_PRFLS_ALL xx where xx.PARTY_ID =  temp.party_id 
452  )
453 
454  or exists (select 'Y' from OZF_CLAIMS_ALL xx where xx.BROKER_ID =  temp.party_id 
455  )
456 
457  or exists (select 'Y' from OZF_CLAIMS_ALL xx where xx.CONTACT_ID =  temp.party_id 
458  )
459 
460  or exists (select 'Y' from OZF_ACT_BUDGETS xx where xx.BUDGET_SOURCE_ID =  temp.party_id 
461  and (BUDGET_SOURCE_TYPE='PTNR'))
462 
463  or exists (select 'Y' from OZF_ACT_BUDGETS xx where xx.VENDOR_ID =  temp.party_id 
464  )
465 
466  or exists (select 'Y' from OZF_OFFERS xx where xx.BUYING_GROUP_CONTACT_ID =  temp.party_id 
467  )
468 
469  or exists (select 'Y' from OZF_REQUEST_HEADERS_ALL_B xx where xx.PARTNER_ID =  temp.party_id 
470  )
471 
472  or exists (select 'Y' from OZF_CODE_CONVERSIONS_ALL xx where xx.PARTY_ID =  temp.party_id 
473  )
474 
475  or exists (select 'Y' from OZF_RESALE_BATCHES_ALL xx where xx.PARTNER_PARTY_ID =  temp.party_id 
476  )
477 
478  or exists (select 'Y' from OZF_REQUEST_HEADERS_ALL_B xx where xx.PARTNER_ID =  temp.party_id 
479  );
480 end if;
481 
482 
483 --delete and insert records into hz_purge_gt for an application
484 appid:=695;
485  if(regid_proc = true) then 
486 insert into hz_application_trans_gt(app_id,party_id) select 695, temp.party_id from hz_purge_gt temp where 
487 
488 
489  exists (select 'Y' from IEX_DELINQUENCIES_ALL xx where xx.PARTY_CUST_ID =  temp.party_id 
490  )
491 
492  or exists (select 'Y' from HZ_PARTY_SITES
493  xx where xx.PARTY_ID =  temp.party_id 
494  and (nvl(STATUS, 'A') in ('A','I'))
495  and exists
496 (select 'Y' from IEX_CASE_CONTACTS
497  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
498 ));
499  else 
500 delete from hz_purge_gt temp where 
501 
502 
503  exists (select 'Y' from IEX_DELINQUENCIES_ALL xx where xx.PARTY_CUST_ID =  temp.party_id 
504  )
505 
506  or exists (select 'Y' from HZ_PARTY_SITES
507  xx where xx.PARTY_ID =  temp.party_id 
508  and (nvl(STATUS, 'A') in ('A','I'))
509  and exists
510 (select 'Y' from IEX_CASE_CONTACTS
511  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
512 ));
513 end if;
514 
515 
516 --delete and insert records into hz_purge_gt for an application
517 appid:=8405;
518  if(regid_proc = true) then 
519 insert into hz_application_trans_gt(app_id,party_id) select 8405, temp.party_id from hz_purge_gt temp where 
520 
521 
522  exists (select 'Y' from HZ_EDUCATION
523  xx where xx.PARTY_ID =  temp.party_id 
524  and (nvl(STATUS, 'A') in ('A','I'))
525  and exists
526 (select 'Y' from IGS_AD_HZ_ACAD_HIST
527  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
528 ))
529  or exists (select 'Y' from HZ_EDUCATION
530  xx where xx.SCHOOL_PARTY_ID =  temp.party_id 
531  and (nvl(STATUS,'A') in ('A','I'))
532  and exists
533 (select 'Y' from IGS_AD_HZ_ACAD_HIST
534  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
535 ))
536 
537  or exists (select 'Y' from HZ_EMPLOYMENT_HISTORY
538  xx where xx.PARTY_ID =  temp.party_id 
539  and (nvl(STATUS, 'A') in ('A','I'))
540  and exists
541 (select 'Y' from IGS_AD_HZ_EMP_DTL
542  yy where yy.EMPLOYMENT_HISTORY_ID=xx.EMPLOYMENT_HISTORY_ID
543 ))
544  or exists (select 'Y' from HZ_EMPLOYMENT_HISTORY
545  xx where xx.EMPLOYED_BY_PARTY_ID =  temp.party_id 
546  and (nvl(STATUS,'A') in ('A','I'))
547  and exists
548 (select 'Y' from IGS_AD_HZ_EMP_DTL
549  yy where yy.EMPLOYMENT_HISTORY_ID=xx.EMPLOYMENT_HISTORY_ID
550 ))
551 
552  or exists (select 'Y' from HZ_PERSON_INTEREST
553  xx where xx.PARTY_ID =  temp.party_id 
554  and (nvl(STATUS, 'A') in ('A','I'))
555  and exists
556 (select 'Y' from IGS_AD_HZ_EXTRACURR_ACT
557  yy where yy.PERSON_INTEREST_ID=xx.PERSON_INTEREST_ID
558 ))
559 
560  or exists (select 'Y' from HZ_EDUCATION
561  xx where xx.PARTY_ID =  temp.party_id 
562  and (nvl(STATUS, 'A') in ('A','I'))
563  and exists
564 (select 'Y' from IGS_AD_TRANSCRIPT
565  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
566 ))
567  or exists (select 'Y' from HZ_EDUCATION
568  xx where xx.SCHOOL_PARTY_ID =  temp.party_id 
569  and (nvl(STATUS,'A') in ('A','I'))
570  and exists
571 (select 'Y' from IGS_AD_TRANSCRIPT
572  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
573 ))
574 
575  or exists (select 'Y' from IGS_PE_HZ_PARTIES xx where xx.PARTY_ID =  temp.party_id 
576  )
577 
578  or exists (select 'Y' from IGS_FI_CREDITS_ALL xx where xx.PARTY_ID =  temp.party_id 
579  )
580 
581  or exists (select 'Y' from IGS_FI_INV_INT_ALL xx where xx.PERSON_ID =  temp.party_id 
582  )
583 
584  or exists (select 'Y' from IGS_FI_PARTY_VENDRS xx where xx.PARTY_ID =  temp.party_id 
585  )
586 
587  or exists (select 'Y' from IGS_FI_PP_STD_ATTRS xx where xx.PERSON_ID =  temp.party_id 
588  )
589 
590  or exists (select 'Y' from IGS_FI_P_SA_NOTES xx where xx.PARTY_ID =  temp.party_id 
591  )
592 
593  or exists (select 'Y' from IGS_FI_REFUNDS xx where xx.PERSON_ID =  temp.party_id 
594  )
595 
596  or exists (select 'Y' from IGP_AC_ACCOUNTS xx where xx.PARTY_ID =  temp.party_id 
597  );
598  else 
599 delete from hz_purge_gt temp where 
600 
601 
602  exists (select 'Y' from HZ_EDUCATION
603  xx where xx.PARTY_ID =  temp.party_id 
604  and (nvl(STATUS, 'A') in ('A','I'))
605  and exists
606 (select 'Y' from IGS_AD_HZ_ACAD_HIST
607  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
608 ))
609  or exists (select 'Y' from HZ_EDUCATION
610  xx where xx.SCHOOL_PARTY_ID =  temp.party_id 
611  and (nvl(STATUS,'A') in ('A','I'))
612  and exists
613 (select 'Y' from IGS_AD_HZ_ACAD_HIST
614  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
615 ))
616 
617  or exists (select 'Y' from HZ_EMPLOYMENT_HISTORY
618  xx where xx.PARTY_ID =  temp.party_id 
619  and (nvl(STATUS, 'A') in ('A','I'))
620  and exists
621 (select 'Y' from IGS_AD_HZ_EMP_DTL
622  yy where yy.EMPLOYMENT_HISTORY_ID=xx.EMPLOYMENT_HISTORY_ID
623 ))
624  or exists (select 'Y' from HZ_EMPLOYMENT_HISTORY
625  xx where xx.EMPLOYED_BY_PARTY_ID =  temp.party_id 
626  and (nvl(STATUS,'A') in ('A','I'))
627  and exists
628 (select 'Y' from IGS_AD_HZ_EMP_DTL
629  yy where yy.EMPLOYMENT_HISTORY_ID=xx.EMPLOYMENT_HISTORY_ID
630 ))
631 
632  or exists (select 'Y' from HZ_PERSON_INTEREST
633  xx where xx.PARTY_ID =  temp.party_id 
634  and (nvl(STATUS, 'A') in ('A','I'))
635  and exists
636 (select 'Y' from IGS_AD_HZ_EXTRACURR_ACT
637  yy where yy.PERSON_INTEREST_ID=xx.PERSON_INTEREST_ID
638 ))
639 
640  or exists (select 'Y' from HZ_EDUCATION
641  xx where xx.PARTY_ID =  temp.party_id 
642  and (nvl(STATUS, 'A') in ('A','I'))
643  and exists
644 (select 'Y' from IGS_AD_TRANSCRIPT
645  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
646 ))
647  or exists (select 'Y' from HZ_EDUCATION
648  xx where xx.SCHOOL_PARTY_ID =  temp.party_id 
649  and (nvl(STATUS,'A') in ('A','I'))
650  and exists
651 (select 'Y' from IGS_AD_TRANSCRIPT
652  yy where yy.EDUCATION_ID=xx.EDUCATION_ID
653 ))
654 
655  or exists (select 'Y' from IGS_PE_HZ_PARTIES xx where xx.PARTY_ID =  temp.party_id 
656  )
657 
658  or exists (select 'Y' from IGS_FI_CREDITS_ALL xx where xx.PARTY_ID =  temp.party_id 
659  )
660 
661  or exists (select 'Y' from IGS_FI_INV_INT_ALL xx where xx.PERSON_ID =  temp.party_id 
662  )
663 
664  or exists (select 'Y' from IGS_FI_PARTY_VENDRS xx where xx.PARTY_ID =  temp.party_id 
665  )
666 
667  or exists (select 'Y' from IGS_FI_PP_STD_ATTRS xx where xx.PERSON_ID =  temp.party_id 
668  )
669 
670  or exists (select 'Y' from IGS_FI_P_SA_NOTES xx where xx.PARTY_ID =  temp.party_id 
671  )
672 
673  or exists (select 'Y' from IGS_FI_REFUNDS xx where xx.PERSON_ID =  temp.party_id 
674  )
675 
676  or exists (select 'Y' from IGP_AC_ACCOUNTS xx where xx.PARTY_ID =  temp.party_id 
677  );
678 end if;
679 
680 
681 --delete and insert records into hz_purge_gt for an application
682 appid:=661;
683  if(regid_proc = true) then 
684 insert into hz_application_trans_gt(app_id,party_id) select 661, temp.party_id from hz_purge_gt temp where 
685 
686 
687  exists (select 'Y' from QP_QUALIFIERS xx where xx.QUALIFIER_ATTR_VALUE =  to_char(temp.party_id) 
688  and ((qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE1'  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute ='QUALIFIER_ATTRIBUTE16'  OR qualifier_context = 'CUSTOMER_GROUP' AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE3'  OR qualifier_context = 'PARTY' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE1', 'QUALIFIER_ATTRIBUTE2'))))
689 
690  or exists (select 'Y' from HZ_PARTY_SITES
691  xx where xx.PARTY_ID =  temp.party_id 
692  and (nvl(STATUS, 'A') in ('A','I'))
693  and exists
694 (select 'Y' from QP_QUALIFIERS
695  yy where yy.QUALIFIER_ATTR_VALUE=to_char(xx.PARTY_SITE_ID)
696  and (qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE10','QUALIFIER_ATTRIBUTE11')  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE17', 'QUALIFIER_ATTRIBUTE18'))));
697  else 
698 delete from hz_purge_gt temp where 
699 
700 
701  exists (select 'Y' from QP_QUALIFIERS xx where xx.QUALIFIER_ATTR_VALUE =  to_char(temp.party_id) 
702  and ((qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE1'  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute ='QUALIFIER_ATTRIBUTE16'  OR qualifier_context = 'CUSTOMER_GROUP' AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE3'  OR qualifier_context = 'PARTY' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE1', 'QUALIFIER_ATTRIBUTE2'))))
703 
704  or exists (select 'Y' from HZ_PARTY_SITES
705  xx where xx.PARTY_ID =  temp.party_id 
706  and (nvl(STATUS, 'A') in ('A','I'))
707  and exists
708 (select 'Y' from QP_QUALIFIERS
709  yy where yy.QUALIFIER_ATTR_VALUE=to_char(xx.PARTY_SITE_ID)
710  and (qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE10','QUALIFIER_ATTRIBUTE11')  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE17', 'QUALIFIER_ATTRIBUTE18'))));
711 end if;
712 
713 
714 --delete and insert records into hz_purge_gt for an application
715 appid:=694;
716  if(regid_proc = true) then 
717 insert into hz_application_trans_gt(app_id,party_id) select 694, temp.party_id from hz_purge_gt temp where 
718 
719 
720  exists (select 'Y' from PRP_PROPOSALS xx where xx.PARTY_ID =  temp.party_id 
721  );
722  else 
723 delete from hz_purge_gt temp where 
724 
725 
726  exists (select 'Y' from PRP_PROPOSALS xx where xx.PARTY_ID =  temp.party_id 
727  );
728 end if;
729 
730 
731 --delete and insert records into hz_purge_gt for an application
732 appid:=542;
733  if(regid_proc = true) then 
734 insert into hz_application_trans_gt(app_id,party_id) select 542, temp.party_id from hz_purge_gt temp where 
735 
736 
737  exists (select 'Y' from CSI_ITEM_INSTANCES xx where xx.OWNER_PARTY_ID =  temp.party_id 
738  )
739 
740  or exists (select 'Y' from HZ_PARTY_SITES
741  xx where xx.PARTY_ID =  temp.party_id 
742  and (nvl(STATUS, 'A') in ('A','I'))
743  and exists
744 (select 'Y' from CSI_T_TXN_LINE_DETAILS
745  yy where yy.LOCATION_ID=xx.PARTY_SITE_ID
746 ))
747 
748  or exists (select 'Y' from HZ_PARTY_SITES
749  xx where xx.PARTY_ID =  temp.party_id 
750  and (nvl(STATUS, 'A') in ('A','I'))
751  and exists
752 (select 'Y' from CSI_T_TXN_LINE_DETAILS
753  yy where yy.INSTALL_LOCATION_ID=xx.PARTY_SITE_ID
754 ))
755 
756  or exists (select 'Y' from CSI_I_PARTIES xx where xx.PARTY_ID =  temp.party_id 
757  )
758 
759  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.SHIP_TO_CONTACT_ID =  temp.party_id 
760  )
761 
762  or exists (select 'Y' from CSI_T_PARTY_DETAILS xx where xx.PARTY_SOURCE_ID =  temp.party_id 
763  )
764 
765  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.SHIP_TO_CONTACT_ID =  temp.party_id 
766  )
767 
768  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.BILL_TO_CONTACT_ID =  temp.party_id 
769  )
770 
771  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.TECHNICAL_CONTACT_ID =  temp.party_id 
772  )
773 
774  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.SERVICE_ADMIN_CONTACT_ID =  temp.party_id 
775  )
776 
777  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.BILL_TO_CONTACT_ID =  temp.party_id 
778  )
779 
780  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.SERVICE_ADMIN_CONTACT_ID =  temp.party_id 
781  )
782 
783  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.TECHNICAL_CONTACT_ID =  temp.party_id 
784  )
785 
786  or exists (select 'Y' from HZ_PARTY_SITES
787  xx where xx.PARTY_ID =  temp.party_id 
788  and (nvl(STATUS, 'A') in ('A','I'))
789  and exists
790 (select 'Y' from CSI_SYSTEMS_B
791  yy where yy.INSTALL_SITE_USE_ID=xx.PARTY_SITE_ID
792 ));
793  else 
794 delete from hz_purge_gt temp where 
795 
796 
797  exists (select 'Y' from CSI_ITEM_INSTANCES xx where xx.OWNER_PARTY_ID =  temp.party_id 
798  )
799 
800  or exists (select 'Y' from HZ_PARTY_SITES
801  xx where xx.PARTY_ID =  temp.party_id 
802  and (nvl(STATUS, 'A') in ('A','I'))
803  and exists
804 (select 'Y' from CSI_T_TXN_LINE_DETAILS
805  yy where yy.LOCATION_ID=xx.PARTY_SITE_ID
806 ))
807 
808  or exists (select 'Y' from HZ_PARTY_SITES
809  xx where xx.PARTY_ID =  temp.party_id 
810  and (nvl(STATUS, 'A') in ('A','I'))
811  and exists
812 (select 'Y' from CSI_T_TXN_LINE_DETAILS
813  yy where yy.INSTALL_LOCATION_ID=xx.PARTY_SITE_ID
814 ))
815 
816  or exists (select 'Y' from CSI_I_PARTIES xx where xx.PARTY_ID =  temp.party_id 
817  )
818 
819  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.SHIP_TO_CONTACT_ID =  temp.party_id 
820  )
821 
822  or exists (select 'Y' from CSI_T_PARTY_DETAILS xx where xx.PARTY_SOURCE_ID =  temp.party_id 
823  )
824 
825  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.SHIP_TO_CONTACT_ID =  temp.party_id 
826  )
827 
828  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.BILL_TO_CONTACT_ID =  temp.party_id 
829  )
830 
831  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.TECHNICAL_CONTACT_ID =  temp.party_id 
832  )
833 
834  or exists (select 'Y' from CSI_SYSTEMS_B xx where xx.SERVICE_ADMIN_CONTACT_ID =  temp.party_id 
835  )
836 
837  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.BILL_TO_CONTACT_ID =  temp.party_id 
838  )
839 
840  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.SERVICE_ADMIN_CONTACT_ID =  temp.party_id 
841  )
842 
843  or exists (select 'Y' from CSI_T_TXN_SYSTEMS xx where xx.TECHNICAL_CONTACT_ID =  temp.party_id 
844  )
845 
846  or exists (select 'Y' from HZ_PARTY_SITES
847  xx where xx.PARTY_ID =  temp.party_id 
848  and (nvl(STATUS, 'A') in ('A','I'))
849  and exists
850 (select 'Y' from CSI_SYSTEMS_B
851  yy where yy.INSTALL_SITE_USE_ID=xx.PARTY_SITE_ID
852 ));
853 end if;
854 
855 
856 --delete and insert records into hz_purge_gt for an application
857 appid:=510;
858  if(regid_proc = true) then 
859 insert into hz_application_trans_gt(app_id,party_id) select 510, temp.party_id from hz_purge_gt temp where 
860 
861 
862  exists (select 'Y' from OKC_K_PARTY_ROLES_B xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
863  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
864 
865  or exists (select 'Y' from OKC_CONTACTS xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
866  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_CONTACTS')))
867 
868  or exists (select 'Y' from OKC_RULES_B xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
869  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
870 
871  or exists (select 'Y' from OKC_RULES_B xx where xx.OBJECT2_ID1 =  to_char(temp.party_id) 
872  and (jtot_object2_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
873 
874  or exists (select 'Y' from OKC_RULES_B xx where xx.OBJECT3_ID1 =  to_char(temp.party_id) 
875  and (jtot_object3_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
876 
877  or exists (select 'Y' from HZ_PARTY_SITES
878  xx where xx.PARTY_ID =  temp.party_id 
879  and (nvl(STATUS, 'A') in ('A','I'))
880  and exists
881 (select 'Y' from OKC_RULES_B
882  yy where yy.OBJECT1_ID1=to_char(xx.PARTY_SITE_ID)
883  and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
884 
885  or exists (select 'Y' from HZ_PARTY_SITES
886  xx where xx.PARTY_ID =  temp.party_id 
887  and (nvl(STATUS, 'A') in ('A','I'))
888  and exists
889 (select 'Y' from OKC_RULES_B
890  yy where yy.OBJECT2_ID1=to_char(xx.PARTY_SITE_ID)
891  and jtot_object2_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
892 
893  or exists (select 'Y' from HZ_PARTY_SITES
894  xx where xx.PARTY_ID =  temp.party_id 
895  and (nvl(STATUS, 'A') in ('A','I'))
896  and exists
897 (select 'Y' from OKC_RULES_B
898  yy where yy.OBJECT3_ID1=to_char(xx.PARTY_SITE_ID)
899  and jtot_object3_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
900 
901  or exists (select 'Y' from HZ_PARTY_SITES
902  xx where xx.PARTY_ID =  temp.party_id 
903  and (nvl(STATUS, 'A') in ('A','I'))
904  and exists 
905  (select 'Y' from HZ_PARTY_SITE_USES
906  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
907  and nvl(STATUS, 'A') in ('A','I')
908  and exists 
909  (select 'Y' from OKC_RULES_B zz where zz.OBJECT1_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))))
910 
911  or exists (select 'Y' from HZ_PARTY_SITES
912  xx where xx.PARTY_ID =  temp.party_id 
913  and (nvl(STATUS, 'A') in ('A','I'))
914  and exists 
915  (select 'Y' from HZ_PARTY_SITE_USES
916  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
917  and nvl(STATUS, 'A') in ('A','I')
918  and exists 
919  (select 'Y' from OKC_RULES_B zz where zz.OBJECT2_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object2_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))))
920 
921  or exists (select 'Y' from HZ_PARTY_SITES
922  xx where xx.PARTY_ID =  temp.party_id 
923  and (nvl(STATUS, 'A') in ('A','I'))
924  and exists 
925  (select 'Y' from HZ_PARTY_SITE_USES
926  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
927  and nvl(STATUS, 'A') in ('A','I')
928  and exists 
929  (select 'Y' from OKC_RULES_B zz where zz.OBJECT3_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object3_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))))
930 
931  or exists (select 'Y' from OKC_K_ITEMS xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
932  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
933 
934  or exists (select 'Y' from HZ_PARTY_SITES
935  xx where xx.PARTY_ID =  temp.party_id 
936  and (nvl(STATUS, 'A') in ('A','I'))
937  and exists
938 (select 'Y' from OKC_K_ITEMS
939  yy where yy.OBJECT1_ID1=to_char(xx.PARTY_SITE_ID)
940  and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
941 
942  or exists (select 'Y' from HZ_PARTY_SITES
943  xx where xx.PARTY_ID =  temp.party_id 
944  and (nvl(STATUS, 'A') in ('A','I'))
945  and exists 
946  (select 'Y' from HZ_PARTY_SITE_USES
947  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
948  and nvl(STATUS, 'A') in ('A','I')
949  and exists 
950  (select 'Y' from OKC_K_ITEMS zz where zz.OBJECT1_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))));
951  else 
952 delete from hz_purge_gt temp where 
953 
954 
955  exists (select 'Y' from OKC_K_PARTY_ROLES_B xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
956  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
957 
958  or exists (select 'Y' from OKC_CONTACTS xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
959  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_CONTACTS')))
960 
961  or exists (select 'Y' from OKC_RULES_B xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
962  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
963 
964  or exists (select 'Y' from OKC_RULES_B xx where xx.OBJECT2_ID1 =  to_char(temp.party_id) 
965  and (jtot_object2_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
966 
967  or exists (select 'Y' from OKC_RULES_B xx where xx.OBJECT3_ID1 =  to_char(temp.party_id) 
968  and (jtot_object3_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
969 
970  or exists (select 'Y' from HZ_PARTY_SITES
971  xx where xx.PARTY_ID =  temp.party_id 
972  and (nvl(STATUS, 'A') in ('A','I'))
973  and exists
974 (select 'Y' from OKC_RULES_B
975  yy where yy.OBJECT1_ID1=to_char(xx.PARTY_SITE_ID)
976  and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
977 
978  or exists (select 'Y' from HZ_PARTY_SITES
979  xx where xx.PARTY_ID =  temp.party_id 
980  and (nvl(STATUS, 'A') in ('A','I'))
981  and exists
982 (select 'Y' from OKC_RULES_B
983  yy where yy.OBJECT2_ID1=to_char(xx.PARTY_SITE_ID)
984  and jtot_object2_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
985 
986  or exists (select 'Y' from HZ_PARTY_SITES
987  xx where xx.PARTY_ID =  temp.party_id 
988  and (nvl(STATUS, 'A') in ('A','I'))
989  and exists
990 (select 'Y' from OKC_RULES_B
991  yy where yy.OBJECT3_ID1=to_char(xx.PARTY_SITE_ID)
992  and jtot_object3_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
993 
994  or exists (select 'Y' from HZ_PARTY_SITES
995  xx where xx.PARTY_ID =  temp.party_id 
996  and (nvl(STATUS, 'A') in ('A','I'))
997  and exists 
998  (select 'Y' from HZ_PARTY_SITE_USES
999  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
1000  and nvl(STATUS, 'A') in ('A','I')
1001  and exists 
1002  (select 'Y' from OKC_RULES_B zz where zz.OBJECT1_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))))
1003 
1004  or exists (select 'Y' from HZ_PARTY_SITES
1005  xx where xx.PARTY_ID =  temp.party_id 
1006  and (nvl(STATUS, 'A') in ('A','I'))
1007  and exists 
1008  (select 'Y' from HZ_PARTY_SITE_USES
1009  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
1010  and nvl(STATUS, 'A') in ('A','I')
1011  and exists 
1012  (select 'Y' from OKC_RULES_B zz where zz.OBJECT2_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object2_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))))
1013 
1014  or exists (select 'Y' from HZ_PARTY_SITES
1015  xx where xx.PARTY_ID =  temp.party_id 
1016  and (nvl(STATUS, 'A') in ('A','I'))
1017  and exists 
1018  (select 'Y' from HZ_PARTY_SITE_USES
1019  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
1020  and nvl(STATUS, 'A') in ('A','I')
1021  and exists 
1022  (select 'Y' from OKC_RULES_B zz where zz.OBJECT3_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object3_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))))
1023 
1024  or exists (select 'Y' from OKC_K_ITEMS xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
1025  and (jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_PARTY')))
1026 
1027  or exists (select 'Y' from HZ_PARTY_SITES
1028  xx where xx.PARTY_ID =  temp.party_id 
1029  and (nvl(STATUS, 'A') in ('A','I'))
1030  and exists
1031 (select 'Y' from OKC_K_ITEMS
1032  yy where yy.OBJECT1_ID1=to_char(xx.PARTY_SITE_ID)
1033  and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE')))
1034 
1035  or exists (select 'Y' from HZ_PARTY_SITES
1036  xx where xx.PARTY_ID =  temp.party_id 
1037  and (nvl(STATUS, 'A') in ('A','I'))
1038  and exists 
1039  (select 'Y' from HZ_PARTY_SITE_USES
1040  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
1041  and nvl(STATUS, 'A') in ('A','I')
1042  and exists 
1043  (select 'Y' from OKC_K_ITEMS zz where zz.OBJECT1_ID1=to_char(yy.PARTY_SITE_USE_ID) and jtot_object1_code IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'OKX_P_SITE_USE'))));
1044 end if;
1045 
1046 
1047 --delete and insert records into hz_purge_gt for an application
1048 appid:=697;
1049  if(regid_proc = true) then 
1050 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp where 
1051 
1052 
1053  exists (select 'Y' from ASO_QUOTE_HEADERS_ALL xx where xx.PARTY_ID =  temp.party_id 
1054  )
1055 
1056  or exists (select 'Y' from HZ_PARTY_SITES
1057  xx where xx.PARTY_ID =  temp.party_id 
1058  and (nvl(STATUS, 'A') in ('A','I'))
1059  and exists
1060 (select 'Y' from ASO_SHIPMENTS
1061  yy where yy.SHIP_TO_PARTY_SITE_ID=xx.PARTY_SITE_ID
1062 ))
1063 
1064  or exists (select 'Y' from ASO_QUOTE_HEADERS_ALL xx where xx.CUST_PARTY_ID =  temp.party_id 
1065  );
1066  else 
1067 delete from hz_purge_gt temp where 
1068 
1069 
1070  exists (select 'Y' from ASO_QUOTE_HEADERS_ALL xx where xx.PARTY_ID =  temp.party_id 
1071  )
1072 
1073  or exists (select 'Y' from HZ_PARTY_SITES
1074  xx where xx.PARTY_ID =  temp.party_id 
1075  and (nvl(STATUS, 'A') in ('A','I'))
1076  and exists
1077 (select 'Y' from ASO_SHIPMENTS
1078  yy where yy.SHIP_TO_PARTY_SITE_ID=xx.PARTY_SITE_ID
1079 ))
1080 
1081  or exists (select 'Y' from ASO_QUOTE_HEADERS_ALL xx where xx.CUST_PARTY_ID =  temp.party_id 
1082  );
1083 end if;
1084 
1085 
1086 --delete and insert records into hz_purge_gt for an application
1087 appid:=777;
1088  if(regid_proc = true) then 
1089 insert into hz_application_trans_gt(app_id,party_id) select 777, temp.party_id from hz_purge_gt temp where 
1090 
1091 
1092  exists (select 'Y' from OKE_K_FUNDING_SOURCES_PM_HV xx where xx.K_PARTY_ID =  temp.party_id 
1093  )
1094 
1095  or exists (select 'Y' from OKE_K_FUNDING_SOURCES xx where xx.K_PARTY_ID =  temp.party_id 
1096  );
1097  else 
1098 delete from hz_purge_gt temp where 
1099 
1100 
1101  exists (select 'Y' from OKE_K_FUNDING_SOURCES_PM_HV xx where xx.K_PARTY_ID =  temp.party_id 
1102  )
1103 
1104  or exists (select 'Y' from OKE_K_FUNDING_SOURCES xx where xx.K_PARTY_ID =  temp.party_id 
1105  );
1106 end if;
1107 
1108 
1109 --delete and insert records into hz_purge_gt for an application
1110 appid:=867;
1111  if(regid_proc = true) then 
1112 insert into hz_application_trans_gt(app_id,party_id) select 867, temp.party_id from hz_purge_gt temp where 
1113 
1114 
1115  exists (select 'Y' from AHL_DOCUMENTS_B xx where xx.SOURCE_PARTY_ID =  temp.party_id 
1116  )
1117 
1118  or exists (select 'Y' from AHL_SUPPLIER_DOCUMENTS xx where xx.SUPPLIER_ID =  temp.party_id 
1119  )
1120 
1121  or exists (select 'Y' from AHL_RECIPIENT_DOCUMENTS xx where xx.RECIPIENT_PARTY_ID =  temp.party_id 
1122  )
1123 
1124  or exists (select 'Y' from AHL_DOC_REVISIONS_B xx where xx.APPROVED_BY_PARTY_ID =  temp.party_id 
1125  );
1126  else 
1127 delete from hz_purge_gt temp where 
1128 
1129 
1130  exists (select 'Y' from AHL_DOCUMENTS_B xx where xx.SOURCE_PARTY_ID =  temp.party_id 
1131  )
1132 
1133  or exists (select 'Y' from AHL_SUPPLIER_DOCUMENTS xx where xx.SUPPLIER_ID =  temp.party_id 
1134  )
1135 
1136  or exists (select 'Y' from AHL_RECIPIENT_DOCUMENTS xx where xx.RECIPIENT_PARTY_ID =  temp.party_id 
1137  )
1138 
1139  or exists (select 'Y' from AHL_DOC_REVISIONS_B xx where xx.APPROVED_BY_PARTY_ID =  temp.party_id 
1140  );
1141 end if;
1142 
1143 
1144 --delete and insert records into hz_purge_gt for an application
1145 appid:=279;
1146  if(regid_proc = true) then 
1147 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp where 
1148 
1149 
1150  exists (select 'Y' from HZ_PARTY_SITES
1151  xx where xx.PARTY_ID =  temp.party_id 
1152  and (nvl(STATUS, 'A') in ('A','I'))
1153  and exists
1154 (select 'Y' from AS_SALES_LEAD_CONTACTS
1155  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1156 ))
1157 
1158  or exists (select 'Y' from HZ_CONTACT_POINTS
1159  xx where xx.OWNER_TABLE_ID =  temp.party_id 
1160  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
1161  and exists
1162 (select 'Y' from AS_SALES_LEAD_CONTACTS
1163  yy where yy.PHONE_ID=xx.CONTACT_POINT_ID
1164 ))
1165  or exists (select 'Y' from HZ_PARTY_SITES
1166  xx where xx.PARTY_ID =  temp.party_id 
1167  and (nvl(STATUS, 'A') in ('A','I'))
1168  and exists 
1169  (select 'Y' from HZ_CONTACT_POINTS
1170  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
1171  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
1172  and exists 
1173  (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.PHONE_ID = yy.CONTACT_POINT_ID )))
1174 
1175  or exists (select 'Y' from AS_SALES_LEAD_CONTACTS xx where xx.CONTACT_PARTY_ID =  temp.party_id 
1176  )
1177 
1178  or exists (select 'Y' from AS_ACCESSES_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1179  )
1180 
1181  or exists (select 'Y' from HZ_PARTY_SITES
1182  xx where xx.PARTY_ID =  temp.party_id 
1183  and (nvl(STATUS, 'A') in ('A','I'))
1184  and exists
1185 (select 'Y' from AS_ACCESSES_ALL
1186  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1187 ))
1188 
1189  or exists (select 'Y' from AS_ACCESSES_ALL xx where xx.PARTNER_CUSTOMER_ID =  temp.party_id 
1190  )
1191 
1192  or exists (select 'Y' from AS_ACCESSES_ALL xx where xx.PARTNER_CONT_PARTY_ID =  temp.party_id 
1193  )
1194 
1195  or exists (select 'Y' from AS_INTERESTS_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1196  )
1197 
1198  or exists (select 'Y' from HZ_PARTY_SITES
1199  xx where xx.PARTY_ID =  temp.party_id 
1200  and (nvl(STATUS, 'A') in ('A','I'))
1201  and exists
1202 (select 'Y' from AS_INTERESTS_ALL
1203  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1204 ))
1205 
1206  or exists (select 'Y' from HZ_PARTY_SITES
1207  xx where xx.PARTY_ID =  temp.party_id 
1208  and (nvl(STATUS, 'A') in ('A','I'))
1209  and exists 
1210  (select 'Y' from HZ_ORG_CONTACTS
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 
1220  (select 'Y' from HZ_ORG_CONTACTS
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 
1230  (select 'Y' from HZ_ORG_CONTACTS
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 
1240  (select 'Y' from HZ_ORG_CONTACTS
1241  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
1242  and nvl(STATUS, 'A') in ('A','I')
1243  and exists 
1244  (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1245 
1246  or exists (select 'Y' from HZ_PARTY_SITES
1247  xx where xx.PARTY_ID =  temp.party_id 
1248  and (nvl(STATUS, 'A') in ('A','I'))
1249  and exists
1250 (select 'Y' from AS_ACCESSES_ALL
1251  yy where yy.PARTNER_ADDRESS_ID=xx.PARTY_SITE_ID
1252 ))
1253 
1254  or exists (select 'Y' from AS_SALES_LEADS xx where xx.CUSTOMER_ID =  temp.party_id 
1255  )
1256 
1257  or exists (select 'Y' from AS_SALES_LEAD_CONTACTS xx where xx.CUSTOMER_ID =  temp.party_id 
1258  )
1259 
1260  or exists (select 'Y' from AS_LEADS_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1261  )
1262 
1263  or exists (select 'Y' from HZ_PARTY_SITES
1264  xx where xx.PARTY_ID =  temp.party_id 
1265  and (nvl(STATUS, 'A') in ('A','I'))
1266  and exists
1267 (select 'Y' from AS_LEADS_ALL
1268  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1269 ))
1270 
1271  or exists (select 'Y' from AS_LEADS_ALL xx where xx.CLOSE_COMPETITOR_ID =  temp.party_id 
1272  )
1273 
1274  or exists (select 'Y' from AS_LEADS_ALL xx where xx.INCUMBENT_PARTNER_PARTY_ID =  temp.party_id 
1275  )
1276 
1277  or exists (select 'Y' from AS_LEAD_COMPETITORS xx where xx.COMPETITOR_ID =  temp.party_id 
1278  )
1279 
1280  or exists (select 'Y' from HZ_PARTY_SITES
1281  xx where xx.PARTY_ID =  temp.party_id 
1282  and (nvl(STATUS, 'A') in ('A','I'))
1283  and exists 
1284  (select 'Y' from HZ_ORG_CONTACTS
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 
1294  (select 'Y' from HZ_ORG_CONTACTS
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 
1304  (select 'Y' from HZ_ORG_CONTACTS
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 
1314  (select 'Y' from HZ_ORG_CONTACTS
1315  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
1316  and nvl(STATUS, 'A') in ('A','I')
1317  and exists 
1318  (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1319 
1320  or exists (select 'Y' from AS_LEAD_CONTACTS_ALL xx where xx.CONTACT_PARTY_ID =  temp.party_id 
1321  )
1322 
1323  or exists (select 'Y' from AS_LEAD_CONTACTS_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1324  )
1325 
1326  or exists (select 'Y' from HZ_PARTY_SITES
1327  xx where xx.PARTY_ID =  temp.party_id 
1328  and (nvl(STATUS, 'A') in ('A','I'))
1329  and exists
1330 (select 'Y' from AS_LEAD_CONTACTS_ALL
1331  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1332 ))
1333 
1334  or exists (select 'Y' from AS_SALES_CREDITS xx where xx.PARTNER_CUSTOMER_ID =  temp.party_id 
1335  )
1336 
1337  or exists (select 'Y' from HZ_PARTY_SITES
1338  xx where xx.PARTY_ID =  temp.party_id 
1339  and (nvl(STATUS, 'A') in ('A','I'))
1340  and exists
1341 (select 'Y' from AS_SALES_CREDITS
1342  yy where yy.PARTNER_ADDRESS_ID=xx.PARTY_SITE_ID
1343 ))
1344 
1345  or exists (select 'Y' from AS_SALES_CREDITS_DENORM xx where xx.PARTNER_CUSTOMER_ID =  temp.party_id 
1346  )
1347 
1348  or exists (select 'Y' from HZ_PARTY_SITES
1349  xx where xx.PARTY_ID =  temp.party_id 
1350  and (nvl(STATUS, 'A') in ('A','I'))
1351  and exists
1352 (select 'Y' from AS_SALES_CREDITS_DENORM
1353  yy where yy.PARTNER_ADDRESS_ID=xx.PARTY_SITE_ID
1354 ))
1355 
1356  or exists (select 'Y' from AS_SALES_CREDITS_DENORM xx where xx.CUSTOMER_ID =  temp.party_id 
1357  )
1358 
1359  or exists (select 'Y' from HZ_PARTY_SITES
1360  xx where xx.PARTY_ID =  temp.party_id 
1361  and (nvl(STATUS, 'A') in ('A','I'))
1362  and exists
1363 (select 'Y' from AS_SALES_CREDITS_DENORM
1364  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1365 ))
1366 
1367  or exists (select 'Y' from HZ_CONTACT_POINTS
1368  xx where xx.OWNER_TABLE_ID =  temp.party_id 
1369  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
1370  and exists
1371 (select 'Y' from AS_LEAD_CONTACTS_ALL
1372  yy where yy.PHONE_ID=xx.CONTACT_POINT_ID
1373 ))
1374  or exists (select 'Y' from HZ_PARTY_SITES
1375  xx where xx.PARTY_ID =  temp.party_id 
1376  and (nvl(STATUS, 'A') in ('A','I'))
1377  and exists 
1378  (select 'Y' from HZ_CONTACT_POINTS
1379  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
1380  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
1381  and exists 
1382  (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.PHONE_ID = yy.CONTACT_POINT_ID )))
1383 
1384  or exists (select 'Y' from HZ_PARTY_SITES
1385  xx where xx.PARTY_ID =  temp.party_id 
1386  and (nvl(STATUS, 'A') in ('A','I'))
1387  and exists
1388 (select 'Y' from AS_CURRENT_ENVIRONMENT
1389  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1390 ))
1391 
1392  or exists (select 'Y' from HZ_PARTY_SITES
1393  xx where xx.PARTY_ID =  temp.party_id 
1394  and (nvl(STATUS, 'A') in ('A','I'))
1395  and exists 
1396  (select 'Y' from HZ_ORG_CONTACTS
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 
1406  (select 'Y' from HZ_ORG_CONTACTS
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 
1416  (select 'Y' from HZ_ORG_CONTACTS
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 
1426  (select 'Y' from HZ_ORG_CONTACTS
1427  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
1428  and nvl(STATUS, 'A') in ('A','I')
1429  and exists 
1430  (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1431 
1432  or exists (select 'Y' from HZ_PARTY_SITES
1433  xx where xx.PARTY_ID =  temp.party_id 
1434  and (nvl(STATUS, 'A') in ('A','I'))
1435  and exists
1436 (select 'Y' from AS_SALES_LEADS
1437  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1438 ))
1439 
1440  or exists (select 'Y' from AS_SALES_LEADS xx where xx.PRIMARY_CONTACT_PARTY_ID =  temp.party_id 
1441  )
1442 
1443  or exists (select 'Y' from AS_SALES_LEADS xx where xx.PRIMARY_CNT_PERSON_PARTY_ID =  temp.party_id 
1444  )
1445 
1446  or exists (select 'Y' from HZ_CONTACT_POINTS
1447  xx where xx.OWNER_TABLE_ID =  temp.party_id 
1448  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
1449  and exists
1450 (select 'Y' from AS_SALES_LEADS
1451  yy where yy.PRIMARY_CONTACT_PHONE_ID=xx.CONTACT_POINT_ID
1452 ))
1453  or exists (select 'Y' from HZ_PARTY_SITES
1454  xx where xx.PARTY_ID =  temp.party_id 
1455  and (nvl(STATUS, 'A') in ('A','I'))
1456  and exists 
1457  (select 'Y' from HZ_CONTACT_POINTS
1458  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
1459  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
1460  and exists 
1461  (select 'Y' from AS_SALES_LEADS zz where zz.PRIMARY_CONTACT_PHONE_ID = yy.CONTACT_POINT_ID )))
1462 
1463  or exists (select 'Y' from AS_AP_ACCOUNT_PLANS xx where xx.CUST_PARTY_ID =  temp.party_id 
1464  );
1465  else 
1466 delete from hz_purge_gt temp where 
1467 
1468 
1469  exists (select 'Y' from HZ_PARTY_SITES
1470  xx where xx.PARTY_ID =  temp.party_id 
1471  and (nvl(STATUS, 'A') in ('A','I'))
1472  and exists
1473 (select 'Y' from AS_SALES_LEAD_CONTACTS
1474  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1475 ))
1476 
1477  or exists (select 'Y' from HZ_CONTACT_POINTS
1478  xx where xx.OWNER_TABLE_ID =  temp.party_id 
1479  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
1480  and exists
1481 (select 'Y' from AS_SALES_LEAD_CONTACTS
1482  yy where yy.PHONE_ID=xx.CONTACT_POINT_ID
1483 ))
1484  or exists (select 'Y' from HZ_PARTY_SITES
1485  xx where xx.PARTY_ID =  temp.party_id 
1486  and (nvl(STATUS, 'A') in ('A','I'))
1487  and exists 
1488  (select 'Y' from HZ_CONTACT_POINTS
1489  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
1490  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
1491  and exists 
1492  (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.PHONE_ID = yy.CONTACT_POINT_ID )))
1493 
1494  or exists (select 'Y' from AS_SALES_LEAD_CONTACTS xx where xx.CONTACT_PARTY_ID =  temp.party_id 
1495  )
1496 
1497  or exists (select 'Y' from AS_ACCESSES_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1498  )
1499 
1500  or exists (select 'Y' from HZ_PARTY_SITES
1501  xx where xx.PARTY_ID =  temp.party_id 
1502  and (nvl(STATUS, 'A') in ('A','I'))
1503  and exists
1504 (select 'Y' from AS_ACCESSES_ALL
1505  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1506 ))
1507 
1508  or exists (select 'Y' from AS_ACCESSES_ALL xx where xx.PARTNER_CUSTOMER_ID =  temp.party_id 
1509  )
1510 
1511  or exists (select 'Y' from AS_ACCESSES_ALL xx where xx.PARTNER_CONT_PARTY_ID =  temp.party_id 
1512  )
1513 
1514  or exists (select 'Y' from AS_INTERESTS_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1515  )
1516 
1517  or exists (select 'Y' from HZ_PARTY_SITES
1518  xx where xx.PARTY_ID =  temp.party_id 
1519  and (nvl(STATUS, 'A') in ('A','I'))
1520  and exists
1521 (select 'Y' from AS_INTERESTS_ALL
1522  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1523 ))
1524 
1525  or exists (select 'Y' from HZ_PARTY_SITES
1526  xx where xx.PARTY_ID =  temp.party_id 
1527  and (nvl(STATUS, 'A') in ('A','I'))
1528  and exists 
1529  (select 'Y' from HZ_ORG_CONTACTS
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 
1539  (select 'Y' from HZ_ORG_CONTACTS
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 
1549  (select 'Y' from HZ_ORG_CONTACTS
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 
1559  (select 'Y' from HZ_ORG_CONTACTS
1560  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
1561  and nvl(STATUS, 'A') in ('A','I')
1562  and exists 
1563  (select 'Y' from AS_INTERESTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1564 
1565  or exists (select 'Y' from HZ_PARTY_SITES
1566  xx where xx.PARTY_ID =  temp.party_id 
1567  and (nvl(STATUS, 'A') in ('A','I'))
1568  and exists
1569 (select 'Y' from AS_ACCESSES_ALL
1570  yy where yy.PARTNER_ADDRESS_ID=xx.PARTY_SITE_ID
1571 ))
1572 
1573  or exists (select 'Y' from AS_SALES_LEADS xx where xx.CUSTOMER_ID =  temp.party_id 
1574  )
1575 
1576  or exists (select 'Y' from AS_SALES_LEAD_CONTACTS xx where xx.CUSTOMER_ID =  temp.party_id 
1577  )
1578 
1579  or exists (select 'Y' from AS_LEADS_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1580  )
1581 
1582  or exists (select 'Y' from HZ_PARTY_SITES
1583  xx where xx.PARTY_ID =  temp.party_id 
1584  and (nvl(STATUS, 'A') in ('A','I'))
1585  and exists
1586 (select 'Y' from AS_LEADS_ALL
1587  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1588 ))
1589 
1590  or exists (select 'Y' from AS_LEADS_ALL xx where xx.CLOSE_COMPETITOR_ID =  temp.party_id 
1591  )
1592 
1593  or exists (select 'Y' from AS_LEADS_ALL xx where xx.INCUMBENT_PARTNER_PARTY_ID =  temp.party_id 
1594  )
1595 
1596  or exists (select 'Y' from AS_LEAD_COMPETITORS xx where xx.COMPETITOR_ID =  temp.party_id 
1597  )
1598 
1599  or exists (select 'Y' from HZ_PARTY_SITES
1600  xx where xx.PARTY_ID =  temp.party_id 
1601  and (nvl(STATUS, 'A') in ('A','I'))
1602  and exists 
1603  (select 'Y' from HZ_ORG_CONTACTS
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 
1613  (select 'Y' from HZ_ORG_CONTACTS
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 
1623  (select 'Y' from HZ_ORG_CONTACTS
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 
1633  (select 'Y' from HZ_ORG_CONTACTS
1634  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
1635  and nvl(STATUS, 'A') in ('A','I')
1636  and exists 
1637  (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1638 
1639  or exists (select 'Y' from AS_LEAD_CONTACTS_ALL xx where xx.CONTACT_PARTY_ID =  temp.party_id 
1640  )
1641 
1642  or exists (select 'Y' from AS_LEAD_CONTACTS_ALL xx where xx.CUSTOMER_ID =  temp.party_id 
1643  )
1644 
1645  or exists (select 'Y' from HZ_PARTY_SITES
1646  xx where xx.PARTY_ID =  temp.party_id 
1647  and (nvl(STATUS, 'A') in ('A','I'))
1648  and exists
1649 (select 'Y' from AS_LEAD_CONTACTS_ALL
1650  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1651 ))
1652 
1653  or exists (select 'Y' from AS_SALES_CREDITS xx where xx.PARTNER_CUSTOMER_ID =  temp.party_id 
1654  )
1655 
1656  or exists (select 'Y' from HZ_PARTY_SITES
1657  xx where xx.PARTY_ID =  temp.party_id 
1658  and (nvl(STATUS, 'A') in ('A','I'))
1659  and exists
1660 (select 'Y' from AS_SALES_CREDITS
1661  yy where yy.PARTNER_ADDRESS_ID=xx.PARTY_SITE_ID
1662 ))
1663 
1664  or exists (select 'Y' from AS_SALES_CREDITS_DENORM xx where xx.PARTNER_CUSTOMER_ID =  temp.party_id 
1665  )
1666 
1667  or exists (select 'Y' from HZ_PARTY_SITES
1668  xx where xx.PARTY_ID =  temp.party_id 
1669  and (nvl(STATUS, 'A') in ('A','I'))
1670  and exists
1671 (select 'Y' from AS_SALES_CREDITS_DENORM
1672  yy where yy.PARTNER_ADDRESS_ID=xx.PARTY_SITE_ID
1673 ))
1674 
1675  or exists (select 'Y' from AS_SALES_CREDITS_DENORM xx where xx.CUSTOMER_ID =  temp.party_id 
1676  )
1677 
1678  or exists (select 'Y' from HZ_PARTY_SITES
1679  xx where xx.PARTY_ID =  temp.party_id 
1680  and (nvl(STATUS, 'A') in ('A','I'))
1681  and exists
1682 (select 'Y' from AS_SALES_CREDITS_DENORM
1683  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1684 ))
1685 
1686  or exists (select 'Y' from HZ_CONTACT_POINTS
1687  xx where xx.OWNER_TABLE_ID =  temp.party_id 
1688  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
1689  and exists
1690 (select 'Y' from AS_LEAD_CONTACTS_ALL
1691  yy where yy.PHONE_ID=xx.CONTACT_POINT_ID
1692 ))
1693  or exists (select 'Y' from HZ_PARTY_SITES
1694  xx where xx.PARTY_ID =  temp.party_id 
1695  and (nvl(STATUS, 'A') in ('A','I'))
1696  and exists 
1697  (select 'Y' from HZ_CONTACT_POINTS
1698  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
1699  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
1700  and exists 
1701  (select 'Y' from AS_LEAD_CONTACTS_ALL zz where zz.PHONE_ID = yy.CONTACT_POINT_ID )))
1702 
1703  or exists (select 'Y' from HZ_PARTY_SITES
1704  xx where xx.PARTY_ID =  temp.party_id 
1705  and (nvl(STATUS, 'A') in ('A','I'))
1706  and exists
1707 (select 'Y' from AS_CURRENT_ENVIRONMENT
1708  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1709 ))
1710 
1711  or exists (select 'Y' from HZ_PARTY_SITES
1712  xx where xx.PARTY_ID =  temp.party_id 
1713  and (nvl(STATUS, 'A') in ('A','I'))
1714  and exists 
1715  (select 'Y' from HZ_ORG_CONTACTS
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 
1725  (select 'Y' from HZ_ORG_CONTACTS
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 
1735  (select 'Y' from HZ_ORG_CONTACTS
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 
1745  (select 'Y' from HZ_ORG_CONTACTS
1746  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
1747  and nvl(STATUS, 'A') in ('A','I')
1748  and exists 
1749  (select 'Y' from AS_SALES_LEAD_CONTACTS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID )))
1750 
1751  or exists (select 'Y' from HZ_PARTY_SITES
1752  xx where xx.PARTY_ID =  temp.party_id 
1753  and (nvl(STATUS, 'A') in ('A','I'))
1754  and exists
1755 (select 'Y' from AS_SALES_LEADS
1756  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
1757 ))
1758 
1759  or exists (select 'Y' from AS_SALES_LEADS xx where xx.PRIMARY_CONTACT_PARTY_ID =  temp.party_id 
1760  )
1761 
1762  or exists (select 'Y' from AS_SALES_LEADS xx where xx.PRIMARY_CNT_PERSON_PARTY_ID =  temp.party_id 
1763  )
1764 
1765  or exists (select 'Y' from HZ_CONTACT_POINTS
1766  xx where xx.OWNER_TABLE_ID =  temp.party_id 
1767  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
1768  and exists
1769 (select 'Y' from AS_SALES_LEADS
1770  yy where yy.PRIMARY_CONTACT_PHONE_ID=xx.CONTACT_POINT_ID
1771 ))
1772  or exists (select 'Y' from HZ_PARTY_SITES
1773  xx where xx.PARTY_ID =  temp.party_id 
1774  and (nvl(STATUS, 'A') in ('A','I'))
1775  and exists 
1776  (select 'Y' from HZ_CONTACT_POINTS
1777  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
1778  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
1779  and exists 
1780  (select 'Y' from AS_SALES_LEADS zz where zz.PRIMARY_CONTACT_PHONE_ID = yy.CONTACT_POINT_ID )))
1781 
1782  or exists (select 'Y' from AS_AP_ACCOUNT_PLANS xx where xx.CUST_PARTY_ID =  temp.party_id 
1783  );
1784 end if;
1785 
1786 
1787 --delete and insert records into hz_purge_gt for an application
1788 appid:=206;
1789  if(regid_proc = true) then 
1790 insert into hz_application_trans_gt(app_id,party_id) select 206, temp.party_id from hz_purge_gt temp where 
1791 
1792 
1793  exists (select 'Y' from LNS_LOAN_HEADERS_ALL xx where xx.PRIMARY_BORROWER_ID =  temp.party_id 
1794  )
1795 
1796  or exists (select 'Y' from LNS_PARTICIPANTS xx where xx.HZ_PARTY_ID =  temp.party_id 
1797  );
1798  else 
1799 delete from hz_purge_gt temp where 
1800 
1801 
1802  exists (select 'Y' from LNS_LOAN_HEADERS_ALL xx where xx.PRIMARY_BORROWER_ID =  temp.party_id 
1803  )
1804 
1805  or exists (select 'Y' from LNS_PARTICIPANTS xx where xx.HZ_PARTY_ID =  temp.party_id 
1806  );
1807 end if;
1808 
1809 
1810 --delete and insert records into hz_purge_gt for an application
1811 appid:=275;
1812  if(regid_proc = true) then 
1813 insert into hz_application_trans_gt(app_id,party_id) select 275, temp.party_id from hz_purge_gt temp where 
1814 
1815 
1816  exists (select 'Y' from PA_CI_ACTIONS xx where xx.ASSIGNED_TO =  temp.party_id 
1817  )
1818 
1819  or exists (select 'Y' from PA_CONTROL_ITEMS xx where xx.OWNER_ID =  temp.party_id 
1820  )
1821 
1822  or exists (select 'Y' from PA_PERCENT_COMPLETES xx where xx.PUBLISHED_BY_PARTY_ID =  temp.party_id 
1823  )
1824 
1825  or exists (select 'Y' from PA_PROJECT_REQUESTS xx where xx.CUST_PARTY_ID =  temp.party_id 
1826  )
1827 
1828  or exists (select 'Y' from PA_PROJECT_SETS_B xx where xx.PARTY_ID =  temp.party_id 
1829  )
1830 
1831  or exists (select 'Y' from PA_RESOURCE_TXN_ATTRIBUTES xx where xx.PARTY_ID =  temp.party_id 
1832  )
1833 
1834  or exists (select 'Y' from PA_CI_IMPACTS xx where xx.IMPLEMENTED_BY =  temp.party_id 
1835  )
1836 
1837  or exists (select 'Y' from PA_CONTROL_ITEMS xx where xx.LAST_MODIFIED_BY_ID =  temp.party_id 
1838  )
1839 
1840  or exists (select 'Y' from PA_CONTROL_ITEMS xx where xx.CLOSED_BY_ID =  temp.party_id 
1841  );
1842  else 
1843 delete from hz_purge_gt temp where 
1844 
1845 
1846  exists (select 'Y' from PA_CI_ACTIONS xx where xx.ASSIGNED_TO =  temp.party_id 
1847  )
1848 
1849  or exists (select 'Y' from PA_CONTROL_ITEMS xx where xx.OWNER_ID =  temp.party_id 
1850  )
1851 
1852  or exists (select 'Y' from PA_PERCENT_COMPLETES xx where xx.PUBLISHED_BY_PARTY_ID =  temp.party_id 
1853  )
1854 
1855  or exists (select 'Y' from PA_PROJECT_REQUESTS xx where xx.CUST_PARTY_ID =  temp.party_id 
1856  )
1857 
1858  or exists (select 'Y' from PA_PROJECT_SETS_B xx where xx.PARTY_ID =  temp.party_id 
1859  )
1860 
1861  or exists (select 'Y' from PA_RESOURCE_TXN_ATTRIBUTES xx where xx.PARTY_ID =  temp.party_id 
1862  )
1863 
1864  or exists (select 'Y' from PA_CI_IMPACTS xx where xx.IMPLEMENTED_BY =  temp.party_id 
1865  )
1866 
1867  or exists (select 'Y' from PA_CONTROL_ITEMS xx where xx.LAST_MODIFIED_BY_ID =  temp.party_id 
1868  )
1869 
1870  or exists (select 'Y' from PA_CONTROL_ITEMS xx where xx.CLOSED_BY_ID =  temp.party_id 
1871  );
1872 end if;
1873 
1874 
1875 --delete and insert records into hz_purge_gt for an application
1876 appid:=451;
1877  if(regid_proc = true) then 
1878 insert into hz_application_trans_gt(app_id,party_id) select 451, temp.party_id from hz_purge_gt temp where 
1879 
1880 
1881  exists (select 'Y' from OPI_DBI_COGS_F xx where xx.CUSTOMER_ID =  temp.party_id 
1882  );
1883  else 
1884 delete from hz_purge_gt temp where 
1885 
1886 
1887  exists (select 'Y' from OPI_DBI_COGS_F xx where xx.CUSTOMER_ID =  temp.party_id 
1888  );
1889 end if;
1890 
1891 
1892 --delete and insert records into hz_purge_gt for an application
1893 appid:=396;
1894  if(regid_proc = true) then 
1895 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp where 
1896 
1897 
1898  exists (select 'Y' from PON_TE_RECIPIENTS xx where xx.TO_ID =  temp.party_id 
1899  )
1900 
1901  or exists (select 'Y' from PON_BIDDING_PARTIES xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1902  )
1903 
1904  or exists (select 'Y' from PON_BID_ITEM_PRICES xx where xx.BID_TRADING_PARTNER_ID =  temp.party_id 
1905  )
1906 
1907  or exists (select 'Y' from PON_AUCTION_HEADERS_ALL xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1908  )
1909 
1910  or exists (select 'Y' from PON_AUCTION_HEADERS_ALL xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1911  )
1912 
1913  or exists (select 'Y' from PON_AUCTION_EVENTS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1914  )
1915 
1916  or exists (select 'Y' from PON_BIDDERS_LISTS xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1917  )
1918 
1919  or exists (select 'Y' from PON_BIDDERS_LISTS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1920  )
1921 
1922  or exists (select 'Y' from PON_ATTRIBUTE_LISTS xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1923  )
1924 
1925  or exists (select 'Y' from PON_ATTRIBUTE_LISTS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1926  )
1927 
1928  or exists (select 'Y' from PON_BID_HEADERS xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1929  )
1930 
1931  or exists (select 'Y' from PON_BID_HEADERS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1932  );
1933  else 
1934 delete from hz_purge_gt temp where 
1935 
1936 
1937  exists (select 'Y' from PON_TE_RECIPIENTS xx where xx.TO_ID =  temp.party_id 
1938  )
1939 
1940  or exists (select 'Y' from PON_BIDDING_PARTIES xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1941  )
1942 
1943  or exists (select 'Y' from PON_BID_ITEM_PRICES xx where xx.BID_TRADING_PARTNER_ID =  temp.party_id 
1944  )
1945 
1946  or exists (select 'Y' from PON_AUCTION_HEADERS_ALL xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1947  )
1948 
1949  or exists (select 'Y' from PON_AUCTION_HEADERS_ALL xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1950  )
1951 
1952  or exists (select 'Y' from PON_AUCTION_EVENTS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1953  )
1954 
1955  or exists (select 'Y' from PON_BIDDERS_LISTS xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1956  )
1957 
1958  or exists (select 'Y' from PON_BIDDERS_LISTS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1959  )
1960 
1961  or exists (select 'Y' from PON_ATTRIBUTE_LISTS xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1962  )
1963 
1964  or exists (select 'Y' from PON_ATTRIBUTE_LISTS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1965  )
1966 
1967  or exists (select 'Y' from PON_BID_HEADERS xx where xx.TRADING_PARTNER_CONTACT_ID =  temp.party_id 
1968  )
1969 
1970  or exists (select 'Y' from PON_BID_HEADERS xx where xx.TRADING_PARTNER_ID =  temp.party_id 
1971  );
1972 end if;
1973 
1974 
1975 --delete and insert records into hz_purge_gt for an application
1976 appid:=540;
1977  if(regid_proc = true) then 
1978 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp where 
1979 
1980 
1981  exists (select 'Y' from HZ_PARTY_SITES
1982  xx where xx.PARTY_ID =  temp.party_id 
1983  and (nvl(STATUS, 'A') in ('A','I'))
1984  and exists 
1985  (select 'Y' from HZ_PARTY_SITE_USES
1986  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
1987  and nvl(STATUS, 'A') in ('A','I')
1988  and exists 
1989  (select 'Y' from OKL_RELOCATE_ASSETS_B zz where zz.IST_ID = yy.PARTY_SITE_USE_ID )))
1990 
1991  or exists (select 'Y' from HZ_PARTY_SITES
1992  xx where xx.PARTY_ID =  temp.party_id 
1993  and (nvl(STATUS, 'A') in ('A','I'))
1994  and exists 
1995  (select 'Y' from HZ_PARTY_SITE_USES
1996  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
1997  and nvl(STATUS, 'A') in ('A','I')
1998  and exists 
1999  (select 'Y' from OKL_RELOCATE_ASSETS_B zz where zz.IST_ID = yy.PARTY_SITE_USE_ID )))
2000 
2001  or exists (select 'Y' from OKL_TRX_AR_INVOICES_B xx where xx.IBT_ID =  temp.party_id 
2002  )
2003 
2004  or exists (select 'Y' from OKL_CNSLD_AR_HDRS_B xx where xx.IBT_ID =  temp.party_id 
2005  )
2006 
2007  or exists (select 'Y' from OKL_TXL_RCPT_APPS_B xx where xx.ILE_ID =  temp.party_id 
2008  )
2009 
2010  or exists (select 'Y' from HZ_CONTACT_POINTS
2011  xx where xx.OWNER_TABLE_ID =  temp.party_id 
2012  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
2013  and exists
2014 (select 'Y' from OKL_RELOCATE_ASSETS_B
2015  yy where yy.PAC_ID=xx.CONTACT_POINT_ID
2016 ))
2017  or exists (select 'Y' from HZ_PARTY_SITES
2018  xx where xx.PARTY_ID =  temp.party_id 
2019  and (nvl(STATUS, 'A') in ('A','I'))
2020  and exists 
2021  (select 'Y' from HZ_CONTACT_POINTS
2022  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
2023  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
2024  and exists 
2025  (select 'Y' from OKL_RELOCATE_ASSETS_B zz where zz.PAC_ID = yy.CONTACT_POINT_ID )));
2026  else 
2027 delete from hz_purge_gt temp where 
2028 
2029 
2030  exists (select 'Y' from HZ_PARTY_SITES
2031  xx where xx.PARTY_ID =  temp.party_id 
2032  and (nvl(STATUS, 'A') in ('A','I'))
2033  and exists 
2034  (select 'Y' from HZ_PARTY_SITE_USES
2035  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
2036  and nvl(STATUS, 'A') in ('A','I')
2037  and exists 
2038  (select 'Y' from OKL_RELOCATE_ASSETS_B zz where zz.IST_ID = yy.PARTY_SITE_USE_ID )))
2039 
2040  or exists (select 'Y' from HZ_PARTY_SITES
2041  xx where xx.PARTY_ID =  temp.party_id 
2042  and (nvl(STATUS, 'A') in ('A','I'))
2043  and exists 
2044  (select 'Y' from HZ_PARTY_SITE_USES
2045  yy where yy.PARTY_SITE_ID=xx.PARTY_SITE_ID 
2046  and nvl(STATUS, 'A') in ('A','I')
2047  and exists 
2048  (select 'Y' from OKL_RELOCATE_ASSETS_B zz where zz.IST_ID = yy.PARTY_SITE_USE_ID )))
2049 
2050  or exists (select 'Y' from OKL_TRX_AR_INVOICES_B xx where xx.IBT_ID =  temp.party_id 
2051  )
2052 
2053  or exists (select 'Y' from OKL_CNSLD_AR_HDRS_B xx where xx.IBT_ID =  temp.party_id 
2054  )
2055 
2056  or exists (select 'Y' from OKL_TXL_RCPT_APPS_B xx where xx.ILE_ID =  temp.party_id 
2057  )
2058 
2059  or exists (select 'Y' from HZ_CONTACT_POINTS
2060  xx where xx.OWNER_TABLE_ID =  temp.party_id 
2061  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
2062  and exists
2063 (select 'Y' from OKL_RELOCATE_ASSETS_B
2064  yy where yy.PAC_ID=xx.CONTACT_POINT_ID
2065 ))
2066  or exists (select 'Y' from HZ_PARTY_SITES
2067  xx where xx.PARTY_ID =  temp.party_id 
2068  and (nvl(STATUS, 'A') in ('A','I'))
2069  and exists 
2070  (select 'Y' from HZ_CONTACT_POINTS
2071  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
2072  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
2073  and exists 
2074  (select 'Y' from OKL_RELOCATE_ASSETS_B zz where zz.PAC_ID = yy.CONTACT_POINT_ID )));
2075 end if;
2076 
2077 
2078 --delete and insert records into hz_purge_gt for an application
2079 appid:=530;
2080  if(regid_proc = true) then 
2081 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp where 
2082 
2083 
2084  exists (select 'Y' from AMS_PARTY_SOURCES xx where xx.PARTY_ID =  temp.party_id 
2085  )
2086 
2087  or exists (select 'Y' from AMS_ACT_PARTNERS xx where xx.PARTNER_ID =  temp.party_id 
2088  )
2089 
2090  or exists (select 'Y' from AMS_ACT_PARTNERS xx where xx.PREFERRED_VAD_ID =  temp.party_id 
2091  )
2092 
2093  or exists (select 'Y' from AMS_ACT_PARTNERS xx where xx.PRIMARY_CONTACT_ID =  temp.party_id 
2094  )
2095 
2096  or exists (select 'Y' from AMS_EVENT_REGISTRATIONS xx where xx.REGISTRANT_PARTY_ID =  temp.party_id 
2097  )
2098 
2099  or exists (select 'Y' from AMS_EVENT_REGISTRATIONS xx where xx.ATTENDANT_CONTACT_ID =  temp.party_id 
2100  )
2101 
2102  or exists (select 'Y' from AMS_CHANNELS_B xx where xx.PARTY_ID =  temp.party_id 
2103  )
2104 
2105  or exists (select 'Y' from AMS_IBA_POSTINGS_B xx where xx.CUSTOMER_PARTY_ID =  temp.party_id 
2106  )
2107 
2108  or exists (select 'Y' from AMS_IBA_POSTINGS_B xx where xx.AFFILIATE_PARTY_ID =  temp.party_id 
2109  )
2110 
2111  or exists (select 'Y' from AMS_COMPETITOR_PRODUCTS_B xx where xx.COMPETITOR_PARTY_ID =  temp.party_id 
2112  )
2113 
2114  or exists (select 'Y' from AMS_VENUES_B xx where xx.PARTY_ID =  temp.party_id 
2115  and (OBJECT_TYPE='VENU'))
2116 
2117  or exists (select 'Y' from AMS_IMP_SOURCE_LINES xx where xx.PARTY_ID =  temp.party_id 
2118  )
2119 
2120  or exists (select 'Y' from AMS_LIST_ENTRIES xx where xx.PARTY_ID =  temp.party_id 
2121  )
2122 
2123  or exists (select 'Y' from AMS_LIST_ENTRIES xx where xx.PARENT_PARTY_ID =  temp.party_id 
2124  )
2125 
2126  or exists (select 'Y' from AMS_ACT_RESOURCES xx where xx.RESOURCE_ID =  temp.party_id 
2127  )
2128 
2129  or exists (select 'Y' from AMS_TCOP_CONTACT_SUMMARY xx where xx.PARTY_ID =  temp.party_id 
2130  );
2131  else 
2132 delete from hz_purge_gt temp where 
2133 
2134 
2135  exists (select 'Y' from AMS_PARTY_SOURCES xx where xx.PARTY_ID =  temp.party_id 
2136  )
2137 
2138  or exists (select 'Y' from AMS_ACT_PARTNERS xx where xx.PARTNER_ID =  temp.party_id 
2139  )
2140 
2141  or exists (select 'Y' from AMS_ACT_PARTNERS xx where xx.PREFERRED_VAD_ID =  temp.party_id 
2142  )
2143 
2144  or exists (select 'Y' from AMS_ACT_PARTNERS xx where xx.PRIMARY_CONTACT_ID =  temp.party_id 
2145  )
2146 
2147  or exists (select 'Y' from AMS_EVENT_REGISTRATIONS xx where xx.REGISTRANT_PARTY_ID =  temp.party_id 
2148  )
2149 
2150  or exists (select 'Y' from AMS_EVENT_REGISTRATIONS xx where xx.ATTENDANT_CONTACT_ID =  temp.party_id 
2151  )
2152 
2153  or exists (select 'Y' from AMS_CHANNELS_B xx where xx.PARTY_ID =  temp.party_id 
2154  )
2155 
2156  or exists (select 'Y' from AMS_IBA_POSTINGS_B xx where xx.CUSTOMER_PARTY_ID =  temp.party_id 
2157  )
2158 
2159  or exists (select 'Y' from AMS_IBA_POSTINGS_B xx where xx.AFFILIATE_PARTY_ID =  temp.party_id 
2160  )
2161 
2162  or exists (select 'Y' from AMS_COMPETITOR_PRODUCTS_B xx where xx.COMPETITOR_PARTY_ID =  temp.party_id 
2163  )
2164 
2165  or exists (select 'Y' from AMS_VENUES_B xx where xx.PARTY_ID =  temp.party_id 
2166  and (OBJECT_TYPE='VENU'))
2167 
2168  or exists (select 'Y' from AMS_IMP_SOURCE_LINES xx where xx.PARTY_ID =  temp.party_id 
2169  )
2170 
2171  or exists (select 'Y' from AMS_LIST_ENTRIES xx where xx.PARTY_ID =  temp.party_id 
2172  )
2173 
2174  or exists (select 'Y' from AMS_LIST_ENTRIES xx where xx.PARENT_PARTY_ID =  temp.party_id 
2175  )
2176 
2177  or exists (select 'Y' from AMS_ACT_RESOURCES xx where xx.RESOURCE_ID =  temp.party_id 
2178  )
2179 
2180  or exists (select 'Y' from AMS_TCOP_CONTACT_SUMMARY xx where xx.PARTY_ID =  temp.party_id 
2181  );
2182 end if;
2183 
2184 
2185 --delete and insert records into hz_purge_gt for an application
2186 appid:=511;
2187  if(regid_proc = true) then 
2188 insert into hz_application_trans_gt(app_id,party_id) select 511, temp.party_id from hz_purge_gt temp where 
2189 
2190 
2191  exists (select 'Y' from CSC_CUSTOMERS xx where xx.PARTY_ID =  temp.party_id 
2192  )
2193 
2194  or exists (select 'Y' from CSC_CUSTOMIZED_PLANS xx where xx.PARTY_ID =  temp.party_id 
2195  );
2196  else 
2197 delete from hz_purge_gt temp where 
2198 
2199 
2200  exists (select 'Y' from CSC_CUSTOMERS xx where xx.PARTY_ID =  temp.party_id 
2201  )
2202 
2203  or exists (select 'Y' from CSC_CUSTOMIZED_PLANS xx where xx.PARTY_ID =  temp.party_id 
2204  );
2205 end if;
2206 
2207 
2208 --delete and insert records into hz_purge_gt for an application
2209 appid:=454;
2210  if(regid_proc = true) then 
2211 insert into hz_application_trans_gt(app_id,party_id) select 454, temp.party_id from hz_purge_gt temp where 
2212 
2213 
2214  exists (select 'Y' from ISC_BOOK_SUM2_PDUE_F xx where xx.CUSTOMER_ID =  temp.party_id 
2215  )
2216 
2217  or exists (select 'Y' from ISC_BOOK_SUM2_PDUE2_F xx where xx.CUSTOMER_ID =  temp.party_id 
2218  )
2219 
2220  or exists (select 'Y' from ISC_BOOK_SUM2_BKORD_F xx where xx.CUSTOMER_ID =  temp.party_id 
2221  )
2222 
2223  or exists (select 'Y' from ISC_BOOK_SUM2_F xx where xx.CUSTOMER_ID =  temp.party_id 
2224  )
2225 
2226  or exists (select 'Y' from HZ_PARTY_SITES
2227  xx where xx.PARTY_ID =  temp.party_id 
2228  and (nvl(STATUS, 'A') in ('A','I'))
2229  and exists
2230 (select 'Y' from ISC_FS_TASKS_F
2231  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
2232 ))
2233 
2234  or exists (select 'Y' from ISC_FS_TASKS_F xx where xx.CUSTOMER_ID =  temp.party_id 
2235  );
2236  else 
2237 delete from hz_purge_gt temp where 
2238 
2239 
2240  exists (select 'Y' from ISC_BOOK_SUM2_PDUE_F xx where xx.CUSTOMER_ID =  temp.party_id 
2241  )
2242 
2243  or exists (select 'Y' from ISC_BOOK_SUM2_PDUE2_F xx where xx.CUSTOMER_ID =  temp.party_id 
2244  )
2245 
2246  or exists (select 'Y' from ISC_BOOK_SUM2_BKORD_F xx where xx.CUSTOMER_ID =  temp.party_id 
2247  )
2248 
2249  or exists (select 'Y' from ISC_BOOK_SUM2_F xx where xx.CUSTOMER_ID =  temp.party_id 
2250  )
2251 
2252  or exists (select 'Y' from HZ_PARTY_SITES
2253  xx where xx.PARTY_ID =  temp.party_id 
2254  and (nvl(STATUS, 'A') in ('A','I'))
2255  and exists
2256 (select 'Y' from ISC_FS_TASKS_F
2257  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
2258 ))
2259 
2260  or exists (select 'Y' from ISC_FS_TASKS_F xx where xx.CUSTOMER_ID =  temp.party_id 
2261  );
2262 end if;
2263 
2264 
2265 --delete and insert records into hz_purge_gt for an application
2266 appid:=690;
2267  if(regid_proc = true) then 
2268 insert into hz_application_trans_gt(app_id,party_id) select 690, temp.party_id from hz_purge_gt temp where 
2269 
2270 
2271  exists (select 'Y' from JTF_TASKS_B xx where xx.CUSTOMER_ID =  temp.party_id 
2272  )
2273 
2274  or exists (select 'Y' from JTF_TASKS_B xx where xx.SOURCE_OBJECT_ID =  temp.party_id 
2275  and (SOURCE_OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2276 
2277  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.NEW_CUSTOMER_ID =  temp.party_id 
2278  )
2279 
2280  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.OLD_CUSTOMER_ID =  temp.party_id 
2281  )
2282 
2283  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.NEW_SOURCE_OBJECT_ID =  temp.party_id 
2284  and (NEW_SOURCE_OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2285 
2286  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.OLD_SOURCE_OBJECT_ID =  temp.party_id 
2287  and (OLD_SOURCE_OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2288 
2289  or exists (select 'Y' from JTF_TASK_CONTACTS xx where xx.CONTACT_ID =  temp.party_id 
2290  and (CONTACT_TYPE_CODE = 'CUST'))
2291 
2292  or exists (select 'Y' from HZ_PARTY_SITES
2293  xx where xx.PARTY_ID =  temp.party_id 
2294  and (nvl(STATUS, 'A') in ('A','I'))
2295  and exists
2296 (select 'Y' from JTF_TASK_REFERENCES_B
2297  yy where yy.OBJECT_ID=xx.PARTY_SITE_ID
2298  and object_type_code in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTY_SITES' and rtrim(ltrim(upper(select_id))) = 'PARTY_SITE_ID')))
2299 
2300  or exists (select 'Y' from JTF_TASK_REFERENCES_B xx where xx.OBJECT_ID =  temp.party_id 
2301  and (OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2302 
2303  or exists (select 'Y' from HZ_PARTY_SITES
2304  xx where xx.PARTY_ID =  temp.party_id 
2305  and (nvl(STATUS, 'A') in ('A','I'))
2306  and exists
2307 (select 'Y' from JTF_TASKS_B
2308  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
2309 ))
2310 
2311  or exists (select 'Y' from HZ_PARTY_SITES
2312  xx where xx.PARTY_ID =  temp.party_id 
2313  and (nvl(STATUS, 'A') in ('A','I'))
2314  and exists
2315 (select 'Y' from JTF_TASK_AUDITS_B
2316  yy where yy.NEW_ADDRESS_ID=xx.PARTY_SITE_ID
2317 ))
2318 
2319  or exists (select 'Y' from HZ_PARTY_SITES
2320  xx where xx.PARTY_ID =  temp.party_id 
2321  and (nvl(STATUS, 'A') in ('A','I'))
2322  and exists
2323 (select 'Y' from JTF_TASK_AUDITS_B
2324  yy where yy.OLD_ADDRESS_ID=xx.PARTY_SITE_ID
2325 ))
2326 
2327  or exists (select 'Y' from HZ_CONTACT_POINTS
2328  xx where xx.OWNER_TABLE_ID =  temp.party_id 
2329  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
2330  and exists
2331 (select 'Y' from JTF_TASK_PHONES
2332  yy where yy.PHONE_ID=xx.CONTACT_POINT_ID
2333 ))
2334  or exists (select 'Y' from HZ_PARTY_SITES
2335  xx where xx.PARTY_ID =  temp.party_id 
2336  and (nvl(STATUS, 'A') in ('A','I'))
2337  and exists 
2338  (select 'Y' from HZ_CONTACT_POINTS
2339  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
2340  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
2341  and exists 
2342  (select 'Y' from JTF_TASK_PHONES zz where zz.PHONE_ID = yy.CONTACT_POINT_ID )))
2343 
2344  or exists (select 'Y' from HZ_PARTY_SITES
2345  xx where xx.PARTY_ID =  temp.party_id 
2346  and (nvl(STATUS, 'A') in ('A','I'))
2347  and exists 
2348  (select 'Y' from HZ_ORG_CONTACTS
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 
2358  (select 'Y' from HZ_ORG_CONTACTS
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 
2368  (select 'Y' from HZ_ORG_CONTACTS
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 
2378  (select 'Y' from HZ_ORG_CONTACTS
2379  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
2380  and nvl(STATUS, 'A') in ('A','I')
2381  and exists 
2382  (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2383 
2384  or exists (select 'Y' from HZ_PARTY_SITES
2385  xx where xx.PARTY_ID =  temp.party_id 
2386  and (nvl(STATUS, 'A') in ('A','I'))
2387  and exists
2388 (select 'Y' from JTF_NOTES_B
2389  yy where yy.SOURCE_OBJECT_ID=xx.PARTY_SITE_ID
2390  and source_object_code  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTY_SITES')))
2391 
2392  or exists (select 'Y' from HZ_PARTY_SITES
2393  xx where xx.PARTY_ID =  temp.party_id 
2394  and (nvl(STATUS, 'A') in ('A','I'))
2395  and exists
2396 (select 'Y' from JTF_NOTE_CONTEXTS
2397  yy where yy.NOTE_CONTEXT_TYPE_ID=xx.PARTY_SITE_ID
2398  and NOTE_CONTEXT_TYPE  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTY_SITES')))
2399 
2400  or exists (select 'Y' from JTF_NOTES_B xx where xx.SOURCE_OBJECT_ID =  temp.party_id 
2401  and (source_object_code  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTIES' )))
2402 
2403  or exists (select 'Y' from JTF_NOTE_CONTEXTS xx where xx.NOTE_CONTEXT_TYPE_ID =  temp.party_id 
2404  and (NOTE_CONTEXT_TYPE  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTIES')))
2405 
2406  or exists (select 'Y' from JTF_IH_INTERACTIONS xx where xx.PARTY_ID =  temp.party_id 
2407  )
2408 
2409  or exists (select 'Y' from JTF_RS_RESOURCE_EXTNS xx where xx.SOURCE_ID =  temp.party_id 
2410  and (category IN ( 'PARTY' , 'PARTNER')))
2411 
2412  or exists (select 'Y' from HZ_PARTY_SITES
2413  xx where xx.PARTY_ID =  temp.party_id 
2414  and (nvl(STATUS, 'A') in ('A','I'))
2415  and exists
2416 (select 'Y' from JTF_RS_RESOURCE_EXTNS
2417  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
2418  and category  =   'PARTNER'))
2419 
2420  or exists (select 'Y' from JTF_UM_APPROVERS xx where xx.ORG_PARTY_ID =  temp.party_id 
2421  and (ROWNUM < 2))
2422 
2423  or exists (select 'Y' from HZ_PARTY_SITES
2424  xx where xx.PARTY_ID =  temp.party_id 
2425  and (nvl(STATUS, 'A') in ('A','I'))
2426  and exists
2427 (select 'Y' from JTF_TERR_VALUES_ALL
2428  yy where yy.LOW_VALUE_CHAR_ID=xx.PARTY_SITE_ID
2429  and TERR_QUAL_ID in ( select TERR_QUAL_ID from JTF_TERR_QUAL_ALL where QUAL_USG_ID in (-1511, -1435, -1078, -1064, -1063, -1037, -1014, -1002,  -1001))))
2430 
2431  or exists (select 'Y' from JTF_TERR_VALUES_ALL xx where xx.LOW_VALUE_CHAR_ID =  temp.party_id 
2432  and (TERR_QUAL_ID in ( select TERR_QUAL_ID from JTF_TERR_QUAL_ALL where QUAL_USG_ID in (-1511, -1435, -1078, -1064, -1063, -1037, -1014, -1002,  -1001))))
2433 
2434  or exists (select 'Y' from JTF_TASK_ASSIGNMENTS xx where xx.RESOURCE_ID =  temp.party_id 
2435  and (RESOURCE_TYPE_CODE  IN (SELECT object_code FROM jtf_objects_b WHERE LTRIM(RTRIM(UPPER(from_table))) = 'HZ_PARTIES' AND RTRIM(LTRIM(UPPER(select_id))) = 'PARTY_ID')))
2436 
2437  or exists (select 'Y' from JTF_PERZ_QUERY_PARAM xx where xx.PARAMETER_VALUE =  to_char(temp.party_id) 
2438  and (parameter_name = 'CUSTOMER_ID' AND query_id IN (SELECT q.query_id FROM  jtf_perz_query q, jtf_perz_query_param p WHERE q.query_type= 'JTF_TASK' AND q.application_id = 690 AND  p.query_id = q.query_id AND p.parameter_name = 'CUSTOMER' AND p.parameter_value = 'NAME')))
2439 
2440  or exists (select 'Y' from JTF_PERZ_QUERY_PARAM xx where xx.PARAMETER_VALUE =  to_char(temp.party_id) 
2441  and (parameter_name = 'CUSTOMER_ID' AND query_id IN (SELECT q.query_id FROM  jtf_perz_query q, jtf_perz_query_param p WHERE q.query_type= 'JTF_TASK' AND q.application_id = 690 AND  p.query_id = q.query_id AND p.parameter_name = 'CUSTOMER' AND p.parameter_value = 'NUMBER')))
2442 
2443  or exists (select 'Y' from HZ_PARTY_SITES
2444  xx where xx.PARTY_ID =  temp.party_id 
2445  and (nvl(STATUS, 'A') in ('A','I'))
2446  and exists
2447 (select 'Y' from JTF_RS_RESOURCE_EXTNS
2448  yy where yy.SUPPORT_SITE_ID=xx.PARTY_SITE_ID
2449 ))
2450 
2451  or exists (select 'Y' from JTF_TTY_NAMED_ACCTS xx where xx.PARTY_ID =  temp.party_id 
2452  );
2453  else 
2454 delete from hz_purge_gt temp where 
2455 
2456 
2457  exists (select 'Y' from JTF_TASKS_B xx where xx.CUSTOMER_ID =  temp.party_id 
2458  )
2459 
2460  or exists (select 'Y' from JTF_TASKS_B xx where xx.SOURCE_OBJECT_ID =  temp.party_id 
2461  and (SOURCE_OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2462 
2463  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.NEW_CUSTOMER_ID =  temp.party_id 
2464  )
2465 
2466  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.OLD_CUSTOMER_ID =  temp.party_id 
2467  )
2468 
2469  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.NEW_SOURCE_OBJECT_ID =  temp.party_id 
2470  and (NEW_SOURCE_OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2471 
2472  or exists (select 'Y' from JTF_TASK_AUDITS_B xx where xx.OLD_SOURCE_OBJECT_ID =  temp.party_id 
2473  and (OLD_SOURCE_OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2474 
2475  or exists (select 'Y' from JTF_TASK_CONTACTS xx where xx.CONTACT_ID =  temp.party_id 
2476  and (CONTACT_TYPE_CODE = 'CUST'))
2477 
2478  or exists (select 'Y' from HZ_PARTY_SITES
2479  xx where xx.PARTY_ID =  temp.party_id 
2480  and (nvl(STATUS, 'A') in ('A','I'))
2481  and exists
2482 (select 'Y' from JTF_TASK_REFERENCES_B
2483  yy where yy.OBJECT_ID=xx.PARTY_SITE_ID
2484  and object_type_code in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTY_SITES' and rtrim(ltrim(upper(select_id))) = 'PARTY_SITE_ID')))
2485 
2486  or exists (select 'Y' from JTF_TASK_REFERENCES_B xx where xx.OBJECT_ID =  temp.party_id 
2487  and (OBJECT_TYPE_CODE in (select object_code from jtf_objects_b where ltrim(rtrim(upper(from_table))) = 'HZ_PARTIES' and rtrim(ltrim(upper(select_id))) = 'PARTY_ID')))
2488 
2489  or exists (select 'Y' from HZ_PARTY_SITES
2490  xx where xx.PARTY_ID =  temp.party_id 
2491  and (nvl(STATUS, 'A') in ('A','I'))
2492  and exists
2493 (select 'Y' from JTF_TASKS_B
2494  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
2495 ))
2496 
2497  or exists (select 'Y' from HZ_PARTY_SITES
2498  xx where xx.PARTY_ID =  temp.party_id 
2499  and (nvl(STATUS, 'A') in ('A','I'))
2500  and exists
2501 (select 'Y' from JTF_TASK_AUDITS_B
2502  yy where yy.NEW_ADDRESS_ID=xx.PARTY_SITE_ID
2503 ))
2504 
2505  or exists (select 'Y' from HZ_PARTY_SITES
2506  xx where xx.PARTY_ID =  temp.party_id 
2507  and (nvl(STATUS, 'A') in ('A','I'))
2508  and exists
2509 (select 'Y' from JTF_TASK_AUDITS_B
2510  yy where yy.OLD_ADDRESS_ID=xx.PARTY_SITE_ID
2511 ))
2512 
2513  or exists (select 'Y' from HZ_CONTACT_POINTS
2514  xx where xx.OWNER_TABLE_ID =  temp.party_id 
2515  and (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I'))
2516  and exists
2517 (select 'Y' from JTF_TASK_PHONES
2518  yy where yy.PHONE_ID=xx.CONTACT_POINT_ID
2519 ))
2520  or exists (select 'Y' from HZ_PARTY_SITES
2521  xx where xx.PARTY_ID =  temp.party_id 
2522  and (nvl(STATUS, 'A') in ('A','I'))
2523  and exists 
2524  (select 'Y' from HZ_CONTACT_POINTS
2525  yy where yy.OWNER_TABLE_ID=xx.PARTY_SITE_ID 
2526  and OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')
2527  and exists 
2528  (select 'Y' from JTF_TASK_PHONES zz where zz.PHONE_ID = yy.CONTACT_POINT_ID )))
2529 
2530  or exists (select 'Y' from HZ_PARTY_SITES
2531  xx where xx.PARTY_ID =  temp.party_id 
2532  and (nvl(STATUS, 'A') in ('A','I'))
2533  and exists 
2534  (select 'Y' from HZ_ORG_CONTACTS
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 
2544  (select 'Y' from HZ_ORG_CONTACTS
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 
2554  (select 'Y' from HZ_ORG_CONTACTS
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 
2564  (select 'Y' from HZ_ORG_CONTACTS
2565  yy where yy.PARTY_RELATIONSHIP_ID=xx.RELATIONSHIP_ID 
2566  and nvl(STATUS, 'A') in ('A','I')
2567  and exists 
2568  (select 'Y' from JTF_RS_RESOURCE_EXTNS zz where zz.CONTACT_ID = yy.ORG_CONTACT_ID and category in ('PARTY', 'PARTNER' ))))
2569 
2570  or exists (select 'Y' from HZ_PARTY_SITES
2571  xx where xx.PARTY_ID =  temp.party_id 
2572  and (nvl(STATUS, 'A') in ('A','I'))
2573  and exists
2574 (select 'Y' from JTF_NOTES_B
2575  yy where yy.SOURCE_OBJECT_ID=xx.PARTY_SITE_ID
2576  and source_object_code  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTY_SITES')))
2577 
2578  or exists (select 'Y' from HZ_PARTY_SITES
2579  xx where xx.PARTY_ID =  temp.party_id 
2580  and (nvl(STATUS, 'A') in ('A','I'))
2581  and exists
2582 (select 'Y' from JTF_NOTE_CONTEXTS
2583  yy where yy.NOTE_CONTEXT_TYPE_ID=xx.PARTY_SITE_ID
2584  and NOTE_CONTEXT_TYPE  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTY_SITES')))
2585 
2586  or exists (select 'Y' from JTF_NOTES_B xx where xx.SOURCE_OBJECT_ID =  temp.party_id 
2587  and (source_object_code  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTIES' )))
2588 
2589  or exists (select 'Y' from JTF_NOTE_CONTEXTS xx where xx.NOTE_CONTEXT_TYPE_ID =  temp.party_id 
2590  and (NOTE_CONTEXT_TYPE  IN (SELECT ojt.object_code FROM jtf_objects_b ojt  ,jtf_object_usages oue WHERE ojt.object_code = oue.object_code AND oue.object_user_code = 'NOTES' and ojt.from_table ='HZ_PARTIES')))
2591 
2592  or exists (select 'Y' from JTF_IH_INTERACTIONS xx where xx.PARTY_ID =  temp.party_id 
2593  )
2594 
2595  or exists (select 'Y' from JTF_RS_RESOURCE_EXTNS xx where xx.SOURCE_ID =  temp.party_id 
2596  and (category IN ( 'PARTY' , 'PARTNER')))
2597 
2598  or exists (select 'Y' from HZ_PARTY_SITES
2599  xx where xx.PARTY_ID =  temp.party_id 
2600  and (nvl(STATUS, 'A') in ('A','I'))
2601  and exists
2602 (select 'Y' from JTF_RS_RESOURCE_EXTNS
2603  yy where yy.ADDRESS_ID=xx.PARTY_SITE_ID
2604  and category  =   'PARTNER'))
2605 
2606  or exists (select 'Y' from JTF_UM_APPROVERS xx where xx.ORG_PARTY_ID =  temp.party_id 
2607  and (ROWNUM < 2))
2608 
2609  or exists (select 'Y' from HZ_PARTY_SITES
2610  xx where xx.PARTY_ID =  temp.party_id 
2611  and (nvl(STATUS, 'A') in ('A','I'))
2612  and exists
2613 (select 'Y' from JTF_TERR_VALUES_ALL
2614  yy where yy.LOW_VALUE_CHAR_ID=xx.PARTY_SITE_ID
2615  and TERR_QUAL_ID in ( select TERR_QUAL_ID from JTF_TERR_QUAL_ALL where QUAL_USG_ID in (-1511, -1435, -1078, -1064, -1063, -1037, -1014, -1002,  -1001))))
2616 
2617  or exists (select 'Y' from JTF_TERR_VALUES_ALL xx where xx.LOW_VALUE_CHAR_ID =  temp.party_id 
2618  and (TERR_QUAL_ID in ( select TERR_QUAL_ID from JTF_TERR_QUAL_ALL where QUAL_USG_ID in (-1511, -1435, -1078, -1064, -1063, -1037, -1014, -1002,  -1001))))
2619 
2620  or exists (select 'Y' from JTF_TASK_ASSIGNMENTS xx where xx.RESOURCE_ID =  temp.party_id 
2621  and (RESOURCE_TYPE_CODE  IN (SELECT object_code FROM jtf_objects_b WHERE LTRIM(RTRIM(UPPER(from_table))) = 'HZ_PARTIES' AND RTRIM(LTRIM(UPPER(select_id))) = 'PARTY_ID')))
2622 
2623  or exists (select 'Y' from JTF_PERZ_QUERY_PARAM xx where xx.PARAMETER_VALUE =  to_char(temp.party_id) 
2624  and (parameter_name = 'CUSTOMER_ID' AND query_id IN (SELECT q.query_id FROM  jtf_perz_query q, jtf_perz_query_param p WHERE q.query_type= 'JTF_TASK' AND q.application_id = 690 AND  p.query_id = q.query_id AND p.parameter_name = 'CUSTOMER' AND p.parameter_value = 'NAME')))
2625 
2626  or exists (select 'Y' from JTF_PERZ_QUERY_PARAM xx where xx.PARAMETER_VALUE =  to_char(temp.party_id) 
2627  and (parameter_name = 'CUSTOMER_ID' AND query_id IN (SELECT q.query_id FROM  jtf_perz_query q, jtf_perz_query_param p WHERE q.query_type= 'JTF_TASK' AND q.application_id = 690 AND  p.query_id = q.query_id AND p.parameter_name = 'CUSTOMER' AND p.parameter_value = 'NUMBER')))
2628 
2629  or exists (select 'Y' from HZ_PARTY_SITES
2630  xx where xx.PARTY_ID =  temp.party_id 
2631  and (nvl(STATUS, 'A') in ('A','I'))
2632  and exists
2633 (select 'Y' from JTF_RS_RESOURCE_EXTNS
2634  yy where yy.SUPPORT_SITE_ID=xx.PARTY_SITE_ID
2635 ))
2636 
2637  or exists (select 'Y' from JTF_TTY_NAMED_ACCTS xx where xx.PARTY_ID =  temp.party_id 
2638  );
2639 end if;
2640 
2641 
2642 --delete and insert records into hz_purge_gt for an application
2643 appid:=515;
2644  if(regid_proc = true) then 
2645 insert into hz_application_trans_gt(app_id,party_id) select 515, temp.party_id from hz_purge_gt temp where 
2646 
2647 
2648  exists (select 'Y' from OKS_BILLING_PROFILES_B xx where xx.OWNED_PARTY_ID1 =  to_char(temp.party_id) 
2649  )
2650 
2651  or exists (select 'Y' from OKS_K_DEFAULTS xx where xx.SEGMENT_ID1 =  to_char(temp.party_id) 
2652  and (JTOT_OBJECT_CODE = 'OKX_PARTY'))
2653 
2654  or exists (select 'Y' from OKS_SERV_AVAIL_EXCEPTS xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
2655  and (JTOT_OBJECT1_CODE = 'OKX_PARTY'));
2656  else 
2657 delete from hz_purge_gt temp where 
2658 
2659 
2660  exists (select 'Y' from OKS_BILLING_PROFILES_B xx where xx.OWNED_PARTY_ID1 =  to_char(temp.party_id) 
2661  )
2662 
2663  or exists (select 'Y' from OKS_K_DEFAULTS xx where xx.SEGMENT_ID1 =  to_char(temp.party_id) 
2664  and (JTOT_OBJECT_CODE = 'OKX_PARTY'))
2665 
2666  or exists (select 'Y' from OKS_SERV_AVAIL_EXCEPTS xx where xx.OBJECT1_ID1 =  to_char(temp.party_id) 
2667  and (JTOT_OBJECT1_CODE = 'OKX_PARTY'));
2668 end if;
2669 
2670 
2671 --delete and insert records into hz_purge_gt for an application
2672 appid:=0;
2673  if(regid_proc = true) then 
2674 insert into hz_application_trans_gt(app_id,party_id) select 0, temp.party_id from hz_purge_gt temp where 
2675 
2676 
2677  exists (select 'Y' from FND_USER xx where xx.CUSTOMER_ID =  temp.party_id 
2678  )
2679 
2680  or exists (select 'Y' from FND_USER xx where xx.PERSON_PARTY_ID =  temp.party_id 
2681  )
2682 
2683  or exists (select 'Y' from UMX_REG_REQUESTS xx where xx.REQUESTED_FOR_PARTY_ID =  temp.party_id 
2684  and (ROWNUM < 2));
2685  else 
2686 delete from hz_purge_gt temp where 
2687 
2688 
2689  exists (select 'Y' from FND_USER xx where xx.CUSTOMER_ID =  temp.party_id 
2690  )
2691 
2692  or exists (select 'Y' from FND_USER xx where xx.PERSON_PARTY_ID =  temp.party_id 
2693  )
2694 
2695  or exists (select 'Y' from UMX_REG_REQUESTS xx where xx.REQUESTED_FOR_PARTY_ID =  temp.party_id 
2696  and (ROWNUM < 2));
2697 end if;
2698 
2699 
2700 --delete and insert records into hz_purge_gt for an application
2701 appid:=170;
2702  if(regid_proc = true) then 
2703 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp where 
2704 
2705 
2706  exists (select 'Y' from CS_INCIDENTS_ALL_B xx where xx.CUSTOMER_ID =  temp.party_id 
2707  )
2708 
2709  or exists (select 'Y' from CS_HZ_SR_CONTACT_POINTS xx where xx.PARTY_ID =  temp.party_id 
2710  and (CONTACT_TYPE <> 'EMPLOYEE'))
2711 
2712  or exists (select 'Y' from HZ_PARTY_SITES
2713  xx where xx.PARTY_ID =  temp.party_id 
2714  and (nvl(STATUS, 'A') in ('A','I'))
2715  and exists
2716 (select 'Y' from CS_ESTIMATE_DETAILS
2717  yy where yy.INVOICE_TO_ORG_ID=xx.PARTY_SITE_ID
2718 ))
2719 
2720  or exists (select 'Y' from HZ_PARTY_SITES
2721  xx where xx.PARTY_ID =  temp.party_id 
2722  and (nvl(STATUS, 'A') in ('A','I'))
2723  and exists
2724 (select 'Y' from CS_ESTIMATE_DETAILS
2725  yy where yy.SHIP_TO_ORG_ID=xx.PARTY_SITE_ID
2726 ));
2727  else 
2728 delete from hz_purge_gt temp where 
2729 
2730 
2731  exists (select 'Y' from CS_INCIDENTS_ALL_B xx where xx.CUSTOMER_ID =  temp.party_id 
2732  )
2733 
2734  or exists (select 'Y' from CS_HZ_SR_CONTACT_POINTS xx where xx.PARTY_ID =  temp.party_id 
2735  and (CONTACT_TYPE <> 'EMPLOYEE'))
2736 
2737  or exists (select 'Y' from HZ_PARTY_SITES
2738  xx where xx.PARTY_ID =  temp.party_id 
2739  and (nvl(STATUS, 'A') in ('A','I'))
2740  and exists
2741 (select 'Y' from CS_ESTIMATE_DETAILS
2742  yy where yy.INVOICE_TO_ORG_ID=xx.PARTY_SITE_ID
2743 ))
2744 
2745  or exists (select 'Y' from HZ_PARTY_SITES
2746  xx where xx.PARTY_ID =  temp.party_id 
2747  and (nvl(STATUS, 'A') in ('A','I'))
2748  and exists
2749 (select 'Y' from CS_ESTIMATE_DETAILS
2750  yy where yy.SHIP_TO_ORG_ID=xx.PARTY_SITE_ID
2751 ));
2752 end if;
2753 
2754 
2755 --delete and insert records into hz_purge_gt for an application
2756 appid:=660;
2757  if(regid_proc = true) then 
2758 insert into hz_application_trans_gt(app_id,party_id) select 660, temp.party_id from hz_purge_gt temp where 
2759 
2760 
2761  exists (select 'Y' from OE_PRICE_ADJ_ATTRIBS xx where xx.PRICING_ATTR_VALUE_FROM =  to_char(temp.party_id) 
2762  and (pricing_context = 'ASOPARTYINFO'  AND pricing_attribute = 'QUALIFIER_ATTRIBUTE1'  OR pricing_context = 'CUSTOMER' AND pricing_attribute ='QUALIFIER_ATTRIBUTE16'  OR pricing_context = 'CUSTOMER_GROUP' AND pricing_attribute = 'QUALIFIER_ATTRIBUTE3'  OR pricing_context = 'PARTY' AND pricing_attribute IN ('QUALIFIER_ATTRIBUTE1', 'QUALIFIER_ATTRIBUTE2')))
2763 
2764  or exists (select 'Y' from HZ_PARTY_SITES
2765  xx where xx.PARTY_ID =  temp.party_id 
2766  and (nvl(STATUS, 'A') in ('A','I'))
2767  and exists
2768 (select 'Y' from OE_PRICE_ADJ_ATTRIBS
2769  yy where yy.PRICING_ATTR_VALUE_FROM=to_char(xx.PARTY_SITE_ID)
2770  and pricing_context = 'ASOPARTYINFO'  AND pricing_attribute IN ('QUALIFIER_ATTRIBUTE10','QUALIFIER_ATTRIBUTE11')  OR pricing_context = 'CUSTOMER' AND pricing_attribute IN ('QUALIFIER_ATTRIBUTE17', 'QUALIFIER_ATTRIBUTE18')));
2771  else 
2772 delete from hz_purge_gt temp where 
2773 
2774 
2775  exists (select 'Y' from OE_PRICE_ADJ_ATTRIBS xx where xx.PRICING_ATTR_VALUE_FROM =  to_char(temp.party_id) 
2776  and (pricing_context = 'ASOPARTYINFO'  AND pricing_attribute = 'QUALIFIER_ATTRIBUTE1'  OR pricing_context = 'CUSTOMER' AND pricing_attribute ='QUALIFIER_ATTRIBUTE16'  OR pricing_context = 'CUSTOMER_GROUP' AND pricing_attribute = 'QUALIFIER_ATTRIBUTE3'  OR pricing_context = 'PARTY' AND pricing_attribute IN ('QUALIFIER_ATTRIBUTE1', 'QUALIFIER_ATTRIBUTE2')))
2777 
2778  or exists (select 'Y' from HZ_PARTY_SITES
2779  xx where xx.PARTY_ID =  temp.party_id 
2780  and (nvl(STATUS, 'A') in ('A','I'))
2781  and exists
2782 (select 'Y' from OE_PRICE_ADJ_ATTRIBS
2783  yy where yy.PRICING_ATTR_VALUE_FROM=to_char(xx.PARTY_SITE_ID)
2784  and pricing_context = 'ASOPARTYINFO'  AND pricing_attribute IN ('QUALIFIER_ATTRIBUTE10','QUALIFIER_ATTRIBUTE11')  OR pricing_context = 'CUSTOMER' AND pricing_attribute IN ('QUALIFIER_ATTRIBUTE17', 'QUALIFIER_ATTRIBUTE18')));
2785 end if;
2786 
2787 
2788 --delete and insert records into hz_purge_gt for an application
2789 appid:=800;
2790  if(regid_proc = true) then 
2791 insert into hz_application_trans_gt(app_id,party_id) select 800, temp.party_id from hz_purge_gt temp where 
2792 
2793 
2794  exists (select 'Y' from PER_ALL_PEOPLE_F xx where xx.PARTY_ID =  temp.party_id 
2795  and (effective_end_date = to_date('12/31/4712','MM/DD/YYYY')));
2796  else 
2797 delete from hz_purge_gt temp where 
2798 
2799 
2800  exists (select 'Y' from PER_ALL_PEOPLE_F xx where xx.PARTY_ID =  temp.party_id 
2801  and (effective_end_date = to_date('12/31/4712','MM/DD/YYYY')));
2802 end if;
2803 
2804 
2805 --delete and insert records into hz_purge_gt for an application
2806 appid:=174;
2807  if(regid_proc = true) then 
2808 insert into hz_application_trans_gt(app_id,party_id) select 174, temp.party_id from hz_purge_gt temp where 
2809 
2810 
2811  exists (select 'Y' from ECX_TP_HEADERS xx where xx.PARTY_ID =  temp.party_id 
2812  );
2813  else 
2814 delete from hz_purge_gt temp where 
2815 
2816 
2817  exists (select 'Y' from ECX_TP_HEADERS xx where xx.PARTY_ID =  temp.party_id 
2818  );
2819 end if;
2820 
2821 
2822 --delete and insert records into hz_purge_gt for an application
2823 appid:=204;
2824  if(regid_proc = true) then 
2825 insert into hz_application_trans_gt(app_id,party_id) select 204, temp.party_id from hz_purge_gt temp where 
2826 
2827 
2828  exists (select 'Y' from XLE_ENTITY_PROFILES xx where xx.PARTY_ID =  temp.party_id 
2829  )
2830 
2831  or exists (select 'Y' from XLE_ETB_PROFILES xx where xx.PARTY_ID =  temp.party_id 
2832  );
2833  else 
2834 delete from hz_purge_gt temp where 
2835 
2836 
2837  exists (select 'Y' from XLE_ENTITY_PROFILES xx where xx.PARTY_ID =  temp.party_id 
2838  )
2839 
2840  or exists (select 'Y' from XLE_ETB_PROFILES xx where xx.PARTY_ID =  temp.party_id 
2841  );
2842 end if;
2843 
2844 
2845 --delete and insert records into hz_purge_gt for an application
2846 appid:=666;
2847  if(regid_proc = true) then 
2848 insert into hz_application_trans_gt(app_id,party_id) select 666, temp.party_id from hz_purge_gt temp where 
2849 
2850 
2851  exists (select 'Y' from IBW_SITE_VISITS xx where xx.PARTY_ID =  temp.party_id 
2852  );
2853  else 
2854 delete from hz_purge_gt temp where 
2855 
2856 
2857  exists (select 'Y' from IBW_SITE_VISITS xx where xx.PARTY_ID =  temp.party_id 
2858  );
2859 end if;
2860 
2861 
2862 --IGW_PROP_LOCATIONS;PARTY_ID
2863 appid:=8404;
2864  if(regid_proc = true) then 
2865 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8404 and appl.party_id=temp.party_id) and 
2866 
2867  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGW_PROP_LOCATIONS xx 
2868  );
2869  else 
2870 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2871  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGW_PROP_LOCATIONS xx 
2872  );
2873 end if;
2874 --IGW_PERSON_DEGREES;PARTY_ID
2875 appid:=8404;
2876  if(regid_proc = true) then 
2877 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8404 and appl.party_id=temp.party_id) and 
2878 
2879  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGW_PERSON_DEGREES xx 
2880  );
2881  else 
2882 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2883  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGW_PERSON_DEGREES xx 
2884  );
2885 end if;
2886 --IGW_PERSON_BIOSKETCH;PARTY_ID
2887 appid:=8404;
2888  if(regid_proc = true) then 
2889 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8404 and appl.party_id=temp.party_id) and 
2890 
2891  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGW_PERSON_BIOSKETCH xx 
2892  );
2893  else 
2894 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2895  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGW_PERSON_BIOSKETCH xx 
2896  );
2897 end if;
2898 --IGW_PROP_PERSONS_TCA_V;ORG_PARTY_ID
2899 appid:=8404;
2900  if(regid_proc = true) then 
2901 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8404 and appl.party_id=temp.party_id) and 
2902 
2903  temp.party_id  in (select /*+ parallel(xx)*/ xx.ORG_PARTY_ID from IGW_PROP_PERSONS_TCA_V xx 
2904  );
2905  else 
2906 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2907  temp.party_id  in (select /*+ parallel(xx)*/ xx.ORG_PARTY_ID from IGW_PROP_PERSONS_TCA_V xx 
2908  );
2909 end if;
2910 --IGW_PROP_PERSON_SUPPORT;LOCATION_PARTY_ID
2911 appid:=8404;
2912  if(regid_proc = true) then 
2913 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8404 and appl.party_id=temp.party_id) and 
2914 
2915  temp.party_id  in (select /*+ parallel(xx)*/ xx.LOCATION_PARTY_ID from IGW_PROP_PERSON_SUPPORT xx 
2916  );
2917  else 
2918 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2919  temp.party_id  in (select /*+ parallel(xx)*/ xx.LOCATION_PARTY_ID from IGW_PROP_PERSON_SUPPORT xx 
2920  );
2921 end if;
2922 --IGW_PROP_PERSON_SUPPORT;PI_PARTY_ID
2923 appid:=8404;
2924  if(regid_proc = true) then 
2925 insert into hz_application_trans_gt(app_id,party_id) select 8404, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8404 and appl.party_id=temp.party_id) and 
2926 
2927  temp.party_id  in (select /*+ parallel(xx)*/ xx.PI_PARTY_ID from IGW_PROP_PERSON_SUPPORT xx 
2928  );
2929  else 
2930 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2931  temp.party_id  in (select /*+ parallel(xx)*/ xx.PI_PARTY_ID from IGW_PROP_PERSON_SUPPORT xx 
2932  );
2933 end if;
2934 --WSH_PARTY_SITES_V;PARTY_SITE_ID
2935 appid:=665;
2936  if(regid_proc = true) then 
2937 insert into hz_application_trans_gt(app_id,party_id) select 665, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 665 and appl.party_id=temp.party_id) and 
2938 
2939  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
2940  xx 
2941  where (nvl(STATUS, 'A') in ('A','I'))
2942  and  xx.PARTY_SITE_ID 
2943  in (select /*+ parallel(yy)*/ yy.PARTY_SITE_ID from WSH_PARTY_SITES_V
2944  yy 
2945 ));
2946  else 
2947 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2948  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
2949  xx 
2950  where (nvl(STATUS, 'A') in ('A','I'))
2951  and  xx.PARTY_SITE_ID 
2952  in (select /*+ parallel(yy)*/ yy.PARTY_SITE_ID from WSH_PARTY_SITES_V
2953  yy 
2954 ));
2955 end if;
2956 --IGF_AP_FA_BASE_REC_ALL;PERSON_ID
2957 appid:=8406;
2958  if(regid_proc = true) then 
2959 insert into hz_application_trans_gt(app_id,party_id) select 8406, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8406 and appl.party_id=temp.party_id) and 
2960 
2961  temp.party_id  in (select /*+ parallel(xx)*/ xx.PERSON_ID from IGF_AP_FA_BASE_REC_ALL xx 
2962  );
2963  else 
2964 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2965  temp.party_id  in (select /*+ parallel(xx)*/ xx.PERSON_ID from IGF_AP_FA_BASE_REC_ALL xx 
2966  );
2967 end if;
2968 --IGF_AW_FUND_MAST_ALL;PARTY_ID
2969 appid:=8406;
2970  if(regid_proc = true) then 
2971 insert into hz_application_trans_gt(app_id,party_id) select 8406, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8406 and appl.party_id=temp.party_id) and 
2972 
2973  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGF_AW_FUND_MAST_ALL xx 
2974  );
2975  else 
2976 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2977  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGF_AW_FUND_MAST_ALL xx 
2978  );
2979 end if;
2980 --HZ_CODE_ASSIGNMENTS;OWNER_TABLE_ID
2981 appid:=222;
2982  if(regid_proc = true) then 
2983 insert into hz_application_trans_gt(app_id,party_id) select 222, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 222 and appl.party_id=temp.party_id) and 
2984 
2985  temp.party_id  in (select /*+ parallel(xx)*/ xx.OWNER_TABLE_ID from HZ_CODE_ASSIGNMENTS xx 
2986  where (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I')));
2987  else 
2988 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
2989  temp.party_id  in (select /*+ parallel(xx)*/ xx.OWNER_TABLE_ID from HZ_CODE_ASSIGNMENTS xx 
2990  where (OWNER_TABLE_NAME='HZ_PARTIES' AND nvl(STATUS, 'A') in ('A','I')));
2991 end if;
2992 --HZ_CODE_ASSIGNMENTS;OWNER_TABLE_ID
2993 appid:=222;
2994  if(regid_proc = true) then 
2995 insert into hz_application_trans_gt(app_id,party_id) select 222, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 222 and appl.party_id=temp.party_id) and 
2996 
2997  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
2998  xx 
2999  where (nvl(STATUS, 'A') in ('A','I'))
3000  and  xx.PARTY_SITE_ID 
3001  in (select /*+ parallel(yy)*/ yy.OWNER_TABLE_ID from HZ_CODE_ASSIGNMENTS
3002  yy 
3003  where OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')));
3004  else 
3005 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3006  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3007  xx 
3008  where (nvl(STATUS, 'A') in ('A','I'))
3009  and  xx.PARTY_SITE_ID 
3010  in (select /*+ parallel(yy)*/ yy.OWNER_TABLE_ID from HZ_CODE_ASSIGNMENTS
3011  yy 
3012  where OWNER_TABLE_NAME='HZ_PARTY_SITES' AND nvl(STATUS, 'A') in ('A','I')));
3013 end if;
3014 --HZ_WORK_CLASS;EMPLOYMENT_HISTORY_ID
3015 appid:=222;
3016  if(regid_proc = true) then 
3017 insert into hz_application_trans_gt(app_id,party_id) select 222, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 222 and appl.party_id=temp.party_id) and 
3018 
3019  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_EMPLOYMENT_HISTORY
3020  xx 
3021  where (nvl(STATUS, 'A') in ('A','I'))
3022  and  xx.EMPLOYMENT_HISTORY_ID 
3023  in (select /*+ parallel(yy)*/ yy.EMPLOYMENT_HISTORY_ID from HZ_WORK_CLASS
3024  yy 
3025  where nvl(STATUS, 'A') in ('A','I')))
3026  or  temp.party_id  in (select /*+ parallel (xx)*/ xx.EMPLOYED_BY_PARTY_ID from HZ_EMPLOYMENT_HISTORY
3027  xx 
3028  where (nvl(STATUS,'A') in ('A','I'))
3029  and  xx.EMPLOYMENT_HISTORY_ID 
3030  in (select /*+ parallel(yy)*/ yy.EMPLOYMENT_HISTORY_ID from HZ_WORK_CLASS
3031  yy 
3032  where nvl(STATUS, 'A') in ('A','I')));
3033  else 
3034 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3035  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_EMPLOYMENT_HISTORY
3036  xx 
3037  where (nvl(STATUS, 'A') in ('A','I'))
3038  and  xx.EMPLOYMENT_HISTORY_ID 
3039  in (select /*+ parallel(yy)*/ yy.EMPLOYMENT_HISTORY_ID from HZ_WORK_CLASS
3040  yy 
3041  where nvl(STATUS, 'A') in ('A','I')))
3042  or  temp.party_id  in (select /*+ parallel (xx)*/ xx.EMPLOYED_BY_PARTY_ID from HZ_EMPLOYMENT_HISTORY
3043  xx 
3044  where (nvl(STATUS,'A') in ('A','I'))
3045  and  xx.EMPLOYMENT_HISTORY_ID 
3046  in (select /*+ parallel(yy)*/ yy.EMPLOYMENT_HISTORY_ID from HZ_WORK_CLASS
3047  yy 
3048  where nvl(STATUS, 'A') in ('A','I')));
3049 end if;
3050 --FND_ATTACHED_DOCUMENTS;PK1_VALUE
3051 appid:=222;
3052  if(regid_proc = true) then 
3053 insert into hz_application_trans_gt(app_id,party_id) select 222, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 222 and appl.party_id=temp.party_id) and 
3054 
3055  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.PK1_VALUE from FND_ATTACHED_DOCUMENTS xx 
3056  where (entity_name = 'HZ_PARTIES'));
3057  else 
3058 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3059  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.PK1_VALUE from FND_ATTACHED_DOCUMENTS xx 
3060  where (entity_name = 'HZ_PARTIES'));
3061 end if;
3062 --HZ_EMAIL_DOMAINS;PARTY_ID
3063 appid:=222;
3064  if(regid_proc = true) then 
3065 insert into hz_application_trans_gt(app_id,party_id) select 222, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 222 and appl.party_id=temp.party_id) and 
3066 
3067  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from HZ_EMAIL_DOMAINS xx 
3068  );
3069  else 
3070 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3071  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from HZ_EMAIL_DOMAINS xx 
3072  );
3073 end if;
3074 --IBE_SH_QUOTE_ACCESS;PARTY_ID
3075 appid:=671;
3076  if(regid_proc = true) then 
3077 insert into hz_application_trans_gt(app_id,party_id) select 671, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 671 and appl.party_id=temp.party_id) and 
3078 
3079  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IBE_SH_QUOTE_ACCESS xx 
3080  );
3081  else 
3082 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3083  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IBE_SH_QUOTE_ACCESS xx 
3084  );
3085 end if;
3086 --IBE_ACTIVE_QUOTES_ALL;PARTY_ID
3087 appid:=671;
3088  if(regid_proc = true) then 
3089 insert into hz_application_trans_gt(app_id,party_id) select 671, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 671 and appl.party_id=temp.party_id) and 
3090 
3091  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IBE_ACTIVE_QUOTES_ALL xx 
3092  );
3093  else 
3094 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3095  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IBE_ACTIVE_QUOTES_ALL xx 
3096  );
3097 end if;
3098 --OZF_CLAIMS_HISTORY_ALL;BROKER_ID
3099 appid:=682;
3100  if(regid_proc = true) then 
3101 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3102 
3103  temp.party_id  in (select /*+ parallel(xx)*/ xx.BROKER_ID from OZF_CLAIMS_HISTORY_ALL xx 
3104  );
3105  else 
3106 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3107  temp.party_id  in (select /*+ parallel(xx)*/ xx.BROKER_ID from OZF_CLAIMS_HISTORY_ALL xx 
3108  );
3109 end if;
3110 --OZF_CLAIMS_HISTORY_ALL;CONTACT_ID
3111 appid:=682;
3112  if(regid_proc = true) then 
3113 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3114 
3115  temp.party_id  in (select /*+ parallel(xx)*/ xx.CONTACT_ID from OZF_CLAIMS_HISTORY_ALL xx 
3116  );
3117  else 
3118 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3119  temp.party_id  in (select /*+ parallel(xx)*/ xx.CONTACT_ID from OZF_CLAIMS_HISTORY_ALL xx 
3120  );
3121 end if;
3122 --OZF_RESALE_LINES_INT_ALL;SHIP_FROM_CONTACT_PARTY_ID
3123 appid:=682;
3124  if(regid_proc = true) then 
3125 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3126 
3127  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3128  );
3129  else 
3130 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3131  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3132  );
3133 end if;
3134 --OZF_RESALE_LINES_INT_ALL;SOLD_FROM_CONTACT_PARTY_ID
3135 appid:=682;
3136  if(regid_proc = true) then 
3137 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3138 
3139  temp.party_id  in (select /*+ parallel(xx)*/ xx.SOLD_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3140  );
3141  else 
3142 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3143  temp.party_id  in (select /*+ parallel(xx)*/ xx.SOLD_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3144  );
3145 end if;
3146 --OZF_RESALE_LINES_INT_ALL;BILL_TO_PARTY_ID
3147 appid:=682;
3148  if(regid_proc = true) then 
3149 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3150 
3151  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3152  );
3153  else 
3154 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3155  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3156  );
3157 end if;
3158 --OZF_RESALE_LINES_INT_ALL;BILL_TO_CONTACT_PARTY_ID
3159 appid:=682;
3160  if(regid_proc = true) then 
3161 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3162 
3163  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3164  );
3165  else 
3166 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3167  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3168  );
3169 end if;
3170 --OZF_RESALE_LINES_INT_ALL;SHIP_TO_PARTY_ID
3171 appid:=682;
3172  if(regid_proc = true) then 
3173 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3174 
3175  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3176  );
3177  else 
3178 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3179  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3180  );
3181 end if;
3182 --OZF_RESALE_LINES_INT_ALL;SHIP_TO_CONTACT_PARTY_ID
3183 appid:=682;
3184  if(regid_proc = true) then 
3185 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3186 
3187  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3188  );
3189  else 
3190 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3191  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3192  );
3193 end if;
3194 --OZF_RESALE_LINES_INT_ALL;END_CUST_PARTY_ID
3195 appid:=682;
3196  if(regid_proc = true) then 
3197 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3198 
3199  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3200  );
3201  else 
3202 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3203  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3204  );
3205 end if;
3206 --OZF_RESALE_LINES_INT_ALL;END_CUST_CONTACT_PARTY_ID
3207 appid:=682;
3208  if(regid_proc = true) then 
3209 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3210 
3211  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3212  );
3213  else 
3214 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3215  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_CONTACT_PARTY_ID from OZF_RESALE_LINES_INT_ALL xx 
3216  );
3217 end if;
3218 --OZF_RESALE_HEADERS_ALL;BILL_TO_PARTY_ID
3219 appid:=682;
3220  if(regid_proc = true) then 
3221 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3222 
3223  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3224  );
3225  else 
3226 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3227  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3228  );
3229 end if;
3230 --OZF_RESALE_HEADERS_ALL;BILL_TO_CONTACT_PARTY_ID
3231 appid:=682;
3232  if(regid_proc = true) then 
3233 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3234 
3235  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3236  );
3237  else 
3238 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3239  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3240  );
3241 end if;
3242 --OZF_RESALE_HEADERS_ALL;SHIP_TO_PARTY_ID
3243 appid:=682;
3244  if(regid_proc = true) then 
3245 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3246 
3247  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3248  );
3249  else 
3250 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3251  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3252  );
3253 end if;
3254 --OZF_RESALE_HEADERS_ALL;SHIP_TO_CONTACT_PARTY_ID
3255 appid:=682;
3256  if(regid_proc = true) then 
3257 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3258 
3259  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3260  );
3261  else 
3262 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3263  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_PARTY_ID from OZF_RESALE_HEADERS_ALL xx 
3264  );
3265 end if;
3266 --OZF_RESALE_LINES_ALL;SHIP_FROM_CONTACT_PARTY_ID
3267 appid:=682;
3268  if(regid_proc = true) then 
3269 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3270 
3271  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3272  );
3273  else 
3274 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3275  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3276  );
3277 end if;
3278 --OZF_RESALE_LINES_ALL;SOLD_FROM_CONTACT_PARTY_ID
3279 appid:=682;
3280  if(regid_proc = true) then 
3281 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3282 
3283  temp.party_id  in (select /*+ parallel(xx)*/ xx.SOLD_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3284  );
3285  else 
3286 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3287  temp.party_id  in (select /*+ parallel(xx)*/ xx.SOLD_FROM_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3288  );
3289 end if;
3290 --OZF_RESALE_LINES_ALL;BILL_TO_PARTY_ID
3291 appid:=682;
3292  if(regid_proc = true) then 
3293 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3294 
3295  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3296  );
3297  else 
3298 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3299  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3300  );
3301 end if;
3302 --OZF_RESALE_LINES_ALL;BILL_TO_CONTACT_PARTY_ID
3303 appid:=682;
3304  if(regid_proc = true) then 
3305 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3306 
3307  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3308  );
3309  else 
3310 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3311  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3312  );
3313 end if;
3314 --OZF_RESALE_LINES_ALL;SHIP_TO_PARTY_ID
3315 appid:=682;
3316  if(regid_proc = true) then 
3317 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3318 
3319  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3320  );
3321  else 
3322 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3323  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3324  );
3325 end if;
3326 --OZF_RESALE_LINES_ALL;SHIP_TO_CONTACT_PARTY_ID
3327 appid:=682;
3328  if(regid_proc = true) then 
3329 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3330 
3331  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3332  );
3333  else 
3334 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3335  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3336  );
3337 end if;
3338 --OZF_RESALE_LINES_ALL;END_CUST_PARTY_ID
3339 appid:=682;
3340  if(regid_proc = true) then 
3341 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3342 
3343  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3344  );
3345  else 
3346 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3347  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3348  );
3349 end if;
3350 --OZF_RESALE_LINES_ALL;END_CUST_CONTACT_PARTY_ID
3351 appid:=682;
3352  if(regid_proc = true) then 
3353 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3354 
3355  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3356  );
3357  else 
3358 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3359  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_CONTACT_PARTY_ID from OZF_RESALE_LINES_ALL xx 
3360  );
3361 end if;
3362 --OZF_REQUEST_HEADERS_ALL_B;END_CUST_PARTY_ID
3363 appid:=682;
3364  if(regid_proc = true) then 
3365 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3366 
3367  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_PARTY_ID from OZF_REQUEST_HEADERS_ALL_B xx 
3368  );
3369  else 
3370 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3371  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUST_PARTY_ID from OZF_REQUEST_HEADERS_ALL_B xx 
3372  );
3373 end if;
3374 --OZF_REQUEST_HEADERS_ALL_B;RESELLER_PARTY_ID
3375 appid:=682;
3376  if(regid_proc = true) then 
3377 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3378 
3379  temp.party_id  in (select /*+ parallel(xx)*/ xx.RESELLER_PARTY_ID from OZF_REQUEST_HEADERS_ALL_B xx 
3380  );
3381  else 
3382 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3383  temp.party_id  in (select /*+ parallel(xx)*/ xx.RESELLER_PARTY_ID from OZF_REQUEST_HEADERS_ALL_B xx 
3384  );
3385 end if;
3386 --OZF_OFFERS;AUTOPAY_PARTY_ID
3387 appid:=682;
3388  if(regid_proc = true) then 
3389 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3390 
3391  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTOPAY_PARTY_ID from OZF_OFFERS xx 
3392  );
3393  else 
3394 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3395  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTOPAY_PARTY_ID from OZF_OFFERS xx 
3396  );
3397 end if;
3398 --OZF_ACTIVITY_CUSTOMERS;PARTY_ID
3399 appid:=682;
3400  if(regid_proc = true) then 
3401 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3402 
3403  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from OZF_ACTIVITY_CUSTOMERS xx 
3404  );
3405  else 
3406 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3407  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from OZF_ACTIVITY_CUSTOMERS xx 
3408  );
3409 end if;
3410 --OZF_CLAIM_LINES_HIST_ALL;BUY_GROUP_PARTY_ID
3411 appid:=682;
3412  if(regid_proc = true) then 
3413 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3414 
3415  temp.party_id  in (select /*+ parallel(xx)*/ xx.BUY_GROUP_PARTY_ID from OZF_CLAIM_LINES_HIST_ALL xx 
3416  );
3417  else 
3418 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3419  temp.party_id  in (select /*+ parallel(xx)*/ xx.BUY_GROUP_PARTY_ID from OZF_CLAIM_LINES_HIST_ALL xx 
3420  );
3421 end if;
3422 --OZF_RESALE_BATCHES_ALL;PARTNER_CONTACT_PARTY_ID
3423 appid:=682;
3424  if(regid_proc = true) then 
3425 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3426 
3427  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTNER_CONTACT_PARTY_ID from OZF_RESALE_BATCHES_ALL xx 
3428  );
3429  else 
3430 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3431  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTNER_CONTACT_PARTY_ID from OZF_RESALE_BATCHES_ALL xx 
3432  );
3433 end if;
3434 --OZF_CLAIM_LINES_ALL;BUY_GROUP_PARTY_ID
3435 appid:=682;
3436  if(regid_proc = true) then 
3437 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3438 
3439  temp.party_id  in (select /*+ parallel(xx)*/ xx.BUY_GROUP_PARTY_ID from OZF_CLAIM_LINES_ALL xx 
3440  );
3441  else 
3442 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3443  temp.party_id  in (select /*+ parallel(xx)*/ xx.BUY_GROUP_PARTY_ID from OZF_CLAIM_LINES_ALL xx 
3444  );
3445 end if;
3446 --OZF_ACCOUNT_ALLOCATIONS;PARENT_PARTY_ID
3447 appid:=682;
3448  if(regid_proc = true) then 
3449 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3450 
3451  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARENT_PARTY_ID from OZF_ACCOUNT_ALLOCATIONS xx 
3452  );
3453  else 
3454 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3455  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARENT_PARTY_ID from OZF_ACCOUNT_ALLOCATIONS xx 
3456  );
3457 end if;
3458 --OZF_ACCOUNT_ALLOCATIONS;ROLLUP_PARTY_ID
3459 appid:=682;
3460  if(regid_proc = true) then 
3461 insert into hz_application_trans_gt(app_id,party_id) select 682, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 682 and appl.party_id=temp.party_id) and 
3462 
3463  temp.party_id  in (select /*+ parallel(xx)*/ xx.ROLLUP_PARTY_ID from OZF_ACCOUNT_ALLOCATIONS xx 
3464  );
3465  else 
3466 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3467  temp.party_id  in (select /*+ parallel(xx)*/ xx.ROLLUP_PARTY_ID from OZF_ACCOUNT_ALLOCATIONS xx 
3468  );
3469 end if;
3470 --FUN_TRX_BATCHES;INITIATOR_ID
3471 appid:=435;
3472  if(regid_proc = true) then 
3473 insert into hz_application_trans_gt(app_id,party_id) select 435, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 435 and appl.party_id=temp.party_id) and 
3474 
3475  temp.party_id  in (select /*+ parallel(xx)*/ xx.INITIATOR_ID from FUN_TRX_BATCHES xx 
3476  );
3477  else 
3478 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3479  temp.party_id  in (select /*+ parallel(xx)*/ xx.INITIATOR_ID from FUN_TRX_BATCHES xx 
3480  );
3481 end if;
3482 --FUN_TRX_HEADERS;RECIPIENT_ID
3483 appid:=435;
3484  if(regid_proc = true) then 
3485 insert into hz_application_trans_gt(app_id,party_id) select 435, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 435 and appl.party_id=temp.party_id) and 
3486 
3487  temp.party_id  in (select /*+ parallel(xx)*/ xx.RECIPIENT_ID from FUN_TRX_HEADERS xx 
3488  );
3489  else 
3490 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3491  temp.party_id  in (select /*+ parallel(xx)*/ xx.RECIPIENT_ID from FUN_TRX_HEADERS xx 
3492  );
3493 end if;
3494 --FUN_DIST_LINES;PARTY_ID
3495 appid:=435;
3496  if(regid_proc = true) then 
3497 insert into hz_application_trans_gt(app_id,party_id) select 435, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 435 and appl.party_id=temp.party_id) and 
3498 
3499  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from FUN_DIST_LINES xx 
3500  );
3501  else 
3502 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3503  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from FUN_DIST_LINES xx 
3504  );
3505 end if;
3506 --FUN_SUPPLIER_MAPS;VENDOR_SITE_ID
3507 appid:=435;
3508  if(regid_proc = true) then 
3509 insert into hz_application_trans_gt(app_id,party_id) select 435, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 435 and appl.party_id=temp.party_id) and 
3510 
3511  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3512  xx 
3513  where (nvl(STATUS, 'A') in ('A','I'))
3514  and  xx.PARTY_SITE_ID 
3515  in (select /*+ parallel(yy)*/ yy.VENDOR_SITE_ID from FUN_SUPPLIER_MAPS
3516  yy 
3517 ));
3518  else 
3519 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3520  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3521  xx 
3522  where (nvl(STATUS, 'A') in ('A','I'))
3523  and  xx.PARTY_SITE_ID 
3524  in (select /*+ parallel(yy)*/ yy.VENDOR_SITE_ID from FUN_SUPPLIER_MAPS
3525  yy 
3526 ));
3527 end if;
3528 --IGS_PE_STAT_DETAILS;PERSON_PROFILE_ID
3529 appid:=8405;
3530  if(regid_proc = true) then 
3531 insert into hz_application_trans_gt(app_id,party_id) select 8405, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8405 and appl.party_id=temp.party_id) and 
3532 
3533  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PERSON_PROFILES
3534  xx 
3535  where (nvl(STATUS, 'A') in ('A','I') and effective_end_date is null)
3536  and  xx.PERSON_PROFILE_ID 
3537  in (select /*+ parallel(yy)*/ yy.PERSON_PROFILE_ID from IGS_PE_STAT_DETAILS
3538  yy 
3539 ));
3540  else 
3541 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3542  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PERSON_PROFILES
3543  xx 
3544  where (nvl(STATUS, 'A') in ('A','I') and effective_end_date is null)
3545  and  xx.PERSON_PROFILE_ID 
3546  in (select /*+ parallel(yy)*/ yy.PERSON_PROFILE_ID from IGS_PE_STAT_DETAILS
3547  yy 
3548 ));
3549 end if;
3550 --IGS_FI_REFUNDS;PAY_PERSON_ID
3551 appid:=8405;
3552  if(regid_proc = true) then 
3553 insert into hz_application_trans_gt(app_id,party_id) select 8405, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8405 and appl.party_id=temp.party_id) and 
3554 
3555  temp.party_id  in (select /*+ parallel(xx)*/ xx.PAY_PERSON_ID from IGS_FI_REFUNDS xx 
3556  );
3557  else 
3558 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3559  temp.party_id  in (select /*+ parallel(xx)*/ xx.PAY_PERSON_ID from IGS_FI_REFUNDS xx 
3560  );
3561 end if;
3562 --IGP_AC_ACCOUNT_INTS;PARTY_ID
3563 appid:=8405;
3564  if(regid_proc = true) then 
3565 insert into hz_application_trans_gt(app_id,party_id) select 8405, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8405 and appl.party_id=temp.party_id) and 
3566 
3567  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGP_AC_ACCOUNT_INTS xx 
3568  );
3569  else 
3570 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3571  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IGP_AC_ACCOUNT_INTS xx 
3572  );
3573 end if;
3574 --IGP_US_REG_VIEWERS;ORG_PARTY_ID
3575 appid:=8405;
3576  if(regid_proc = true) then 
3577 insert into hz_application_trans_gt(app_id,party_id) select 8405, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 8405 and appl.party_id=temp.party_id) and 
3578 
3579  temp.party_id  in (select /*+ parallel(xx)*/ xx.ORG_PARTY_ID from IGP_US_REG_VIEWERS xx 
3580  );
3581  else 
3582 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3583  temp.party_id  in (select /*+ parallel(xx)*/ xx.ORG_PARTY_ID from IGP_US_REG_VIEWERS xx 
3584  );
3585 end if;
3586 --XDP_ORDER_HEADERS;CUSTOMER_ID
3587 appid:=535;
3588  if(regid_proc = true) then 
3589 insert into hz_application_trans_gt(app_id,party_id) select 535, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 535 and appl.party_id=temp.party_id) and 
3590 
3591  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from XDP_ORDER_HEADERS xx 
3592  );
3593  else 
3594 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3595  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from XDP_ORDER_HEADERS xx 
3596  );
3597 end if;
3598 --QA_RESULTS;PARTY_ID
3599 appid:=250;
3600  if(regid_proc = true) then 
3601 insert into hz_application_trans_gt(app_id,party_id) select 250, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 250 and appl.party_id=temp.party_id) and 
3602 
3603  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from QA_RESULTS xx 
3604  );
3605  else 
3606 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3607  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from QA_RESULTS xx 
3608  );
3609 end if;
3610 --PRP_EMAIL_RECIPIENTS;PARTY_ID
3611 appid:=694;
3612  if(regid_proc = true) then 
3613 insert into hz_application_trans_gt(app_id,party_id) select 694, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 694 and appl.party_id=temp.party_id) and 
3614 
3615  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from PRP_EMAIL_RECIPIENTS xx 
3616  );
3617  else 
3618 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3619  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from PRP_EMAIL_RECIPIENTS xx 
3620  );
3621 end if;
3622 --PRP_PROPOSALS;CONTACT_PARTY_ID
3623 appid:=694;
3624  if(regid_proc = true) then 
3625 insert into hz_application_trans_gt(app_id,party_id) select 694, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 694 and appl.party_id=temp.party_id) and 
3626 
3627  temp.party_id  in (select /*+ parallel(xx)*/ xx.CONTACT_PARTY_ID from PRP_PROPOSALS xx 
3628  );
3629  else 
3630 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3631  temp.party_id  in (select /*+ parallel(xx)*/ xx.CONTACT_PARTY_ID from PRP_PROPOSALS xx 
3632  );
3633 end if;
3634 --CSI_ITEM_INSTANCES;LOCATION_ID
3635 appid:=542;
3636  if(regid_proc = true) then 
3637 insert into hz_application_trans_gt(app_id,party_id) select 542, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 542 and appl.party_id=temp.party_id) and 
3638 
3639  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3640  xx 
3641  where (nvl(STATUS, 'A') in ('A','I'))
3642  and  xx.PARTY_SITE_ID 
3643  in (select /*+ parallel(yy)*/ yy.LOCATION_ID from CSI_ITEM_INSTANCES
3644  yy 
3645 ));
3646  else 
3647 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3648  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3649  xx 
3650  where (nvl(STATUS, 'A') in ('A','I'))
3651  and  xx.PARTY_SITE_ID 
3652  in (select /*+ parallel(yy)*/ yy.LOCATION_ID from CSI_ITEM_INSTANCES
3653  yy 
3654 ));
3655 end if;
3656 --CSI_ITEM_INSTANCES;INSTALL_LOCATION_ID
3657 appid:=542;
3658  if(regid_proc = true) then 
3659 insert into hz_application_trans_gt(app_id,party_id) select 542, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 542 and appl.party_id=temp.party_id) and 
3660 
3661  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3662  xx 
3663  where (nvl(STATUS, 'A') in ('A','I'))
3664  and  xx.PARTY_SITE_ID 
3665  in (select /*+ parallel(yy)*/ yy.INSTALL_LOCATION_ID from CSI_ITEM_INSTANCES
3666  yy 
3667 ));
3668  else 
3669 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3670  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3671  xx 
3672  where (nvl(STATUS, 'A') in ('A','I'))
3673  and  xx.PARTY_SITE_ID 
3674  in (select /*+ parallel(yy)*/ yy.INSTALL_LOCATION_ID from CSI_ITEM_INSTANCES
3675  yy 
3676 ));
3677 end if;
3678 --CSI_T_TXN_SYSTEMS;INSTALL_SITE_USE_ID
3679 appid:=542;
3680  if(regid_proc = true) then 
3681 insert into hz_application_trans_gt(app_id,party_id) select 542, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 542 and appl.party_id=temp.party_id) and 
3682 
3683  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3684  xx 
3685  where (nvl(STATUS, 'A') in ('A','I'))
3686  and  xx.PARTY_SITE_ID 
3687  in (select /*+ parallel(yy)*/ yy.INSTALL_SITE_USE_ID from CSI_T_TXN_SYSTEMS
3688  yy 
3689 ));
3690  else 
3691 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3692  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3693  xx 
3694  where (nvl(STATUS, 'A') in ('A','I'))
3695  and  xx.PARTY_SITE_ID 
3696  in (select /*+ parallel(yy)*/ yy.INSTALL_SITE_USE_ID from CSI_T_TXN_SYSTEMS
3697  yy 
3698 ));
3699 end if;
3700 --ASO_QUOTE_HEADERS_ALL;INVOICE_TO_PARTY_ID
3701 appid:=697;
3702  if(regid_proc = true) then 
3703 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3704 
3705  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3706  );
3707  else 
3708 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3709  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3710  );
3711 end if;
3712 --ASO_QUOTE_LINES_ALL;INVOICE_TO_PARTY_ID
3713 appid:=697;
3714  if(regid_proc = true) then 
3715 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3716 
3717  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3718  );
3719  else 
3720 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3721  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3722  );
3723 end if;
3724 --ASO_SHIPMENTS;SHIP_TO_PARTY_ID
3725 appid:=697;
3726  if(regid_proc = true) then 
3727 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3728 
3729  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from ASO_SHIPMENTS xx 
3730  );
3731  else 
3732 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3733  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from ASO_SHIPMENTS xx 
3734  );
3735 end if;
3736 --ASO_QUOTE_HEADERS_ALL;INVOICE_TO_PARTY_SITE_ID
3737 appid:=697;
3738  if(regid_proc = true) then 
3739 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3740 
3741  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3742  xx 
3743  where (nvl(STATUS, 'A') in ('A','I'))
3744  and  xx.PARTY_SITE_ID 
3745  in (select /*+ parallel(yy)*/ yy.INVOICE_TO_PARTY_SITE_ID from ASO_QUOTE_HEADERS_ALL
3746  yy 
3747 ));
3748  else 
3749 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3750  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3751  xx 
3752  where (nvl(STATUS, 'A') in ('A','I'))
3753  and  xx.PARTY_SITE_ID 
3754  in (select /*+ parallel(yy)*/ yy.INVOICE_TO_PARTY_SITE_ID from ASO_QUOTE_HEADERS_ALL
3755  yy 
3756 ));
3757 end if;
3758 --ASO_QUOTE_LINES_ALL;INVOICE_TO_PARTY_SITE_ID
3759 appid:=697;
3760  if(regid_proc = true) then 
3761 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3762 
3763  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3764  xx 
3765  where (nvl(STATUS, 'A') in ('A','I'))
3766  and  xx.PARTY_SITE_ID 
3767  in (select /*+ parallel(yy)*/ yy.INVOICE_TO_PARTY_SITE_ID from ASO_QUOTE_LINES_ALL
3768  yy 
3769 ));
3770  else 
3771 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3772  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3773  xx 
3774  where (nvl(STATUS, 'A') in ('A','I'))
3775  and  xx.PARTY_SITE_ID 
3776  in (select /*+ parallel(yy)*/ yy.INVOICE_TO_PARTY_SITE_ID from ASO_QUOTE_LINES_ALL
3777  yy 
3778 ));
3779 end if;
3780 --ASO_QUOTE_HEADERS_ALL;INVOICE_TO_CUST_PARTY_ID
3781 appid:=697;
3782  if(regid_proc = true) then 
3783 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3784 
3785  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_CUST_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3786  );
3787  else 
3788 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3789  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_CUST_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3790  );
3791 end if;
3792 --ASO_QUOTE_HEADERS_ALL;SOLD_TO_PARTY_SITE_ID
3793 appid:=697;
3794  if(regid_proc = true) then 
3795 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3796 
3797  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3798  xx 
3799  where (nvl(STATUS, 'A') in ('A','I'))
3800  and  xx.PARTY_SITE_ID 
3801  in (select /*+ parallel(yy)*/ yy.SOLD_TO_PARTY_SITE_ID from ASO_QUOTE_HEADERS_ALL
3802  yy 
3803 ));
3804  else 
3805 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3806  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3807  xx 
3808  where (nvl(STATUS, 'A') in ('A','I'))
3809  and  xx.PARTY_SITE_ID 
3810  in (select /*+ parallel(yy)*/ yy.SOLD_TO_PARTY_SITE_ID from ASO_QUOTE_HEADERS_ALL
3811  yy 
3812 ));
3813 end if;
3814 --ASO_QUOTE_LINES_ALL;INVOICE_TO_CUST_PARTY_ID
3815 appid:=697;
3816  if(regid_proc = true) then 
3817 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3818 
3819  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_CUST_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3820  );
3821  else 
3822 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3823  temp.party_id  in (select /*+ parallel(xx)*/ xx.INVOICE_TO_CUST_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3824  );
3825 end if;
3826 --ASO_SHIPMENTS;SHIP_TO_CUST_PARTY_ID
3827 appid:=697;
3828  if(regid_proc = true) then 
3829 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3830 
3831  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CUST_PARTY_ID from ASO_SHIPMENTS xx 
3832  );
3833  else 
3834 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3835  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CUST_PARTY_ID from ASO_SHIPMENTS xx 
3836  );
3837 end if;
3838 --ASO_QUOTE_HEADERS_ALL;END_CUSTOMER_PARTY_ID
3839 appid:=697;
3840  if(regid_proc = true) then 
3841 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3842 
3843  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3844  );
3845  else 
3846 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3847  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3848  );
3849 end if;
3850 --ASO_QUOTE_HEADERS_ALL;END_CUSTOMER_CUST_PARTY_ID
3851 appid:=697;
3852  if(regid_proc = true) then 
3853 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3854 
3855  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_CUST_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3856  );
3857  else 
3858 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3859  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_CUST_PARTY_ID from ASO_QUOTE_HEADERS_ALL xx 
3860  );
3861 end if;
3862 --ASO_QUOTE_HEADERS_ALL;END_CUSTOMER_PARTY_SITE_ID
3863 appid:=697;
3864  if(regid_proc = true) then 
3865 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3866 
3867  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3868  xx 
3869  where (nvl(STATUS, 'A') in ('A','I'))
3870  and  xx.PARTY_SITE_ID 
3871  in (select /*+ parallel(yy)*/ yy.END_CUSTOMER_PARTY_SITE_ID from ASO_QUOTE_HEADERS_ALL
3872  yy 
3873 ));
3874  else 
3875 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3876  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3877  xx 
3878  where (nvl(STATUS, 'A') in ('A','I'))
3879  and  xx.PARTY_SITE_ID 
3880  in (select /*+ parallel(yy)*/ yy.END_CUSTOMER_PARTY_SITE_ID from ASO_QUOTE_HEADERS_ALL
3881  yy 
3882 ));
3883 end if;
3884 --ASO_QUOTE_LINES_ALL;END_CUSTOMER_PARTY_ID
3885 appid:=697;
3886  if(regid_proc = true) then 
3887 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3888 
3889  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3890  );
3891  else 
3892 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3893  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3894  );
3895 end if;
3896 --ASO_QUOTE_LINES_ALL;END_CUSTOMER_CUST_PARTY_ID
3897 appid:=697;
3898  if(regid_proc = true) then 
3899 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3900 
3901  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_CUST_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3902  );
3903  else 
3904 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3905  temp.party_id  in (select /*+ parallel(xx)*/ xx.END_CUSTOMER_CUST_PARTY_ID from ASO_QUOTE_LINES_ALL xx 
3906  );
3907 end if;
3908 --ASO_QUOTE_LINES_ALL;END_CUSTOMER_PARTY_SITE_ID
3909 appid:=697;
3910  if(regid_proc = true) then 
3911 insert into hz_application_trans_gt(app_id,party_id) select 697, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 697 and appl.party_id=temp.party_id) and 
3912 
3913  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3914  xx 
3915  where (nvl(STATUS, 'A') in ('A','I'))
3916  and  xx.PARTY_SITE_ID 
3917  in (select /*+ parallel(yy)*/ yy.END_CUSTOMER_PARTY_SITE_ID from ASO_QUOTE_LINES_ALL
3918  yy 
3919 ));
3920  else 
3921 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3922  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
3923  xx 
3924  where (nvl(STATUS, 'A') in ('A','I'))
3925  and  xx.PARTY_SITE_ID 
3926  in (select /*+ parallel(yy)*/ yy.END_CUSTOMER_PARTY_SITE_ID from ASO_QUOTE_LINES_ALL
3927  yy 
3928 ));
3929 end if;
3930 --OKE_POOL_PARTIES;PARTY_ID
3931 appid:=777;
3932  if(regid_proc = true) then 
3933 insert into hz_application_trans_gt(app_id,party_id) select 777, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 777 and appl.party_id=temp.party_id) and 
3934 
3935  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from OKE_POOL_PARTIES xx 
3936  );
3937  else 
3938 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3939  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from OKE_POOL_PARTIES xx 
3940  );
3941 end if;
3942 --AHL_SUBSCRIPTIONS_B;REQUESTED_BY_PARTY_ID
3943 appid:=867;
3944  if(regid_proc = true) then 
3945 insert into hz_application_trans_gt(app_id,party_id) select 867, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 867 and appl.party_id=temp.party_id) and 
3946 
3947  temp.party_id  in (select /*+ parallel(xx)*/ xx.REQUESTED_BY_PARTY_ID from AHL_SUBSCRIPTIONS_B xx 
3948  );
3949  else 
3950 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3951  temp.party_id  in (select /*+ parallel(xx)*/ xx.REQUESTED_BY_PARTY_ID from AHL_SUBSCRIPTIONS_B xx 
3952  );
3953 end if;
3954 --AHL_SUBSCRIPTIONS_B;SUBSCRIBED_FRM_PARTY_ID
3955 appid:=867;
3956  if(regid_proc = true) then 
3957 insert into hz_application_trans_gt(app_id,party_id) select 867, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 867 and appl.party_id=temp.party_id) and 
3958 
3959  temp.party_id  in (select /*+ parallel(xx)*/ xx.SUBSCRIBED_FRM_PARTY_ID from AHL_SUBSCRIPTIONS_B xx 
3960  );
3961  else 
3962 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3963  temp.party_id  in (select /*+ parallel(xx)*/ xx.SUBSCRIBED_FRM_PARTY_ID from AHL_SUBSCRIPTIONS_B xx 
3964  );
3965 end if;
3966 --AHL_ROUTES_B;OPERATOR_PARTY_ID
3967 appid:=867;
3968  if(regid_proc = true) then 
3969 insert into hz_application_trans_gt(app_id,party_id) select 867, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 867 and appl.party_id=temp.party_id) and 
3970 
3971  temp.party_id  in (select /*+ parallel(xx)*/ xx.OPERATOR_PARTY_ID from AHL_ROUTES_B xx 
3972  );
3973  else 
3974 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3975  temp.party_id  in (select /*+ parallel(xx)*/ xx.OPERATOR_PARTY_ID from AHL_ROUTES_B xx 
3976  );
3977 end if;
3978 --AS_SALES_LEADS;INCUMBENT_PARTNER_PARTY_ID
3979 appid:=279;
3980  if(regid_proc = true) then 
3981 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
3982 
3983  temp.party_id  in (select /*+ parallel(xx)*/ xx.INCUMBENT_PARTNER_PARTY_ID from AS_SALES_LEADS xx 
3984  );
3985  else 
3986 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3987  temp.party_id  in (select /*+ parallel(xx)*/ xx.INCUMBENT_PARTNER_PARTY_ID from AS_SALES_LEADS xx 
3988  );
3989 end if;
3990 --AS_SALES_CREDITS_DENORM;CLOSE_COMPETITOR_ID
3991 appid:=279;
3992  if(regid_proc = true) then 
3993 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
3994 
3995  temp.party_id  in (select /*+ parallel(xx)*/ xx.CLOSE_COMPETITOR_ID from AS_SALES_CREDITS_DENORM xx 
3996  );
3997  else 
3998 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
3999  temp.party_id  in (select /*+ parallel(xx)*/ xx.CLOSE_COMPETITOR_ID from AS_SALES_CREDITS_DENORM xx 
4000  );
4001 end if;
4002 --AS_LEADS_LOG;CUSTOMER_ID
4003 appid:=279;
4004  if(regid_proc = true) then 
4005 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
4006 
4007  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from AS_LEADS_LOG xx 
4008  );
4009  else 
4010 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4011  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from AS_LEADS_LOG xx 
4012  );
4013 end if;
4014 --AS_LEADS_LOG;ADDRESS_ID
4015 appid:=279;
4016  if(regid_proc = true) then 
4017 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
4018 
4019  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4020  xx 
4021  where (nvl(STATUS, 'A') in ('A','I'))
4022  and  xx.PARTY_SITE_ID 
4023  in (select /*+ parallel(yy)*/ yy.ADDRESS_ID from AS_LEADS_LOG
4024  yy 
4025 ));
4026  else 
4027 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4028  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4029  xx 
4030  where (nvl(STATUS, 'A') in ('A','I'))
4031  and  xx.PARTY_SITE_ID 
4032  in (select /*+ parallel(yy)*/ yy.ADDRESS_ID from AS_LEADS_LOG
4033  yy 
4034 ));
4035 end if;
4036 --AS_LEADS_LOG;CLOSE_COMPETITOR_ID
4037 appid:=279;
4038  if(regid_proc = true) then 
4039 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
4040 
4041  temp.party_id  in (select /*+ parallel(xx)*/ xx.CLOSE_COMPETITOR_ID from AS_LEADS_LOG xx 
4042  );
4043  else 
4044 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4045  temp.party_id  in (select /*+ parallel(xx)*/ xx.CLOSE_COMPETITOR_ID from AS_LEADS_LOG xx 
4046  );
4047 end if;
4048 --AS_CURRENT_ENVIRONMENT;CUSTOMER_ID
4049 appid:=279;
4050  if(regid_proc = true) then 
4051 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
4052 
4053  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from AS_CURRENT_ENVIRONMENT xx 
4054  );
4055  else 
4056 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4057  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from AS_CURRENT_ENVIRONMENT xx 
4058  );
4059 end if;
4060 --AS_SALES_LEADS;REFERRED_BY
4061 appid:=279;
4062  if(regid_proc = true) then 
4063 insert into hz_application_trans_gt(app_id,party_id) select 279, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 279 and appl.party_id=temp.party_id) and 
4064 
4065  temp.party_id  in (select /*+ parallel(xx)*/ xx.REFERRED_BY from AS_SALES_LEADS xx 
4066  );
4067  else 
4068 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4069  temp.party_id  in (select /*+ parallel(xx)*/ xx.REFERRED_BY from AS_SALES_LEADS xx 
4070  );
4071 end if;
4072 --AMW_ASSESSMENTS_B;ASSESSMENT_OWNER_ID
4073 appid:=242;
4074  if(regid_proc = true) then 
4075 insert into hz_application_trans_gt(app_id,party_id) select 242, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 242 and appl.party_id=temp.party_id) and 
4076 
4077  temp.party_id  in (select /*+ parallel(xx)*/ xx.ASSESSMENT_OWNER_ID from AMW_ASSESSMENTS_B xx 
4078  );
4079  else 
4080 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4081  temp.party_id  in (select /*+ parallel(xx)*/ xx.ASSESSMENT_OWNER_ID from AMW_ASSESSMENTS_B xx 
4082  );
4083 end if;
4084 --AMW_AP_EXECUTIONS;EXECUTED_BY
4085 appid:=242;
4086  if(regid_proc = true) then 
4087 insert into hz_application_trans_gt(app_id,party_id) select 242, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 242 and appl.party_id=temp.party_id) and 
4088 
4089  temp.party_id  in (select /*+ parallel(xx)*/ xx.EXECUTED_BY from AMW_AP_EXECUTIONS xx 
4090  );
4091  else 
4092 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4093  temp.party_id  in (select /*+ parallel(xx)*/ xx.EXECUTED_BY from AMW_AP_EXECUTIONS xx 
4094  );
4095 end if;
4096 --AMW_CONSTRAINTS_B;ENTERED_BY_ID
4097 appid:=242;
4098  if(regid_proc = true) then 
4099 insert into hz_application_trans_gt(app_id,party_id) select 242, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 242 and appl.party_id=temp.party_id) and 
4100 
4101  temp.party_id  in (select /*+ parallel(xx)*/ xx.ENTERED_BY_ID from AMW_CONSTRAINTS_B xx 
4102  );
4103  else 
4104 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4105  temp.party_id  in (select /*+ parallel(xx)*/ xx.ENTERED_BY_ID from AMW_CONSTRAINTS_B xx 
4106  );
4107 end if;
4108 --AMW_VIOLATIONS;REQUESTED_BY_ID
4109 appid:=242;
4110  if(regid_proc = true) then 
4111 insert into hz_application_trans_gt(app_id,party_id) select 242, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 242 and appl.party_id=temp.party_id) and 
4112 
4113  temp.party_id  in (select /*+ parallel(xx)*/ xx.REQUESTED_BY_ID from AMW_VIOLATIONS xx 
4114  );
4115  else 
4116 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4117  temp.party_id  in (select /*+ parallel(xx)*/ xx.REQUESTED_BY_ID from AMW_VIOLATIONS xx 
4118  );
4119 end if;
4120 --AMW_CERTIFICATION_B;CERTIFICATION_OWNER_ID
4121 appid:=242;
4122  if(regid_proc = true) then 
4123 insert into hz_application_trans_gt(app_id,party_id) select 242, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 242 and appl.party_id=temp.party_id) and 
4124 
4125  temp.party_id  in (select /*+ parallel(xx)*/ xx.CERTIFICATION_OWNER_ID from AMW_CERTIFICATION_B xx 
4126  );
4127  else 
4128 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4129  temp.party_id  in (select /*+ parallel(xx)*/ xx.CERTIFICATION_OWNER_ID from AMW_CERTIFICATION_B xx 
4130  );
4131 end if;
4132 --JTF_PERZ_DATA_V;ATTRIBUTE_VALUE
4133 appid:=514;
4134  if(regid_proc = true) then 
4135 insert into hz_application_trans_gt(app_id,party_id) select 514, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 514 and appl.party_id=temp.party_id) and 
4136 
4137  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.ATTRIBUTE_VALUE from JTF_PERZ_DATA_V xx 
4138  where (attribute_name = 'customer ID' and application_id = 514 and perz_data_type in ('CSS_PROFILE_DEFECT_TEMPLATE','CSS_PROFILE_ENH_TEMPLATE') and profile_name like 'CSS_514%'));
4139  else 
4140 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4141  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.ATTRIBUTE_VALUE from JTF_PERZ_DATA_V xx 
4142  where (attribute_name = 'customer ID' and application_id = 514 and perz_data_type in ('CSS_PROFILE_DEFECT_TEMPLATE','CSS_PROFILE_ENH_TEMPLATE') and profile_name like 'CSS_514%'));
4143 end if;
4144 --JTF_PERZ_QUERY_PARAM_V;PARAMETER_VALUE
4145 appid:=514;
4146  if(regid_proc = true) then 
4147 insert into hz_application_trans_gt(app_id,party_id) select 514, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 514 and appl.party_id=temp.party_id) and 
4148 
4149  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.PARAMETER_VALUE from JTF_PERZ_QUERY_PARAM_V xx 
4150  where (parameter_name in ('CUSTOMER_ID','SR_CUSTOMER_ID') and application_id = 514 and query_type like 'ADV_SEARCH_%' and profile_name like 'CSS_514%' ));
4151  else 
4152 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4153  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.PARAMETER_VALUE from JTF_PERZ_QUERY_PARAM_V xx 
4154  where (parameter_name in ('CUSTOMER_ID','SR_CUSTOMER_ID') and application_id = 514 and query_type like 'ADV_SEARCH_%' and profile_name like 'CSS_514%' ));
4155 end if;
4156 --PON_SUPPLIER_ACTIVITIES;TRADING_PARTNER_ID
4157 appid:=396;
4158  if(regid_proc = true) then 
4159 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4160 
4161  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_SUPPLIER_ACTIVITIES xx 
4162  );
4163  else 
4164 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4165  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_SUPPLIER_ACTIVITIES xx 
4166  );
4167 end if;
4168 --PON_SUPPLIER_ACCESS;SUPPLIER_TRADING_PARTNER_ID
4169 appid:=396;
4170  if(regid_proc = true) then 
4171 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4172 
4173  temp.party_id  in (select /*+ parallel(xx)*/ xx.SUPPLIER_TRADING_PARTNER_ID from PON_SUPPLIER_ACCESS xx 
4174  );
4175  else 
4176 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4177  temp.party_id  in (select /*+ parallel(xx)*/ xx.SUPPLIER_TRADING_PARTNER_ID from PON_SUPPLIER_ACCESS xx 
4178  );
4179 end if;
4180 --PON_PARTY_LINE_EXCLUSIONS;TRADING_PARTNER_ID
4181 appid:=396;
4182  if(regid_proc = true) then 
4183 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4184 
4185  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_PARTY_LINE_EXCLUSIONS xx 
4186  );
4187  else 
4188 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4189  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_PARTY_LINE_EXCLUSIONS xx 
4190  );
4191 end if;
4192 --PON_PF_SUPPLIER_FORMULA;TRADING_PARTNER_ID
4193 appid:=396;
4194  if(regid_proc = true) then 
4195 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4196 
4197  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_PF_SUPPLIER_FORMULA xx 
4198  );
4199  else 
4200 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4201  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_PF_SUPPLIER_FORMULA xx 
4202  );
4203 end if;
4204 --PON_BID_HEADERS;SURROG_BID_CREATED_TP_ID
4205 appid:=396;
4206  if(regid_proc = true) then 
4207 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4208 
4209  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_CREATED_TP_ID from PON_BID_HEADERS xx 
4210  );
4211  else 
4212 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4213  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_CREATED_TP_ID from PON_BID_HEADERS xx 
4214  );
4215 end if;
4216 --PON_CONTRACTS;AUTHORING_PARTY_CONTACT_ID
4217 appid:=396;
4218  if(regid_proc = true) then 
4219 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4220 
4221  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTHORING_PARTY_CONTACT_ID from PON_CONTRACTS xx 
4222  );
4223  else 
4224 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4225  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTHORING_PARTY_CONTACT_ID from PON_CONTRACTS xx 
4226  );
4227 end if;
4228 --PON_CONTRACTS;AUTHORING_PARTY_ID
4229 appid:=396;
4230  if(regid_proc = true) then 
4231 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4232 
4233  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTHORING_PARTY_ID from PON_CONTRACTS xx 
4234  );
4235  else 
4236 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4237  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTHORING_PARTY_ID from PON_CONTRACTS xx 
4238  );
4239 end if;
4240 --PON_THREADS;OWNER_PARTY_ID
4241 appid:=396;
4242  if(regid_proc = true) then 
4243 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4244 
4245  temp.party_id  in (select /*+ parallel(xx)*/ xx.OWNER_PARTY_ID from PON_THREADS xx 
4246  );
4247  else 
4248 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4249  temp.party_id  in (select /*+ parallel(xx)*/ xx.OWNER_PARTY_ID from PON_THREADS xx 
4250  );
4251 end if;
4252 --PON_THREAD_ENTRIES;FROM_ID
4253 appid:=396;
4254  if(regid_proc = true) then 
4255 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4256 
4257  temp.party_id  in (select /*+ parallel(xx)*/ xx.FROM_ID from PON_THREAD_ENTRIES xx 
4258  );
4259  else 
4260 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4261  temp.party_id  in (select /*+ parallel(xx)*/ xx.FROM_ID from PON_THREAD_ENTRIES xx 
4262  );
4263 end if;
4264 --PON_THREAD_ENTRIES;FROM_COMPANY_ID
4265 appid:=396;
4266  if(regid_proc = true) then 
4267 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4268 
4269  temp.party_id  in (select /*+ parallel(xx)*/ xx.FROM_COMPANY_ID from PON_THREAD_ENTRIES xx 
4270  );
4271  else 
4272 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4273  temp.party_id  in (select /*+ parallel(xx)*/ xx.FROM_COMPANY_ID from PON_THREAD_ENTRIES xx 
4274  );
4275 end if;
4276 --PON_TE_RECIPIENTS;TO_COMPANY_ID
4277 appid:=396;
4278  if(regid_proc = true) then 
4279 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4280 
4281  temp.party_id  in (select /*+ parallel(xx)*/ xx.TO_COMPANY_ID from PON_TE_RECIPIENTS xx 
4282  );
4283  else 
4284 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4285  temp.party_id  in (select /*+ parallel(xx)*/ xx.TO_COMPANY_ID from PON_TE_RECIPIENTS xx 
4286  );
4287 end if;
4288 --PON_ACKNOWLEDGEMENTS;SURROG_BID_ACK_CONTACT_ID
4289 appid:=396;
4290  if(regid_proc = true) then 
4291 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4292 
4293  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_ACK_CONTACT_ID from PON_ACKNOWLEDGEMENTS xx 
4294  );
4295  else 
4296 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4297  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_ACK_CONTACT_ID from PON_ACKNOWLEDGEMENTS xx 
4298  );
4299 end if;
4300 --PON_ACKNOWLEDGEMENTS;SURROG_BID_ACK_TP_ID
4301 appid:=396;
4302  if(regid_proc = true) then 
4303 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4304 
4305  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_ACK_TP_ID from PON_ACKNOWLEDGEMENTS xx 
4306  );
4307  else 
4308 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4309  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_ACK_TP_ID from PON_ACKNOWLEDGEMENTS xx 
4310  );
4311 end if;
4312 --PON_SUPPLIER_ACCESS;BUYER_TP_CONTACT_ID
4313 appid:=396;
4314  if(regid_proc = true) then 
4315 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4316 
4317  temp.party_id  in (select /*+ parallel(xx)*/ xx.BUYER_TP_CONTACT_ID from PON_SUPPLIER_ACCESS xx 
4318  );
4319  else 
4320 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4321  temp.party_id  in (select /*+ parallel(xx)*/ xx.BUYER_TP_CONTACT_ID from PON_SUPPLIER_ACCESS xx 
4322  );
4323 end if;
4324 --PON_BIDDING_PARTIES;TRADING_PARTNER_CONTACT_ID
4325 appid:=396;
4326  if(regid_proc = true) then 
4327 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4328 
4329  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_BIDDING_PARTIES xx 
4330  );
4331  else 
4332 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4333  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_BIDDING_PARTIES xx 
4334  );
4335 end if;
4336 --PON_BIDDING_PARTIES;ACK_PARTNER_CONTACT_ID
4337 appid:=396;
4338  if(regid_proc = true) then 
4339 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4340 
4341  temp.party_id  in (select /*+ parallel(xx)*/ xx.ACK_PARTNER_CONTACT_ID from PON_BIDDING_PARTIES xx 
4342  );
4343  else 
4344 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4345  temp.party_id  in (select /*+ parallel(xx)*/ xx.ACK_PARTNER_CONTACT_ID from PON_BIDDING_PARTIES xx 
4346  );
4347 end if;
4348 --PON_OPTIMIZE_CONSTRAINTS;TRADING_PARTNER_CONTACT_ID
4349 appid:=396;
4350  if(regid_proc = true) then 
4351 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4352 
4353  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_OPTIMIZE_CONSTRAINTS xx 
4354  );
4355  else 
4356 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4357  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_OPTIMIZE_CONSTRAINTS xx 
4358  );
4359 end if;
4360 --PON_OPTIMIZE_CONSTRAINTS;TRADING_PARTNER_ID
4361 appid:=396;
4362  if(regid_proc = true) then 
4363 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4364 
4365  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_OPTIMIZE_CONSTRAINTS xx 
4366  );
4367  else 
4368 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4369  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_OPTIMIZE_CONSTRAINTS xx 
4370  );
4371 end if;
4372 --PON_ACKNOWLEDGEMENTS;TRADING_PARTNER_CONTACT_ID
4373 appid:=396;
4374  if(regid_proc = true) then 
4375 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4376 
4377  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_ACKNOWLEDGEMENTS xx 
4378  );
4379  else 
4380 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4381  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_ACKNOWLEDGEMENTS xx 
4382  );
4383 end if;
4384 --PON_ACKNOWLEDGEMENTS;TRADING_PARTNER_ID
4385 appid:=396;
4386  if(regid_proc = true) then 
4387 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4388 
4389  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_ACKNOWLEDGEMENTS xx 
4390  );
4391  else 
4392 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4393  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_ACKNOWLEDGEMENTS xx 
4394  );
4395 end if;
4396 --PON_AUCTION_SUMMARY;TRADING_PARTNER_CONTACT_ID
4397 appid:=396;
4398  if(regid_proc = true) then 
4399 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4400 
4401  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_AUCTION_SUMMARY xx 
4402  );
4403  else 
4404 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4405  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_AUCTION_SUMMARY xx 
4406  );
4407 end if;
4408 --PON_AUCTION_SUMMARY;TRADING_PARTNER_ID
4409 appid:=396;
4410  if(regid_proc = true) then 
4411 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4412 
4413  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_AUCTION_SUMMARY xx 
4414  );
4415  else 
4416 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4417  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_ID from PON_AUCTION_SUMMARY xx 
4418  );
4419 end if;
4420 --PON_SUPPLIER_ACTIVITIES;TRADING_PARTNER_CONTACT_ID
4421 appid:=396;
4422  if(regid_proc = true) then 
4423 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4424 
4425  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_SUPPLIER_ACTIVITIES xx 
4426  );
4427  else 
4428 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4429  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_SUPPLIER_ACTIVITIES xx 
4430  );
4431 end if;
4432 --PON_AUCTION_HEADERS_ALL;DRAFT_LOCKED_BY_CONTACT_ID
4433 appid:=396;
4434  if(regid_proc = true) then 
4435 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4436 
4437  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_LOCKED_BY_CONTACT_ID from PON_AUCTION_HEADERS_ALL xx 
4438  );
4439  else 
4440 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4441  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_LOCKED_BY_CONTACT_ID from PON_AUCTION_HEADERS_ALL xx 
4442  );
4443 end if;
4444 --PON_AUCTION_HEADERS_ALL;DRAFT_UNLOCKED_BY_CONTACT_ID
4445 appid:=396;
4446  if(regid_proc = true) then 
4447 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4448 
4449  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_UNLOCKED_BY_CONTACT_ID from PON_AUCTION_HEADERS_ALL xx 
4450  );
4451  else 
4452 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4453  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_UNLOCKED_BY_CONTACT_ID from PON_AUCTION_HEADERS_ALL xx 
4454  );
4455 end if;
4456 --PON_AUCTION_HEADERS_ALL;SCORING_LOCK_TP_CONTACT_ID
4457 appid:=396;
4458  if(regid_proc = true) then 
4459 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4460 
4461  temp.party_id  in (select /*+ parallel(xx)*/ xx.SCORING_LOCK_TP_CONTACT_ID from PON_AUCTION_HEADERS_ALL xx 
4462  );
4463  else 
4464 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4465  temp.party_id  in (select /*+ parallel(xx)*/ xx.SCORING_LOCK_TP_CONTACT_ID from PON_AUCTION_HEADERS_ALL xx 
4466  );
4467 end if;
4468 --PON_AUCTION_EVENTS;TRADING_PARTNER_CONTACT_ID
4469 appid:=396;
4470  if(regid_proc = true) then 
4471 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4472 
4473  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_AUCTION_EVENTS xx 
4474  );
4475  else 
4476 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4477  temp.party_id  in (select /*+ parallel(xx)*/ xx.TRADING_PARTNER_CONTACT_ID from PON_AUCTION_EVENTS xx 
4478  );
4479 end if;
4480 --PON_BID_HEADERS;SURROG_BID_CREATED_CONTACT_ID
4481 appid:=396;
4482  if(regid_proc = true) then 
4483 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4484 
4485  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_CREATED_CONTACT_ID from PON_BID_HEADERS xx 
4486  );
4487  else 
4488 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4489  temp.party_id  in (select /*+ parallel(xx)*/ xx.SURROG_BID_CREATED_CONTACT_ID from PON_BID_HEADERS xx 
4490  );
4491 end if;
4492 --PON_BID_HEADERS;SCORE_OVERRIDE_TP_CONTACT_ID
4493 appid:=396;
4494  if(regid_proc = true) then 
4495 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4496 
4497  temp.party_id  in (select /*+ parallel(xx)*/ xx.SCORE_OVERRIDE_TP_CONTACT_ID from PON_BID_HEADERS xx 
4498  );
4499  else 
4500 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4501  temp.party_id  in (select /*+ parallel(xx)*/ xx.SCORE_OVERRIDE_TP_CONTACT_ID from PON_BID_HEADERS xx 
4502  );
4503 end if;
4504 --PON_BID_HEADERS;SHORTLIST_TPC_ID
4505 appid:=396;
4506  if(regid_proc = true) then 
4507 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4508 
4509  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHORTLIST_TPC_ID from PON_BID_HEADERS xx 
4510  );
4511  else 
4512 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4513  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHORTLIST_TPC_ID from PON_BID_HEADERS xx 
4514  );
4515 end if;
4516 --PON_BID_HEADERS;DRAFT_UNLOCKED_BY_CONTACT_ID
4517 appid:=396;
4518  if(regid_proc = true) then 
4519 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4520 
4521  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_UNLOCKED_BY_CONTACT_ID from PON_BID_HEADERS xx 
4522  );
4523  else 
4524 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4525  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_UNLOCKED_BY_CONTACT_ID from PON_BID_HEADERS xx 
4526  );
4527 end if;
4528 --PON_BID_HEADERS;DRAFT_LOCKED_BY_CONTACT_ID
4529 appid:=396;
4530  if(regid_proc = true) then 
4531 insert into hz_application_trans_gt(app_id,party_id) select 396, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 396 and appl.party_id=temp.party_id) and 
4532 
4533  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_LOCKED_BY_CONTACT_ID from PON_BID_HEADERS xx 
4534  );
4535  else 
4536 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4537  temp.party_id  in (select /*+ parallel(xx)*/ xx.DRAFT_LOCKED_BY_CONTACT_ID from PON_BID_HEADERS xx 
4538  );
4539 end if;
4540 --OKL_INS_POLICIES_B;INT_ID
4541 appid:=540;
4542  if(regid_proc = true) then 
4543 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4544 
4545  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.INT_ID from OKL_INS_POLICIES_B xx 
4546  where (IPY_TYPE = 'THIRD_PARTY_POLICY'));
4547  else 
4548 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4549  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.INT_ID from OKL_INS_POLICIES_B xx 
4550  where (IPY_TYPE = 'THIRD_PARTY_POLICY'));
4551 end if;
4552 --OKL_INS_POLICIES_B;AGENT_SITE_ID
4553 appid:=540;
4554  if(regid_proc = true) then 
4555 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4556 
4557  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4558  xx 
4559  where (nvl(STATUS, 'A') in ('A','I'))
4560  and  to_char(xx.PARTY_SITE_ID)
4561  in (select /*+ parallel(yy)*/ yy.AGENT_SITE_ID from OKL_INS_POLICIES_B
4562  yy 
4563  where IPY_TYPE = 'THIRD_PARTY_POLICY'));
4564  else 
4565 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4566  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4567  xx 
4568  where (nvl(STATUS, 'A') in ('A','I'))
4569  and  to_char(xx.PARTY_SITE_ID)
4570  in (select /*+ parallel(yy)*/ yy.AGENT_SITE_ID from OKL_INS_POLICIES_B
4571  yy 
4572  where IPY_TYPE = 'THIRD_PARTY_POLICY'));
4573 end if;
4574 --OKL_INS_POLICIES_B;AGENCY_SITE_ID
4575 appid:=540;
4576  if(regid_proc = true) then 
4577 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4578 
4579  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4580  xx 
4581  where (nvl(STATUS, 'A') in ('A','I'))
4582  and  xx.PARTY_SITE_ID 
4583  in (select /*+ parallel(yy)*/ yy.AGENCY_SITE_ID from OKL_INS_POLICIES_B
4584  yy 
4585  where IPY_TYPE = 'THIRD_PARTY_POLICY'));
4586  else 
4587 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4588  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4589  xx 
4590  where (nvl(STATUS, 'A') in ('A','I'))
4591  and  xx.PARTY_SITE_ID 
4592  in (select /*+ parallel(yy)*/ yy.AGENCY_SITE_ID from OKL_INS_POLICIES_B
4593  yy 
4594  where IPY_TYPE = 'THIRD_PARTY_POLICY'));
4595 end if;
4596 --OKL_INS_POLICIES_B;AGENCY_SITE_ID
4597 appid:=540;
4598  if(regid_proc = true) then 
4599 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4600 
4601  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4602  xx 
4603  where (nvl(STATUS, 'A') in ('A','I'))
4604  and  xx.PARTY_SITE_ID 
4605  in (select /*+ parallel(yy)*/ yy.AGENCY_SITE_ID from OKL_INS_POLICIES_B
4606  yy 
4607  where IPY_TYPE = 'THIRD_PARTY_POLICY'));
4608  else 
4609 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4610  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4611  xx 
4612  where (nvl(STATUS, 'A') in ('A','I'))
4613  and  xx.PARTY_SITE_ID 
4614  in (select /*+ parallel(yy)*/ yy.AGENCY_SITE_ID from OKL_INS_POLICIES_B
4615  yy 
4616  where IPY_TYPE = 'THIRD_PARTY_POLICY'));
4617 end if;
4618 --OKL_INS_POLICIES_B;ISU_ID
4619 appid:=540;
4620  if(regid_proc = true) then 
4621 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4622 
4623  temp.party_id  in (select /*+ parallel(xx)*/ xx.ISU_ID from OKL_INS_POLICIES_B xx 
4624  where (IPY_TYPE = 'THIRD_PARTY_POLICY'));
4625  else 
4626 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4627  temp.party_id  in (select /*+ parallel(xx)*/ xx.ISU_ID from OKL_INS_POLICIES_B xx 
4628  where (IPY_TYPE = 'THIRD_PARTY_POLICY'));
4629 end if;
4630 --OKL_EXT_SELL_INVS_B;CUSTOMER_ID
4631 appid:=540;
4632  if(regid_proc = true) then 
4633 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4634 
4635  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from OKL_EXT_SELL_INVS_B xx 
4636  );
4637  else 
4638 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4639  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from OKL_EXT_SELL_INVS_B xx 
4640  );
4641 end if;
4642 --OKL_OPEN_INT;PARTY_ID
4643 appid:=540;
4644  if(regid_proc = true) then 
4645 insert into hz_application_trans_gt(app_id,party_id) select 540, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 540 and appl.party_id=temp.party_id) and 
4646 
4647  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from OKL_OPEN_INT xx 
4648  );
4649  else 
4650 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4651  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from OKL_OPEN_INT xx 
4652  );
4653 end if;
4654 --AMS_IBA_PL_SITES_B;SITE_CATEGORY_OBJECT_ID
4655 appid:=530;
4656  if(regid_proc = true) then 
4657 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4658 
4659  temp.party_id  in (select /*+ parallel(xx)*/ xx.SITE_CATEGORY_OBJECT_ID from AMS_IBA_PL_SITES_B xx 
4660  where (SITE_CATEGORY_TYPE = 'AFFILIATES'));
4661  else 
4662 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4663  temp.party_id  in (select /*+ parallel(xx)*/ xx.SITE_CATEGORY_OBJECT_ID from AMS_IBA_PL_SITES_B xx 
4664  where (SITE_CATEGORY_TYPE = 'AFFILIATES'));
4665 end if;
4666 --AMS_PARTY_MARKET_SEGMENTS;PARTY_ID
4667 appid:=530;
4668  if(regid_proc = true) then 
4669 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4670 
4671  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_PARTY_MARKET_SEGMENTS xx 
4672  );
4673  else 
4674 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4675  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_PARTY_MARKET_SEGMENTS xx 
4676  );
4677 end if;
4678 --AMS_AGENDAS_B;COORDINATOR_ID
4679 appid:=530;
4680  if(regid_proc = true) then 
4681 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4682 
4683  temp.party_id  in (select /*+ parallel(xx)*/ xx.COORDINATOR_ID from AMS_AGENDAS_B xx 
4684  );
4685  else 
4686 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4687  temp.party_id  in (select /*+ parallel(xx)*/ xx.COORDINATOR_ID from AMS_AGENDAS_B xx 
4688  );
4689 end if;
4690 --AMS_TCOP_CHANNEL_SUMMARY;PARTY_ID
4691 appid:=530;
4692  if(regid_proc = true) then 
4693 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4694 
4695  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_CHANNEL_SUMMARY xx 
4696  );
4697  else 
4698 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4699  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_CHANNEL_SUMMARY xx 
4700  );
4701 end if;
4702 --AMS_TCOP_CONTACTS;PARTY_ID
4703 appid:=530;
4704  if(regid_proc = true) then 
4705 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4706 
4707  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_CONTACTS xx 
4708  );
4709  else 
4710 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4711  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_CONTACTS xx 
4712  );
4713 end if;
4714 --AMS_TCOP_PRVW_CONTACTS;PARTY_ID
4715 appid:=530;
4716  if(regid_proc = true) then 
4717 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4718 
4719  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_PRVW_CONTACTS xx 
4720  );
4721  else 
4722 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4723  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_PRVW_CONTACTS xx 
4724  );
4725 end if;
4726 --AMS_TCOP_PRVW_FTG_DTLS;PARTY_ID
4727 appid:=530;
4728  if(regid_proc = true) then 
4729 insert into hz_application_trans_gt(app_id,party_id) select 530, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 530 and appl.party_id=temp.party_id) and 
4730 
4731  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_PRVW_FTG_DTLS xx 
4732  );
4733  else 
4734 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4735  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from AMS_TCOP_PRVW_FTG_DTLS xx 
4736  );
4737 end if;
4738 --CSC_CUST_PLANS;PARTY_ID
4739 appid:=511;
4740  if(regid_proc = true) then 
4741 insert into hz_application_trans_gt(app_id,party_id) select 511, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 511 and appl.party_id=temp.party_id) and 
4742 
4743  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from CSC_CUST_PLANS xx 
4744  );
4745  else 
4746 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4747  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from CSC_CUST_PLANS xx 
4748  );
4749 end if;
4750 --ISC_DR_REPAIR_ORDERS_F;CUSTOMER_ID
4751 appid:=454;
4752  if(regid_proc = true) then 
4753 insert into hz_application_trans_gt(app_id,party_id) select 454, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 454 and appl.party_id=temp.party_id) and 
4754 
4755  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from ISC_DR_REPAIR_ORDERS_F xx 
4756  );
4757  else 
4758 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4759  temp.party_id  in (select /*+ parallel(xx)*/ xx.CUSTOMER_ID from ISC_DR_REPAIR_ORDERS_F xx 
4760  );
4761 end if;
4762 --FTE_LOCATION_PARAMETERS;FACILITY_CONTACT_ID
4763 appid:=716;
4764  if(regid_proc = true) then 
4765 insert into hz_application_trans_gt(app_id,party_id) select 716, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 716 and appl.party_id=temp.party_id) and 
4766 
4767  temp.party_id  in (select /*+ parallel(xx)*/ xx.FACILITY_CONTACT_ID from FTE_LOCATION_PARAMETERS xx 
4768  );
4769  else 
4770 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4771  temp.party_id  in (select /*+ parallel(xx)*/ xx.FACILITY_CONTACT_ID from FTE_LOCATION_PARAMETERS xx 
4772  );
4773 end if;
4774 --FEM_PARTY_PROFITABILITY;PARTY_ID
4775 appid:=272;
4776  if(regid_proc = true) then 
4777 insert into hz_application_trans_gt(app_id,party_id) select 272, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 272 and appl.party_id=temp.party_id) and 
4778 
4779  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from FEM_PARTY_PROFITABILITY xx 
4780  );
4781  else 
4782 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4783  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from FEM_PARTY_PROFITABILITY xx 
4784  );
4785 end if;
4786 --JTF_FM_PROCESSED_V;PARTY_ID
4787 appid:=690;
4788  if(regid_proc = true) then 
4789 insert into hz_application_trans_gt(app_id,party_id) select 690, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 690 and appl.party_id=temp.party_id) and 
4790 
4791  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from JTF_FM_PROCESSED_V xx 
4792  );
4793  else 
4794 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4795  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from JTF_FM_PROCESSED_V xx 
4796  );
4797 end if;
4798 --JTF_FM_CONTENT_HISTORY_V;PARTY_ID
4799 appid:=690;
4800  if(regid_proc = true) then 
4801 insert into hz_application_trans_gt(app_id,party_id) select 690, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 690 and appl.party_id=temp.party_id) and 
4802 
4803  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from JTF_FM_CONTENT_HISTORY_V xx 
4804  );
4805  else 
4806 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4807  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from JTF_FM_CONTENT_HISTORY_V xx 
4808  );
4809 end if;
4810 --JTF_TTY_NAMED_ACCTS;PARTY_SITE_ID
4811 appid:=690;
4812  if(regid_proc = true) then 
4813 insert into hz_application_trans_gt(app_id,party_id) select 690, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 690 and appl.party_id=temp.party_id) and 
4814 
4815  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4816  xx 
4817  where (nvl(STATUS, 'A') in ('A','I'))
4818  and  xx.PARTY_SITE_ID 
4819  in (select /*+ parallel(yy)*/ yy.PARTY_SITE_ID from JTF_TTY_NAMED_ACCTS
4820  yy 
4821 ));
4822  else 
4823 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4824  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4825  xx 
4826  where (nvl(STATUS, 'A') in ('A','I'))
4827  and  xx.PARTY_SITE_ID 
4828  in (select /*+ parallel(yy)*/ yy.PARTY_SITE_ID from JTF_TTY_NAMED_ACCTS
4829  yy 
4830 ));
4831 end if;
4832 --OKS_QUALIFIERS;QUALIFIER_ATTR_VALUE
4833 appid:=515;
4834  if(regid_proc = true) then 
4835 insert into hz_application_trans_gt(app_id,party_id) select 515, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 515 and appl.party_id=temp.party_id) and 
4836 
4837  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.QUALIFIER_ATTR_VALUE from OKS_QUALIFIERS xx 
4838  where ((qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE1'  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute ='QUALIFIER_ATTRIBUTE16'  OR qualifier_context = 'CUSTOMER_GROUP' AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE3'  OR qualifier_context = 'PARTY' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE1', 'QUALIFIER_ATTRIBUTE2'))));
4839  else 
4840 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4841  to_char(temp.party_id)  in (select /*+ parallel(xx)*/ xx.QUALIFIER_ATTR_VALUE from OKS_QUALIFIERS xx 
4842  where ((qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE1'  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute ='QUALIFIER_ATTRIBUTE16'  OR qualifier_context = 'CUSTOMER_GROUP' AND qualifier_attribute = 'QUALIFIER_ATTRIBUTE3'  OR qualifier_context = 'PARTY' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE1', 'QUALIFIER_ATTRIBUTE2'))));
4843 end if;
4844 --OKS_QUALIFIERS;QUALIFIER_ATTR_VALUE
4845 appid:=515;
4846  if(regid_proc = true) then 
4847 insert into hz_application_trans_gt(app_id,party_id) select 515, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 515 and appl.party_id=temp.party_id) and 
4848 
4849  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4850  xx 
4851  where (nvl(STATUS, 'A') in ('A','I'))
4852  and  to_char(xx.PARTY_SITE_ID)
4853  in (select /*+ parallel(yy)*/ yy.QUALIFIER_ATTR_VALUE from OKS_QUALIFIERS
4854  yy 
4855  where (qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE10','QUALIFIER_ATTRIBUTE11')  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE17', 'QUALIFIER_ATTRIBUTE18'))));
4856  else 
4857 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4858  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4859  xx 
4860  where (nvl(STATUS, 'A') in ('A','I'))
4861  and  to_char(xx.PARTY_SITE_ID)
4862  in (select /*+ parallel(yy)*/ yy.QUALIFIER_ATTR_VALUE from OKS_QUALIFIERS
4863  yy 
4864  where (qualifier_context = 'ASOPARTYINFO'  AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE10','QUALIFIER_ATTRIBUTE11')  OR qualifier_context = 'CUSTOMER' AND qualifier_attribute IN ('QUALIFIER_ATTRIBUTE17', 'QUALIFIER_ATTRIBUTE18'))));
4865 end if;
4866 --CS_ESTIMATE_DETAILS;BILL_TO_PARTY_ID
4867 appid:=170;
4868  if(regid_proc = true) then 
4869 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4870 
4871  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from CS_ESTIMATE_DETAILS xx 
4872  );
4873  else 
4874 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4875  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from CS_ESTIMATE_DETAILS xx 
4876  );
4877 end if;
4878 --CS_ESTIMATE_DETAILS;SHIP_TO_PARTY_ID
4879 appid:=170;
4880  if(regid_proc = true) then 
4881 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4882 
4883  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from CS_ESTIMATE_DETAILS xx 
4884  );
4885  else 
4886 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4887  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from CS_ESTIMATE_DETAILS xx 
4888  );
4889 end if;
4890 --CS_INCIDENTS_ALL_B;SITE_ID
4891 appid:=170;
4892  if(regid_proc = true) then 
4893 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4894 
4895  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4896  xx 
4897  where (nvl(STATUS, 'A') in ('A','I'))
4898  and  xx.PARTY_SITE_ID 
4899  in (select /*+ parallel(yy)*/ yy.SITE_ID from CS_INCIDENTS_ALL_B
4900  yy 
4901 ));
4902  else 
4903 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4904  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4905  xx 
4906  where (nvl(STATUS, 'A') in ('A','I'))
4907  and  xx.PARTY_SITE_ID 
4908  in (select /*+ parallel(yy)*/ yy.SITE_ID from CS_INCIDENTS_ALL_B
4909  yy 
4910 ));
4911 end if;
4912 --CS_INCIDENTS_AUDIT_B;SITE_ID
4913 appid:=170;
4914  if(regid_proc = true) then 
4915 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4916 
4917  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4918  xx 
4919  where (nvl(STATUS, 'A') in ('A','I'))
4920  and  xx.PARTY_SITE_ID 
4921  in (select /*+ parallel(yy)*/ yy.SITE_ID from CS_INCIDENTS_AUDIT_B
4922  yy 
4923 ));
4924  else 
4925 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4926  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4927  xx 
4928  where (nvl(STATUS, 'A') in ('A','I'))
4929  and  xx.PARTY_SITE_ID 
4930  in (select /*+ parallel(yy)*/ yy.SITE_ID from CS_INCIDENTS_AUDIT_B
4931  yy 
4932 ));
4933 end if;
4934 --CS_INCIDENTS_ALL_B;BILL_TO_SITE_ID
4935 appid:=170;
4936  if(regid_proc = true) then 
4937 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4938 
4939  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4940  xx 
4941  where (nvl(STATUS, 'A') in ('A','I'))
4942  and  xx.PARTY_SITE_ID 
4943  in (select /*+ parallel(yy)*/ yy.BILL_TO_SITE_ID from CS_INCIDENTS_ALL_B
4944  yy 
4945 ));
4946  else 
4947 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4948  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4949  xx 
4950  where (nvl(STATUS, 'A') in ('A','I'))
4951  and  xx.PARTY_SITE_ID 
4952  in (select /*+ parallel(yy)*/ yy.BILL_TO_SITE_ID from CS_INCIDENTS_ALL_B
4953  yy 
4954 ));
4955 end if;
4956 --CS_INCIDENTS_ALL_B;SHIP_TO_SITE_ID
4957 appid:=170;
4958  if(regid_proc = true) then 
4959 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4960 
4961  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4962  xx 
4963  where (nvl(STATUS, 'A') in ('A','I'))
4964  and  xx.PARTY_SITE_ID 
4965  in (select /*+ parallel(yy)*/ yy.SHIP_TO_SITE_ID from CS_INCIDENTS_ALL_B
4966  yy 
4967 ));
4968  else 
4969 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4970  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4971  xx 
4972  where (nvl(STATUS, 'A') in ('A','I'))
4973  and  xx.PARTY_SITE_ID 
4974  in (select /*+ parallel(yy)*/ yy.SHIP_TO_SITE_ID from CS_INCIDENTS_ALL_B
4975  yy 
4976 ));
4977 end if;
4978 --CS_INCIDENTS_ALL_B;INSTALL_SITE_ID
4979 appid:=170;
4980  if(regid_proc = true) then 
4981 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
4982 
4983  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4984  xx 
4985  where (nvl(STATUS, 'A') in ('A','I'))
4986  and  xx.PARTY_SITE_ID 
4987  in (select /*+ parallel(yy)*/ yy.INSTALL_SITE_ID from CS_INCIDENTS_ALL_B
4988  yy 
4989 ));
4990  else 
4991 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
4992  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
4993  xx 
4994  where (nvl(STATUS, 'A') in ('A','I'))
4995  and  xx.PARTY_SITE_ID 
4996  in (select /*+ parallel(yy)*/ yy.INSTALL_SITE_ID from CS_INCIDENTS_ALL_B
4997  yy 
4998 ));
4999 end if;
5000 --CS_INCIDENTS_AUDIT_B;BILL_TO_CONTACT_ID
5001 appid:=170;
5002  if(regid_proc = true) then 
5003 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5004 
5005  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_ID from CS_INCIDENTS_AUDIT_B xx 
5006  );
5007  else 
5008 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5009  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_ID from CS_INCIDENTS_AUDIT_B xx 
5010  );
5011 end if;
5012 --CS_INCIDENTS_ALL_B;BILL_TO_PARTY_ID
5013 appid:=170;
5014  if(regid_proc = true) then 
5015 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5016 
5017  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from CS_INCIDENTS_ALL_B xx 
5018  );
5019  else 
5020 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5021  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_PARTY_ID from CS_INCIDENTS_ALL_B xx 
5022  );
5023 end if;
5024 --CS_INCIDENTS_ALL_B;SHIP_TO_PARTY_ID
5025 appid:=170;
5026  if(regid_proc = true) then 
5027 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5028 
5029  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from CS_INCIDENTS_ALL_B xx 
5030  );
5031  else 
5032 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5033  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_PARTY_ID from CS_INCIDENTS_ALL_B xx 
5034  );
5035 end if;
5036 --CS_CHG_SUB_RESTRICTIONS;VALUE_OBJECT_ID
5037 appid:=170;
5038  if(regid_proc = true) then 
5039 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5040 
5041  temp.party_id  in (select /*+ parallel(xx)*/ xx.VALUE_OBJECT_ID from CS_CHG_SUB_RESTRICTIONS xx 
5042  );
5043  else 
5044 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5045  temp.party_id  in (select /*+ parallel(xx)*/ xx.VALUE_OBJECT_ID from CS_CHG_SUB_RESTRICTIONS xx 
5046  );
5047 end if;
5048 --CS_INCIDENTS_ALL_B;BILL_TO_CONTACT_ID
5049 appid:=170;
5050  if(regid_proc = true) then 
5051 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5052 
5053  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_ID from CS_INCIDENTS_ALL_B xx 
5054  );
5055  else 
5056 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5057  temp.party_id  in (select /*+ parallel(xx)*/ xx.BILL_TO_CONTACT_ID from CS_INCIDENTS_ALL_B xx 
5058  );
5059 end if;
5060 --CS_INCIDENTS_ALL_B;SHIP_TO_CONTACT_ID
5061 appid:=170;
5062  if(regid_proc = true) then 
5063 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5064 
5065  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_ID from CS_INCIDENTS_ALL_B xx 
5066  );
5067  else 
5068 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5069  temp.party_id  in (select /*+ parallel(xx)*/ xx.SHIP_TO_CONTACT_ID from CS_INCIDENTS_ALL_B xx 
5070  );
5071 end if;
5072 --CS_INCIDENTS_ALL_B;CUSTOMER_SITE_ID
5073 appid:=170;
5074  if(regid_proc = true) then 
5075 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5076 
5077  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5078  xx 
5079  where (nvl(STATUS, 'A') in ('A','I'))
5080  and  xx.PARTY_SITE_ID 
5081  in (select /*+ parallel(yy)*/ yy.CUSTOMER_SITE_ID from CS_INCIDENTS_ALL_B
5082  yy 
5083 ));
5084  else 
5085 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5086  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5087  xx 
5088  where (nvl(STATUS, 'A') in ('A','I'))
5089  and  xx.PARTY_SITE_ID 
5090  in (select /*+ parallel(yy)*/ yy.CUSTOMER_SITE_ID from CS_INCIDENTS_ALL_B
5091  yy 
5092 ));
5093 end if;
5094 --CS_INCIDENTS_ALL_B;INSTALL_SITE_USE_ID
5095 appid:=170;
5096  if(regid_proc = true) then 
5097 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5098 
5099  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5100  xx 
5101  where (nvl(STATUS, 'A') in ('A','I'))
5102  and  xx.PARTY_SITE_ID 
5103  in (select /*+ parallel(yy)*/ yy.INSTALL_SITE_USE_ID from CS_INCIDENTS_ALL_B
5104  yy 
5105 ));
5106  else 
5107 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5108  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5109  xx 
5110  where (nvl(STATUS, 'A') in ('A','I'))
5111  and  xx.PARTY_SITE_ID 
5112  in (select /*+ parallel(yy)*/ yy.INSTALL_SITE_USE_ID from CS_INCIDENTS_ALL_B
5113  yy 
5114 ));
5115 end if;
5116 --CS_INCIDENTS_ALL_B;INCIDENT_LOCATION_ID
5117 appid:=170;
5118  if(regid_proc = true) then 
5119 insert into hz_application_trans_gt(app_id,party_id) select 170, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 170 and appl.party_id=temp.party_id) and 
5120 
5121  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5122  xx 
5123  where (nvl(STATUS, 'A') in ('A','I'))
5124  and  xx.PARTY_SITE_ID 
5125  in (select /*+ parallel(yy)*/ yy.INCIDENT_LOCATION_ID from CS_INCIDENTS_ALL_B
5126  yy 
5127 ));
5128  else 
5129 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5130  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5131  xx 
5132  where (nvl(STATUS, 'A') in ('A','I'))
5133  and  xx.PARTY_SITE_ID 
5134  in (select /*+ parallel(yy)*/ yy.INCIDENT_LOCATION_ID from CS_INCIDENTS_ALL_B
5135  yy 
5136 ));
5137 end if;
5138 --ECX_TP_HEADERS;PARTY_SITE_ID
5139 appid:=174;
5140  if(regid_proc = true) then 
5141 insert into hz_application_trans_gt(app_id,party_id) select 174, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 174 and appl.party_id=temp.party_id) and 
5142 
5143  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5144  xx 
5145  where (nvl(STATUS, 'A') in ('A','I'))
5146  and  xx.PARTY_SITE_ID 
5147  in (select /*+ parallel(yy)*/ yy.PARTY_SITE_ID from ECX_TP_HEADERS
5148  yy 
5149 ));
5150  else 
5151 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5152  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5153  xx 
5154  where (nvl(STATUS, 'A') in ('A','I'))
5155  and  xx.PARTY_SITE_ID 
5156  in (select /*+ parallel(yy)*/ yy.PARTY_SITE_ID from ECX_TP_HEADERS
5157  yy 
5158 ));
5159 end if;
5160 --XLE_REGISTRATIONS;ISSUING_AUTHORITY_ID
5161 appid:=204;
5162  if(regid_proc = true) then 
5163 insert into hz_application_trans_gt(app_id,party_id) select 204, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 204 and appl.party_id=temp.party_id) and 
5164 
5165  temp.party_id  in (select /*+ parallel(xx)*/ xx.ISSUING_AUTHORITY_ID from XLE_REGISTRATIONS xx 
5166  );
5167  else 
5168 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5169  temp.party_id  in (select /*+ parallel(xx)*/ xx.ISSUING_AUTHORITY_ID from XLE_REGISTRATIONS xx 
5170  );
5171 end if;
5172 --XLE_REG_FUNCTIONS;AUTHORITY_ID
5173 appid:=204;
5174  if(regid_proc = true) then 
5175 insert into hz_application_trans_gt(app_id,party_id) select 204, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 204 and appl.party_id=temp.party_id) and 
5176 
5177  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTHORITY_ID from XLE_REG_FUNCTIONS xx 
5178  );
5179  else 
5180 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5181  temp.party_id  in (select /*+ parallel(xx)*/ xx.AUTHORITY_ID from XLE_REG_FUNCTIONS xx 
5182  );
5183 end if;
5184 --XLE_REGISTRATIONS;ISSUING_AUTHORITY_SITE_ID
5185 appid:=204;
5186  if(regid_proc = true) then 
5187 insert into hz_application_trans_gt(app_id,party_id) select 204, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 204 and appl.party_id=temp.party_id) and 
5188 
5189  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5190  xx 
5191  where (nvl(STATUS, 'A') in ('A','I'))
5192  and  xx.PARTY_SITE_ID 
5193  in (select /*+ parallel(yy)*/ yy.ISSUING_AUTHORITY_SITE_ID from XLE_REGISTRATIONS
5194  yy 
5195 ));
5196  else 
5197 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5198  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5199  xx 
5200  where (nvl(STATUS, 'A') in ('A','I'))
5201  and  xx.PARTY_SITE_ID 
5202  in (select /*+ parallel(yy)*/ yy.ISSUING_AUTHORITY_SITE_ID from XLE_REGISTRATIONS
5203  yy 
5204 ));
5205 end if;
5206 --XLE_REG_FUNCTIONS;AUTHORITY_SITE_ID
5207 appid:=204;
5208  if(regid_proc = true) then 
5209 insert into hz_application_trans_gt(app_id,party_id) select 204, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 204 and appl.party_id=temp.party_id) and 
5210 
5211  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5212  xx 
5213  where (nvl(STATUS, 'A') in ('A','I'))
5214  and  xx.PARTY_SITE_ID 
5215  in (select /*+ parallel(yy)*/ yy.AUTHORITY_SITE_ID from XLE_REG_FUNCTIONS
5216  yy 
5217 ));
5218  else 
5219 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5220  temp.party_id  in (select /*+ parallel (xx)*/ xx.PARTY_ID from HZ_PARTY_SITES
5221  xx 
5222  where (nvl(STATUS, 'A') in ('A','I'))
5223  and  xx.PARTY_SITE_ID 
5224  in (select /*+ parallel(yy)*/ yy.AUTHORITY_SITE_ID from XLE_REG_FUNCTIONS
5225  yy 
5226 ));
5227 end if;
5228 --IBW_PAGE_VIEWS;PARTY_ID
5229 appid:=666;
5230  if(regid_proc = true) then 
5231 insert into hz_application_trans_gt(app_id,party_id) select 666, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 666 and appl.party_id=temp.party_id) and 
5232 
5233  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IBW_PAGE_VIEWS xx 
5234  );
5235  else 
5236 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5237  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_ID from IBW_PAGE_VIEWS xx 
5238  );
5239 end if;
5240 --IBW_PAGE_VIEWS;PARTY_RELATIONSHIP_ID
5241 appid:=666;
5242  if(regid_proc = true) then 
5243 insert into hz_application_trans_gt(app_id,party_id) select 666, temp.party_id from hz_purge_gt temp  where not exists(select 'Y' from hz_application_trans_gt appl where appl.app_id = 666 and appl.party_id=temp.party_id) and 
5244 
5245  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_RELATIONSHIP_ID from IBW_PAGE_VIEWS xx 
5246  );
5247  else 
5248 delete /*+ parallel(temp) */ from hz_purge_gt temp where 
5249  temp.party_id  in (select /*+ parallel(xx)*/ xx.PARTY_RELATIONSHIP_ID from IBW_PAGE_VIEWS xx 
5250  );
5251 end if;
5252  if(regid_proc = true) then 
5253 delete from hz_purge_gt temp where temp.party_id in (select appl.party_id from hz_application_trans_gt appl) ;
5254 end if;
5255 
5256 
5257 EXCEPTION
5258 WHEN OTHERS THEN
5259 ROLLBACK to identify_candidates;
5260 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5261 FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_OTHERS_EXCEP' );
5262 FND_MESSAGE.SET_TOKEN( 'ERROR' ,SQLERRM );
5263 FND_MSG_PUB.ADD;
5264 FND_MSG_PUB.Count_And_Get(
5265             p_encoded => FND_API.G_FALSE,
5266             p_count => x_msg_count,
5267             p_data  => x_msg_data );
5268 RAISE FND_API.G_EXC_ERROR;
5269 END IDENTIFY_CANDIDATES;
5270 END HZ_PURGE_GEN;