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