DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ELP_CACHE

Source


1 PACKAGE BODY ben_elp_cache as
2 /* $Header: benelpch.pkb 120.1 2005/06/22 04:33:08 ssarkar noship $ */
3 --
4 -- Declare globals
5 --
6 g_package   varchar2(50) := 'ben_elp_cache.';
7 g_hash_key  number      := ben_hash_utility.get_hash_key;
8 g_hash_jump number     := ben_hash_utility.get_hash_jump;
9 --
10 -- cobcep
11 --
12 g_cobcep_lookup ben_cache.g_cache_lookup_table;
13 g_cobcep_inst   ben_elp_cache.g_cobcep_cache;
14 g_cobcep_cached boolean := FALSE;
15 --
16 -- eligibility profile person type by eligibility profile
17 --
18 g_cache_elpept_lookup ben_cache.g_cache_lookup_table;
19 g_cache_elpept_inst ben_elp_cache.g_cache_elpept_instor;
20 --
21 -- eligibility profile people group by eligibility profile
22 --
23 g_cache_elpepg_lookup ben_cache.g_cache_lookup_table;
24 g_cache_elpepg_inst ben_elp_cache.g_cache_elpepg_instor;
25 --
26 -- eligibility profile rule by eligibility profile
27 --
28 g_cache_elperl_lookup ben_cache.g_cache_lookup_table;
29 g_cache_elperl_inst ben_elp_cache.g_cache_elperl_instor;
30 --
31 -- eligibility profile assignment status type by eligibility profile
32 --
33 g_cache_elpees_lookup ben_cache.g_cache_lookup_table;
34 g_cache_elpees_inst ben_elp_cache.g_cache_elpees_instor;
35 --
36 -- eligibility profile length of service by eligibility profile
37 --
38 g_cache_elpels_lookup ben_cache.g_cache_lookup_table;
39 g_cache_elpels_inst ben_elp_cache.g_cache_elpels_instor;
40 --
41 -- eligibility profile age/los combination by eligibility profile
42 --
43 g_cache_elpecp_lookup ben_cache.g_cache_lookup_table;
44 g_cache_elpecp_inst ben_elp_cache.g_cache_elpecp_instor;
45 --
46 -- eligibility profile location by eligibility profile
47 --
48 g_cache_elpewl_lookup ben_cache.g_cache_lookup_table;
49 g_cache_elpewl_inst ben_elp_cache.g_cache_elpewl_instor;
50 --
51 -- eligibility profile assignment set by eligibility profile
52 --
53 g_cache_elpean_lookup ben_cache.g_cache_lookup_table;
54 g_cache_elpean_inst ben_elp_cache.g_cache_elpean_instor;
55 --
56 -- eligibility profile organization by eligibility profile
57 --
58 g_cache_elpeou_lookup ben_cache.g_cache_lookup_table;
59 g_cache_elpeou_inst ben_elp_cache.g_cache_elpeou_instor;
60 --
61 -- eligibility profile pay frequency by eligibility profile
62 --
63 g_cache_elpehs_lookup ben_cache.g_cache_lookup_table;
64 g_cache_elpehs_inst ben_elp_cache.g_cache_elpehs_instor;
65 --
66 -- eligibility profile full/part time by eligibility profile
67 --
68 g_cache_elpefp_lookup ben_cache.g_cache_lookup_table;
69 g_cache_elpefp_inst ben_elp_cache.g_cache_elpefp_instor;
70 --
71 -- eligibility profile scheduled hours by eligibility profile
72 --
73 g_cache_elpesh_lookup ben_cache.g_cache_lookup_table;
74 g_cache_elpesh_inst ben_elp_cache.g_cache_elpesh_instor;
75 --
76 -- eligibility profile compensation level by eligibility profile
77 --
78 g_cache_elpecl_lookup ben_cache.g_cache_lookup_table;
79 g_cache_elpecl_inst ben_elp_cache.g_cache_elpecl_instor;
80 --
81 -- eligibility profile hours worked by eligibility profile
82 --
83 g_cache_elpehw_lookup ben_cache.g_cache_lookup_table;
84 g_cache_elpehw_inst ben_elp_cache.g_cache_elpehw_instor;
85 --
86 -- eligibility profile full time by eligibility profile
87 --
88 g_cache_elpepf_lookup ben_cache.g_cache_lookup_table;
89 g_cache_elpepf_inst ben_elp_cache.g_cache_elpepf_instor;
90 --
91 -- eligibility profile grade by eligibility profile
92 --
93 g_cache_elpegr_lookup ben_cache.g_cache_lookup_table;
94 g_cache_elpegr_inst ben_elp_cache.g_cache_elpegr_instor;
95 --
96 -- eligibility profile sex by eligibility profile
97 --
98 g_cache_elpegn_lookup ben_cache.g_cache_lookup_table;
99 g_cache_elpegn_inst ben_elp_cache.g_cache_elpegn_instor;
100 --
101 -- eligibility profile job by eligibility profile
102 --
103 g_cache_elpejp_lookup ben_cache.g_cache_lookup_table;
104 g_cache_elpejp_inst ben_elp_cache.g_cache_elpejp_instor;
105 --
106 -- eligibility profile pay basis by eligibility profile
107 --
108 g_cache_elpepb_lookup ben_cache.g_cache_lookup_table;
109 g_cache_elpepb_inst ben_elp_cache.g_cache_elpepb_instor;
110 --
111 -- eligibility profile service area by eligibility profile
112 --
113 g_cache_elpesa_lookup ben_cache.g_cache_lookup_table;
114 g_cache_elpesa_inst ben_elp_cache.g_cache_elpesa_instor;
115 --
116 -- eligibility profile payroll by eligibility profile
117 --
118 g_cache_elpepy_lookup ben_cache.g_cache_lookup_table;
119 g_cache_elpepy_inst ben_elp_cache.g_cache_elpepy_instor;
120 --
121 -- eligibility profile bargaining unit by eligibility profile
122 --
123 g_cache_elpebu_lookup ben_cache.g_cache_lookup_table;
124 g_cache_elpebu_inst ben_elp_cache.g_cache_elpebu_instor;
125 --
126 -- eligibility profile labour union membership by eligibility profile
127 --
128 g_cache_elpelu_lookup ben_cache.g_cache_lookup_table;
129 g_cache_elpelu_inst ben_elp_cache.g_cache_elpelu_instor;
130 --
131 -- eligibility profile leave of absence reason by eligibility profile
132 --
133 g_cache_elpelr_lookup ben_cache.g_cache_lookup_table;
134 g_cache_elpelr_inst ben_elp_cache.g_cache_elpelr_instor;
135 --
136 -- eligibility profile age details by eligibility profile
137 --
138 g_cache_elpeap_lookup ben_cache.g_cache_lookup_table;
139 g_cache_elpeap_inst ben_elp_cache.g_cache_elpeap_instor;
140 --
141 -- eligibility profile zip code range by eligibility profile
142 --
143 g_cache_elpepz_lookup ben_cache.g_cache_lookup_table;
144 g_cache_elpepz_inst ben_elp_cache.g_cache_elpepz_instor;
145 --
146 -- eligibility profile benefits group by eligibility profile
147 --
148 g_cache_elpebn_lookup ben_cache.g_cache_lookup_table;
149 g_cache_elpebn_inst ben_elp_cache.g_cache_elpebn_instor;
150 --
151 -- eligibility profile legal entity by eligibility profile
152 --
153 g_cache_elpeln_lookup ben_cache.g_cache_lookup_table;
154 g_cache_elpeln_inst ben_elp_cache.g_cache_elpeln_instor;
155 --
156 -- eligibility profile other plan by eligibility profile
157 --
158 g_cache_elpepp_lookup ben_cache.g_cache_lookup_table;
159 g_cache_elpepp_inst ben_elp_cache.g_cache_elpepp_instor;
160 --
161 -- eligibility profile elig other ptip by eligibility profile
162 --
163 g_cache_elpeoy_lookup ben_cache.g_cache_lookup_table;
164 g_cache_elpeoy_inst ben_elp_cache.g_cache_elpeoy_instor;
165 --
166 -- eligibility profile no other coverage participate by eligibility profile
167 --
168 g_cache_elpetd_lookup ben_cache.g_cache_lookup_table;
169 g_cache_elpetd_inst ben_elp_cache.g_cache_elpetd_instor;
170 --
171 -- eligibility profile no other dpnt coverage participate by elig profile
172 --
173 g_cache_elpeno_lookup ben_cache.g_cache_lookup_table;
174 g_cache_elpeno_inst ben_elp_cache.g_cache_elpeno_instor;
175 --
176 -- eligibility profile enrolled another plan by eligibility profile
177 --
178 g_cache_elpeep_lookup ben_cache.g_cache_lookup_table;
179 g_cache_elpeep_inst ben_elp_cache.g_cache_elpeep_instor;
180 --
181 -- eligibility profile enrolled in another oipl by eligibility profile
182 --
183 g_cache_elpeei_lookup ben_cache.g_cache_lookup_table;
184 g_cache_elpeei_inst ben_elp_cache.g_cache_elpeei_instor;
185 --
186 -- eligibility profile enrolled in another pgm by eligibility profile
187 --
188 g_cache_elpeeg_lookup ben_cache.g_cache_lookup_table;
189 g_cache_elpeeg_inst ben_elp_cache.g_cache_elpeeg_instor;
190 --
191 -- eligibility profile dependent covered other plan by eligibility profile
192 --
193 g_cache_elpedp_lookup ben_cache.g_cache_lookup_table;
194 g_cache_elpedp_inst ben_elp_cache.g_cache_elpedp_instor;
195 --
196 -- eligibility profile leaving reason participate by eligibility profile
197 --
198 g_cache_elpelv_lookup ben_cache.g_cache_lookup_table;
199 g_cache_elpelv_inst ben_elp_cache.g_cache_elpelv_instor;
200 --
201 -- eligibility profile opted for medicare participate by eligibility profile
202 --
203 g_cache_elpeom_lookup ben_cache.g_cache_lookup_table;
204 g_cache_elpeom_inst ben_elp_cache.g_cache_elpeom_instor;
205 --
206 -- eligibility profile enrolled in another plip by eligibility profile
207 --
208 g_cache_elpeai_lookup ben_cache.g_cache_lookup_table;
209 g_cache_elpeai_inst ben_elp_cache.g_cache_elpeai_instor;
210 --
211 -- eligibility profile dependent covered othr plip by eligibility profile
212 --
213 g_cache_elpedi_lookup ben_cache.g_cache_lookup_table;
214 g_cache_elpedi_inst ben_elp_cache.g_cache_elpedi_instor;
215 --
216 -- eligibility profile enrolled another ptip by eligibility profile
217 --
218 g_cache_elpeet_lookup ben_cache.g_cache_lookup_table;
219 g_cache_elpeet_inst ben_elp_cache.g_cache_elpeet_instor;
220 --
221 -- eligibility profile dependent covered in other ptip by eligibility profile
222 --
223 g_cache_elpedt_lookup ben_cache.g_cache_lookup_table;
224 g_cache_elpedt_inst ben_elp_cache.g_cache_elpedt_instor;
225 --
226 -- eligibility profile dependent covered in other program by eligibility profile
227 --
228 g_cache_elpedg_lookup ben_cache.g_cache_lookup_table;
229 g_cache_elpedg_inst ben_elp_cache.g_cache_elpedg_instor;
230 --
231 -- eligibility profile cobra qualified beneficiary by eligibility profile
232 --
233 g_cache_elpecq_lookup ben_cache.g_cache_lookup_table;
234 g_cache_elpecq_inst ben_elp_cache.g_cache_elpecq_instor;
235 --
236 g_copcep_odlookup ben_cache.g_cache_lookup_table;
237 g_copcep_nxelenum number;
238 g_copcep_odinst   ben_elp_cache.g_cobcep_odcache := ben_elp_cache.g_cobcep_odcache();
239 g_copcep_odcached pls_integer := 0;
240 --
241 procedure write_cobcep_cache
242   (p_business_group_id in     number
243   ,p_effective_date    in     date
244   )
245 is
246   --
247   l_proc varchar2(72) := g_package||'write_cobcep_cache';
248   --
249   l_torrwnum        pls_integer;
250   l_prev_hv         pls_integer;
251   l_hv              pls_integer;
252   l_not_hash_found  boolean;
253 
254   cursor c_lookup
255     (c_business_group_id   NUMBER
256     ,c_effective_date      DATE
257     )
258   is
259     SELECT MAS1.PGM_ID,
260            MAS1.PTIP_ID,
261            MAS1.PLIP_ID,
262            MAS1.PL_ID,
263            MAS1.OIPL_ID
264     FROM BEN_PRTN_ELIG_F MAS1
265     WHERE MAS1.BUSINESS_GROUP_ID = c_business_group_id
266     AND c_effective_date
267       BETWEEN MAS1.EFFECTIVE_START_DATE AND MAS1.EFFECTIVE_END_DATE
268     and exists(select null
269                from  ben_prtn_elig_prfl_f mas2
270                where mas1.prtn_elig_id = mas2.prtn_elig_id
271                AND c_effective_date
272                  BETWEEN MAS2.EFFECTIVE_START_DATE AND MAS2.EFFECTIVE_END_DATE
273                )
274     ORDER BY MAS1.PGM_ID,
275            MAS1.PTIP_ID,
276            MAS1.PLIP_ID,
277            MAS1.PL_ID,
278            MAS1.OIPL_ID;
279   --
280   cursor c_instance
281     (c_business_group_id      NUMBER
282     ,c_effective_date         DATE
283     )
284   is
285     select  tab1.pgm_id,
286             tab1.ptip_id,
287             tab1.plip_id,
288             tab1.pl_id,
289             tab1.oipl_id,
290             tab1.prtn_elig_id,
291             tab2.mndtry_flag,
292             tab3.eligy_prfl_id,
293             tab3.asmt_to_use_cd,
294             tab3.elig_enrld_plip_flag,
295             tab3.elig_cbr_quald_bnf_flag,
296             tab3.elig_enrld_ptip_flag,
297             tab3.elig_dpnt_cvrd_plip_flag,
298             tab3.elig_dpnt_cvrd_ptip_flag,
299             tab3.elig_dpnt_cvrd_pgm_flag,
300             tab3.elig_job_flag,
301             tab3.elig_hrly_slrd_flag,
302             tab3.elig_pstl_cd_flag,
303             tab3.elig_lbr_mmbr_flag,
304             tab3.elig_lgl_enty_flag,
305             tab3.elig_benfts_grp_flag,
306             tab3.elig_wk_loc_flag,
307             tab3.elig_brgng_unit_flag,
308             tab3.elig_age_flag,
309             tab3.elig_los_flag,
310             tab3.elig_per_typ_flag,
311             tab3.elig_fl_tm_pt_tm_flag,
312             tab3.elig_ee_stat_flag,
313             tab3.elig_grd_flag,
314             tab3.elig_pct_fl_tm_flag,
315             tab3.elig_asnt_set_flag,
316             tab3.elig_hrs_wkd_flag,
317             tab3.elig_comp_lvl_flag,
318             tab3.elig_org_unit_flag,
319             tab3.elig_loa_rsn_flag,
320             tab3.elig_pyrl_flag,
321             tab3.elig_schedd_hrs_flag,
322             tab3.elig_py_bss_flag,
323             tab3.eligy_prfl_rl_flag,
324             tab3.elig_cmbn_age_los_flag,
325             tab3.cntng_prtn_elig_prfl_flag,
326             tab3.elig_prtt_pl_flag,
327             tab3.elig_ppl_grp_flag,
328             tab3.elig_svc_area_flag,
329             tab3.elig_ptip_prte_flag,
330             tab3.elig_no_othr_cvg_flag,
331             tab3.elig_enrld_pl_flag,
332             tab3.elig_enrld_oipl_flag,
333             tab3.elig_enrld_pgm_flag,
334             tab3.elig_dpnt_cvrd_pl_flag,
335             tab3.elig_lvg_rsn_flag,
336             tab3.elig_optd_mdcr_flag,
337             tab3.elig_tbco_use_flag,
338             tab3.elig_dpnt_othr_ptip_flag,
339             tab3.ELIG_GNDR_FLAG,
340             tab3.ELIG_MRTL_STS_FLAG,
341             tab3.ELIG_DSBLTY_CTG_FLAG,
342             tab3.ELIG_DSBLTY_RSN_FLAG,
343             tab3.ELIG_DSBLTY_DGR_FLAG,
344             tab3.ELIG_SUPPL_ROLE_FLAG,
345             tab3.ELIG_QUAL_TITL_FLAG,
346             tab3.ELIG_PSTN_FLAG,
347             tab3.ELIG_PRBTN_PERD_FLAG,
348             tab3.ELIG_SP_CLNG_PRG_PT_FLAG,
349             tab3.BNFT_CAGR_PRTN_CD,
350             tab3.ELIG_DSBLD_FLAG,
351             tab3.ELIG_TTL_CVG_VOL_FLAG,
352             tab3.ELIG_TTL_PRTT_FLAG,
353             tab3.ELIG_COMPTNCY_FLAG,
354             tab3.ELIG_HLTH_CVG_FLAG,
355             tab3.ELIG_ANTHR_PL_FLAG
356     from  ben_prtn_elig_f tab1,
357           ben_prtn_elig_prfl_f tab2,
358           ben_eligy_prfl_f tab3
359     where tab1.business_group_id = c_business_group_id
360     and tab1.prtn_elig_id = tab2.prtn_elig_id
361     and c_effective_date
362       between tab1.effective_start_date
363         and tab1.effective_end_date
364     and tab2.eligy_prfl_id = tab3.eligy_prfl_id
365     and c_effective_date
366       between tab2.effective_start_date
367         and tab2.effective_end_date
368     and c_effective_date
369       between tab3.effective_start_date
370     and tab3.effective_end_date
371     order by tab1.pgm_id,
372              tab1.ptip_id,
373              tab1.plip_id,
374              tab1.pl_id,
375              tab1.oipl_id,
376              decode(tab2.mndtry_flag,'Y',1,2);
377   --
378 begin
379   --
380 --  hr_utility.set_location(' Entering  '||l_proc,10);
381   --
382   for row in c_lookup
383     (c_business_group_id => p_business_group_id
384     ,c_effective_date    => p_effective_date
385     )
386   loop
387     --
388     l_hv := mod(nvl(row.pgm_id,1)+nvl(row.ptip_id,2)+nvl(row.plip_id,3)
389             +nvl(row.pl_id,4)+nvl(row.oipl_id,5),ben_hash_utility.get_hash_key);
390     --
391     while ben_elp_cache.g_cobcep_lookup.exists(l_hv)
392     loop
393       --
394       l_hv := l_hv+g_hash_jump;
395       --
396     end loop;
397     --
398     ben_elp_cache.g_cobcep_lookup(l_hv).id      := row.pgm_id;
399     ben_elp_cache.g_cobcep_lookup(l_hv).fk_id   := row.ptip_id;
400     ben_elp_cache.g_cobcep_lookup(l_hv).fk1_id  := row.plip_id;
401     ben_elp_cache.g_cobcep_lookup(l_hv).fk2_id  := row.pl_id;
402     ben_elp_cache.g_cobcep_lookup(l_hv).fk3_id  := row.oipl_id;
403     --
404   end loop;
405   --
406 --  hr_utility.set_location(' Dn Look  '||l_proc,10);
407   --
408   l_torrwnum := 0;
409   l_prev_hv  := -1;
410   --
411   if ben_elp_cache.g_cobcep_lookup.count > 0 then
412     --
413     for objinst in c_instance
414       (c_business_group_id => p_business_group_id
415       ,c_effective_date    => p_effective_date
416       )
417     loop
418       --
419     --  hr_utility.set_location(' St inst loop  '||l_proc,10);
420       --
421       l_hv := mod(nvl(objinst.pgm_id,1)+nvl(objinst.ptip_id,2)+nvl(objinst.plip_id,3)
422               +nvl(objinst.pl_id,4)+nvl(objinst.oipl_id,5),ben_hash_utility.get_hash_key);
423       --
424       if nvl(ben_elp_cache.g_cobcep_lookup(l_hv).id,-1) =  nvl(objinst.pgm_id,-1)
425         and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk_id,-1) = nvl(objinst.ptip_id,-1)
426         and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk1_id,-1) = nvl(objinst.plip_id,-1)
427         and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk2_id,-1) = nvl(objinst.pl_id,-1)
428         and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk3_id,-1) = nvl(objinst.oipl_id,-1)
429       then
430         --
431         null;
432         --
433       else
434         --
435         l_hv := l_hv+g_hash_jump;
436         --
437         loop
438           --
439           if nvl(ben_elp_cache.g_cobcep_lookup(l_hv).id,-1) = nvl(objinst.pgm_id,-1)
440             and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk_id,-1) = nvl(objinst.ptip_id,-1)
441             and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk1_id,-1) = nvl(objinst.plip_id,-1)
442             and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk2_id,-1) = nvl(objinst.pl_id,-1)
443             and nvl(ben_elp_cache.g_cobcep_lookup(l_hv).fk3_id,-1) = nvl(objinst.oipl_id,-1)
444           then
445             --
446             exit;
447             --
448           else
449             --
450             l_hv := l_hv+g_hash_jump;
451             --
452           end if;
453           --
454         end loop;
455         --
456       end if;
457       --
458       if l_prev_hv = -1 then
459         ben_elp_cache.g_cobcep_lookup(l_hv).starttorele_num := l_torrwnum;
460       elsif l_hv <> l_prev_hv then
461         ben_elp_cache.g_cobcep_lookup(l_prev_hv).endtorele_num := l_torrwnum-1;
462         ben_elp_cache.g_cobcep_lookup(l_hv).starttorele_num := l_torrwnum;
463       end if;
464       --
465     --  hr_utility.set_location(' Assign inst  '||l_proc,10);
466       --
467       g_cobcep_inst(l_torrwnum).pgm_id                   := objinst.pgm_id;
468       g_cobcep_inst(l_torrwnum).ptip_id                  := objinst.ptip_id;
469       g_cobcep_inst(l_torrwnum).plip_id                  := objinst.plip_id;
470       g_cobcep_inst(l_torrwnum).pl_id                    := objinst.pl_id;
471       g_cobcep_inst(l_torrwnum).oipl_id                  := objinst.oipl_id;
472       g_cobcep_inst(l_torrwnum).prtn_elig_id             := objinst.prtn_elig_id;
473       g_cobcep_inst(l_torrwnum).mndtry_flag              := objinst.mndtry_flag;
474       g_cobcep_inst(l_torrwnum).eligy_prfl_id            := objinst.eligy_prfl_id;
475       g_cobcep_inst(l_torrwnum).asmt_to_use_cd           := objinst.asmt_to_use_cd;
476       g_cobcep_inst(l_torrwnum).elig_enrld_plip_flag     := objinst.elig_enrld_plip_flag;
477       g_cobcep_inst(l_torrwnum).elig_cbr_quald_bnf_flag  := objinst.elig_cbr_quald_bnf_flag;
478       g_cobcep_inst(l_torrwnum).elig_enrld_ptip_flag     := objinst.elig_enrld_ptip_flag;
479       g_cobcep_inst(l_torrwnum).elig_dpnt_cvrd_plip_flag := objinst.elig_dpnt_cvrd_plip_flag;
480       g_cobcep_inst(l_torrwnum).elig_dpnt_cvrd_ptip_flag := objinst.elig_dpnt_cvrd_ptip_flag;
481       g_cobcep_inst(l_torrwnum).elig_dpnt_cvrd_pgm_flag  := objinst.elig_dpnt_cvrd_pgm_flag;
482       g_cobcep_inst(l_torrwnum).elig_job_flag            := objinst.elig_job_flag;
483       g_cobcep_inst(l_torrwnum).elig_hrly_slrd_flag      := objinst.elig_hrly_slrd_flag;
484       g_cobcep_inst(l_torrwnum).elig_pstl_cd_flag        := objinst.elig_pstl_cd_flag;
485       g_cobcep_inst(l_torrwnum).elig_lbr_mmbr_flag       := objinst.elig_lbr_mmbr_flag;
486       g_cobcep_inst(l_torrwnum).elig_lgl_enty_flag       := objinst.elig_lgl_enty_flag;
487       g_cobcep_inst(l_torrwnum).elig_benfts_grp_flag     := objinst.elig_benfts_grp_flag;
488       g_cobcep_inst(l_torrwnum).elig_wk_loc_flag         := objinst.elig_wk_loc_flag;
489       g_cobcep_inst(l_torrwnum).elig_brgng_unit_flag     := objinst.elig_brgng_unit_flag;
490       g_cobcep_inst(l_torrwnum).elig_age_flag            := objinst.elig_age_flag;
491       g_cobcep_inst(l_torrwnum).elig_los_flag            := objinst.elig_los_flag;
492       g_cobcep_inst(l_torrwnum).elig_per_typ_flag        := objinst.elig_per_typ_flag;
493       g_cobcep_inst(l_torrwnum).elig_fl_tm_pt_tm_flag    := objinst.elig_fl_tm_pt_tm_flag;
494       g_cobcep_inst(l_torrwnum).elig_ee_stat_flag        := objinst.elig_ee_stat_flag;
495       g_cobcep_inst(l_torrwnum).elig_grd_flag            := objinst.elig_grd_flag;
496       g_cobcep_inst(l_torrwnum).elig_pct_fl_tm_flag      := objinst.elig_pct_fl_tm_flag;
497       g_cobcep_inst(l_torrwnum).elig_asnt_set_flag       := objinst.elig_asnt_set_flag;
498       g_cobcep_inst(l_torrwnum).elig_hrs_wkd_flag        := objinst.elig_hrs_wkd_flag;
499       g_cobcep_inst(l_torrwnum).elig_comp_lvl_flag       := objinst.elig_comp_lvl_flag;
500       g_cobcep_inst(l_torrwnum).elig_org_unit_flag       := objinst.elig_org_unit_flag;
501       g_cobcep_inst(l_torrwnum).elig_loa_rsn_flag        := objinst.elig_loa_rsn_flag;
502       g_cobcep_inst(l_torrwnum).elig_pyrl_flag           := objinst.elig_pyrl_flag;
503       g_cobcep_inst(l_torrwnum).elig_schedd_hrs_flag     := objinst.elig_schedd_hrs_flag;
504       g_cobcep_inst(l_torrwnum).elig_py_bss_flag         := objinst.elig_py_bss_flag;
505       g_cobcep_inst(l_torrwnum).eligy_prfl_rl_flag       := objinst.eligy_prfl_rl_flag;
506       g_cobcep_inst(l_torrwnum).elig_cmbn_age_los_flag   := objinst.elig_cmbn_age_los_flag;
507       g_cobcep_inst(l_torrwnum).cntng_prtn_elig_prfl_flag := objinst.cntng_prtn_elig_prfl_flag;
508       g_cobcep_inst(l_torrwnum).elig_prtt_pl_flag         := objinst.elig_prtt_pl_flag;
509       g_cobcep_inst(l_torrwnum).elig_ppl_grp_flag         := objinst.elig_ppl_grp_flag;
510       g_cobcep_inst(l_torrwnum).elig_svc_area_flag        := objinst.elig_svc_area_flag;
511       g_cobcep_inst(l_torrwnum).elig_ptip_prte_flag       := objinst.elig_ptip_prte_flag;
512       g_cobcep_inst(l_torrwnum).elig_no_othr_cvg_flag     := objinst.elig_no_othr_cvg_flag;
513       g_cobcep_inst(l_torrwnum).elig_enrld_pl_flag        := objinst.elig_enrld_pl_flag;
514       g_cobcep_inst(l_torrwnum).elig_enrld_oipl_flag      := objinst.elig_enrld_oipl_flag;
515       g_cobcep_inst(l_torrwnum).elig_enrld_pgm_flag       := objinst.elig_enrld_pgm_flag;
516       g_cobcep_inst(l_torrwnum).elig_dpnt_cvrd_pl_flag    := objinst.elig_dpnt_cvrd_pl_flag;
517       g_cobcep_inst(l_torrwnum).elig_lvg_rsn_flag         := objinst.elig_lvg_rsn_flag;
518       g_cobcep_inst(l_torrwnum).elig_optd_mdcr_flag       := objinst.elig_optd_mdcr_flag;
519       g_cobcep_inst(l_torrwnum).elig_tbco_use_flag        := objinst.elig_tbco_use_flag;
520       g_cobcep_inst(l_torrwnum).elig_dpnt_othr_ptip_flag  := objinst.elig_dpnt_othr_ptip_flag;
521       g_cobcep_inst(l_torrwnum).ELIG_GNDR_FLAG            := objinst.ELIG_GNDR_FLAG;
522       g_cobcep_inst(l_torrwnum).ELIG_MRTL_STS_FLAG        := objinst.ELIG_MRTL_STS_FLAG;
523       g_cobcep_inst(l_torrwnum).ELIG_DSBLTY_CTG_FLAG      := objinst.ELIG_DSBLTY_CTG_FLAG;
524       g_cobcep_inst(l_torrwnum).ELIG_DSBLTY_RSN_FLAG      := objinst.ELIG_DSBLTY_RSN_FLAG;
525       g_cobcep_inst(l_torrwnum).ELIG_DSBLTY_DGR_FLAG      := objinst.ELIG_DSBLTY_DGR_FLAG;
526       g_cobcep_inst(l_torrwnum).ELIG_SUPPL_ROLE_FLAG      := objinst.ELIG_SUPPL_ROLE_FLAG;
527       g_cobcep_inst(l_torrwnum).ELIG_QUAL_TITL_FLAG       := objinst.ELIG_QUAL_TITL_FLAG;
528       g_cobcep_inst(l_torrwnum).ELIG_PSTN_FLAG            := objinst.ELIG_PSTN_FLAG;
529       g_cobcep_inst(l_torrwnum).ELIG_PRBTN_PERD_FLAG      := objinst.ELIG_PRBTN_PERD_FLAG;
530       g_cobcep_inst(l_torrwnum).ELIG_SP_CLNG_PRG_PT_FLAG  := objinst.ELIG_SP_CLNG_PRG_PT_FLAG;
531       g_cobcep_inst(l_torrwnum).BNFT_CAGR_PRTN_CD         := objinst.BNFT_CAGR_PRTN_CD;
532       g_cobcep_inst(l_torrwnum).ELIG_DSBLD_FLAG       	  := objinst.ELIG_DSBLD_FLAG       ;
533       g_cobcep_inst(l_torrwnum).ELIG_TTL_CVG_VOL_FLAG	  := objinst.ELIG_TTL_CVG_VOL_FLAG ;
534       g_cobcep_inst(l_torrwnum).ELIG_TTL_PRTT_FLAG    	  := objinst.ELIG_TTL_PRTT_FLAG    ;
535       g_cobcep_inst(l_torrwnum).ELIG_COMPTNCY_FLAG    	  := objinst.ELIG_COMPTNCY_FLAG    ;
536       g_cobcep_inst(l_torrwnum).ELIG_HLTH_CVG_FLAG    	  := objinst.ELIG_HLTH_CVG_FLAG    ;
537       g_cobcep_inst(l_torrwnum).ELIG_ANTHR_PL_FLAG    	  := objinst.ELIG_ANTHR_PL_FLAG    ;
538 
539       --
540     --  hr_utility.set_location(' Dn Assign inst  '||l_proc,10);
541       --
542       l_torrwnum := l_torrwnum+1;
543       l_prev_hv := l_hv;
544       --
545     end loop;
546     --
547     ben_elp_cache.g_cobcep_lookup(l_prev_hv).endtorele_num := l_torrwnum-1;
548     --
549   end if;
550   --
551 --  hr_utility.set_location(' Leaving  '||l_proc,10);
552 end write_cobcep_cache;
553 --
554 procedure cobcep_getdets
555   (p_business_group_id in number
556   ,p_effective_date in date
557   ,p_pgm_id in number default hr_api.g_number
558   ,p_pl_id in number default hr_api.g_number
559   ,p_oipl_id in number default hr_api.g_number
560   ,p_plip_id in number default hr_api.g_number
561   ,p_ptip_id in number default hr_api.g_number
562   --
563   ,p_inst_set out nocopy ben_elp_cache.g_cobcep_cache
564   ,p_inst_count out nocopy number
565   )
566 is
567   --
568   l_torrwnum      pls_integer;
569   l_insttorrw_num pls_integer;
570   l_hv            pls_integer;
571   l_not_hash_found boolean;
572   --
573 begin
574   --
575   if not g_cobcep_cached
576   then
577     --
578     -- Build the cache
579     --
580     write_cobcep_cache
581       (p_business_group_id => p_business_group_id
582       ,p_effective_date    => p_effective_date
583       );
584     --
585     g_cobcep_cached := TRUE;
586     --
587   end if;
588   --
589   -- Get the instance details
590   --
591   l_hv := mod(nvl(p_pgm_id,1)+nvl(p_ptip_id,2)+nvl(p_plip_id,3)
592           +nvl(p_pl_id,4)+nvl(p_oipl_id,5),ben_hash_utility.get_hash_key);
593   --
594   -- Check if hashed value is already allocated
595   --
596   if ben_elp_cache.g_cobcep_lookup.exists(l_hv) then
597     --
598     if nvl(g_cobcep_lookup(l_hv).id,-1) = nvl(p_pgm_id,-1)
599       and nvl(g_cobcep_lookup(l_hv).fk_id,-1) = nvl(p_ptip_id,-1)
600       and nvl(g_cobcep_lookup(l_hv).fk1_id,-1) = nvl(p_plip_id,-1)
601       and nvl(g_cobcep_lookup(l_hv).fk2_id,-1) = nvl(p_pl_id,-1)
602       and nvl(g_cobcep_lookup(l_hv).fk3_id,-1) = nvl(p_oipl_id,-1)
603     then
604        -- Matched row
605        null;
606     else
607       --
608       l_not_hash_found := false;
609       --
610       -- Loop until un-allocated has value is derived
611       --
612       while not l_not_hash_found loop
613         --
614         l_hv := ben_hash_utility.get_next_hash_index(p_hash_index => l_hv);
615         --
616         -- Check if the hash index exists, and compare the values
617         --
618         if nvl(g_cobcep_lookup(l_hv).id,-1) = nvl(p_pgm_id,-1)
619           and nvl(g_cobcep_lookup(l_hv).fk_id,-1) = nvl(p_ptip_id,-1)
620           and nvl(g_cobcep_lookup(l_hv).fk1_id,-1) = nvl(p_plip_id,-1)
621           and nvl(g_cobcep_lookup(l_hv).fk2_id,-1) = nvl(p_pl_id,-1)
622           and nvl(g_cobcep_lookup(l_hv).fk3_id,-1) = nvl(p_oipl_id,-1)
623         then
624           --
625           l_not_hash_found := true;
626           exit;
627           --
628         else
629           --
630           l_not_hash_found := false;
631           --
632         end if;
633         --
634       end loop;
635       --
636     end if;
637     --
638     l_torrwnum := 0;
639     --
640     for l_insttorrw_num in g_cobcep_lookup(l_hv).starttorele_num ..
641       g_cobcep_lookup(l_hv).endtorele_num loop
642       --
643       p_inst_set(l_torrwnum) := g_cobcep_inst(l_insttorrw_num);
644       l_torrwnum := l_torrwnum+1;
645       --
646     end loop;
647     --
648     p_inst_count := l_torrwnum;
649     --
650   end if;
651   --
652 exception
653   --
654   when no_data_found then
655     --
656     null;
657     --
658 end cobcep_getdets;
659 --
660 procedure write_cobcep_odcache
661   (p_effective_date in     date
662   ,p_pgm_id         in     number default hr_api.g_number
663   ,p_pl_id          in     number default hr_api.g_number
664   ,p_oipl_id        in     number default hr_api.g_number
665   ,p_plip_id        in     number default hr_api.g_number
666   ,p_ptip_id        in     number default hr_api.g_number
667   --
668   ,p_hv               out nocopy  pls_integer
669   )
670 is
671   --
672   l_proc varchar2(72) := g_package||'write_cobcep_odcache';
673   --
674   l_hv              pls_integer;
675   l_not_hash_found  boolean;
676   l_torrwnum        pls_integer;
677   l_starttorele_num pls_integer;
678   --
679   cursor c_pgminstance
680     (c_pgm_id         number
681     ,c_effective_date date
682     )
683   is
684     select  tab1.pgm_id,
685             tab1.ptip_id,
686             tab1.plip_id,
687             tab1.pl_id,
688             tab1.oipl_id,
689             tab1.prtn_elig_id,
690             tab2.mndtry_flag,
691             tab3.eligy_prfl_id,
692             tab3.asmt_to_use_cd,
693             tab3.elig_enrld_plip_flag,
694             tab3.elig_cbr_quald_bnf_flag,
695             tab3.elig_enrld_ptip_flag,
696             tab3.elig_dpnt_cvrd_plip_flag,
697             tab3.elig_dpnt_cvrd_ptip_flag,
698             tab3.elig_dpnt_cvrd_pgm_flag,
699             tab3.elig_job_flag,
700             tab3.elig_hrly_slrd_flag,
701             tab3.elig_pstl_cd_flag,
702             tab3.elig_lbr_mmbr_flag,
703             tab3.elig_lgl_enty_flag,
704             tab3.elig_benfts_grp_flag,
705             tab3.elig_wk_loc_flag,
706             tab3.elig_brgng_unit_flag,
707             tab3.elig_age_flag,
708             tab3.elig_los_flag,
709             tab3.elig_per_typ_flag,
710             tab3.elig_fl_tm_pt_tm_flag,
711             tab3.elig_ee_stat_flag,
712             tab3.elig_grd_flag,
713             tab3.elig_pct_fl_tm_flag,
714             tab3.elig_asnt_set_flag,
715             tab3.elig_hrs_wkd_flag,
716             tab3.elig_comp_lvl_flag,
717             tab3.elig_org_unit_flag,
718             tab3.elig_loa_rsn_flag,
719             tab3.elig_pyrl_flag,
720             tab3.elig_schedd_hrs_flag,
721             tab3.elig_py_bss_flag,
722             tab3.eligy_prfl_rl_flag,
723             tab3.elig_cmbn_age_los_flag,
724             tab3.cntng_prtn_elig_prfl_flag,
725             tab3.elig_prtt_pl_flag,
726             tab3.elig_ppl_grp_flag,
727             tab3.elig_svc_area_flag,
728             tab3.elig_ptip_prte_flag,
729             tab3.elig_no_othr_cvg_flag,
730             tab3.elig_enrld_pl_flag,
731             tab3.elig_enrld_oipl_flag,
732             tab3.elig_enrld_pgm_flag,
733             tab3.elig_dpnt_cvrd_pl_flag,
734             tab3.elig_lvg_rsn_flag,
735             tab3.elig_optd_mdcr_flag,
736             tab3.elig_tbco_use_flag,
737             tab3.elig_dpnt_othr_ptip_flag,
738             tab3.ELIG_DSBLD_FLAG,
739             tab3.ELIG_TTL_CVG_VOL_FLAG,
740             tab3.ELIG_TTL_PRTT_FLAG,
741             tab3.ELIG_COMPTNCY_FLAG,
742             tab3.ELIG_HLTH_CVG_FLAG,
743             tab3.ELIG_ANTHR_PL_FLAG
744     from  ben_prtn_elig_f tab1,
745           ben_prtn_elig_prfl_f tab2,
746           ben_eligy_prfl_f tab3
747     where tab1.pgm_id = c_pgm_id
748     and tab1.prtn_elig_id = tab2.prtn_elig_id
749     and c_effective_date
750       between tab1.effective_start_date  and tab1.effective_end_date
751     and tab2.eligy_prfl_id = tab3.eligy_prfl_id
752     and c_effective_date
753       between tab2.effective_start_date  and tab2.effective_end_date
754     and c_effective_date
755       between tab3.effective_start_date  and tab3.effective_end_date
756     order by tab1.pgm_id,
757              tab1.ptip_id,
758              tab1.plip_id,
759              tab1.pl_id,
760              tab1.oipl_id,
761              decode(tab2.mndtry_flag,'Y',1,2);
762   --
763   l_instance c_pgminstance%rowtype;
764   --
765   cursor c_ptipinstance
766     (c_ptip_id        number
767     ,c_effective_date date
768     )
769   is
770     select  tab1.pgm_id,
771             tab1.ptip_id,
772             tab1.plip_id,
773             tab1.pl_id,
774             tab1.oipl_id,
775             tab1.prtn_elig_id,
776             tab2.mndtry_flag,
777             tab3.eligy_prfl_id,
778             tab3.asmt_to_use_cd,
779             tab3.elig_enrld_plip_flag,
780             tab3.elig_cbr_quald_bnf_flag,
781             tab3.elig_enrld_ptip_flag,
782             tab3.elig_dpnt_cvrd_plip_flag,
783             tab3.elig_dpnt_cvrd_ptip_flag,
784             tab3.elig_dpnt_cvrd_pgm_flag,
785             tab3.elig_job_flag,
786             tab3.elig_hrly_slrd_flag,
787             tab3.elig_pstl_cd_flag,
788             tab3.elig_lbr_mmbr_flag,
789             tab3.elig_lgl_enty_flag,
790             tab3.elig_benfts_grp_flag,
791             tab3.elig_wk_loc_flag,
792             tab3.elig_brgng_unit_flag,
793             tab3.elig_age_flag,
794             tab3.elig_los_flag,
795             tab3.elig_per_typ_flag,
796             tab3.elig_fl_tm_pt_tm_flag,
797             tab3.elig_ee_stat_flag,
798             tab3.elig_grd_flag,
799             tab3.elig_pct_fl_tm_flag,
800             tab3.elig_asnt_set_flag,
801             tab3.elig_hrs_wkd_flag,
802             tab3.elig_comp_lvl_flag,
803             tab3.elig_org_unit_flag,
804             tab3.elig_loa_rsn_flag,
805             tab3.elig_pyrl_flag,
806             tab3.elig_schedd_hrs_flag,
807             tab3.elig_py_bss_flag,
808             tab3.eligy_prfl_rl_flag,
809             tab3.elig_cmbn_age_los_flag,
810             tab3.cntng_prtn_elig_prfl_flag,
811             tab3.elig_prtt_pl_flag,
812             tab3.elig_ppl_grp_flag,
813             tab3.elig_svc_area_flag,
814             tab3.elig_ptip_prte_flag,
815             tab3.elig_no_othr_cvg_flag,
816             tab3.elig_enrld_pl_flag,
817             tab3.elig_enrld_oipl_flag,
818             tab3.elig_enrld_pgm_flag,
819             tab3.elig_dpnt_cvrd_pl_flag,
820             tab3.elig_lvg_rsn_flag,
821             tab3.elig_optd_mdcr_flag,
822             tab3.elig_tbco_use_flag,
823             tab3.elig_dpnt_othr_ptip_flag,
824             tab3.ELIG_DSBLD_FLAG,
825             tab3.ELIG_TTL_CVG_VOL_FLAG,
826             tab3.ELIG_TTL_PRTT_FLAG,
827             tab3.ELIG_COMPTNCY_FLAG,
828             tab3.ELIG_HLTH_CVG_FLAG,
829             tab3.ELIG_ANTHR_PL_FLAG
830     from  ben_prtn_elig_f tab1,
831           ben_prtn_elig_prfl_f tab2,
832           ben_eligy_prfl_f tab3
833     where tab1.ptip_id = c_ptip_id
834     and tab1.prtn_elig_id = tab2.prtn_elig_id
835     and c_effective_date
836       between tab1.effective_start_date  and tab1.effective_end_date
837     and tab2.eligy_prfl_id = tab3.eligy_prfl_id
838     and c_effective_date
839       between tab2.effective_start_date  and tab2.effective_end_date
840     and c_effective_date
841       between tab3.effective_start_date  and tab3.effective_end_date
842     order by tab1.pgm_id,
843              tab1.ptip_id,
844              tab1.plip_id,
845              tab1.pl_id,
846              tab1.oipl_id,
847              decode(tab2.mndtry_flag,'Y',1,2);
848   --
849   cursor c_plipinstance
850     (c_plip_id        number
851     ,c_effective_date date
852     )
853   is
854     select  tab1.pgm_id,
855             tab1.ptip_id,
856             tab1.plip_id,
857             tab1.pl_id,
858             tab1.oipl_id,
859             tab1.prtn_elig_id,
860             tab2.mndtry_flag,
861             tab3.eligy_prfl_id,
862             tab3.asmt_to_use_cd,
863             tab3.elig_enrld_plip_flag,
864             tab3.elig_cbr_quald_bnf_flag,
865             tab3.elig_enrld_ptip_flag,
866             tab3.elig_dpnt_cvrd_plip_flag,
867             tab3.elig_dpnt_cvrd_ptip_flag,
868             tab3.elig_dpnt_cvrd_pgm_flag,
869             tab3.elig_job_flag,
870             tab3.elig_hrly_slrd_flag,
871             tab3.elig_pstl_cd_flag,
872             tab3.elig_lbr_mmbr_flag,
873             tab3.elig_lgl_enty_flag,
874             tab3.elig_benfts_grp_flag,
875             tab3.elig_wk_loc_flag,
876             tab3.elig_brgng_unit_flag,
877             tab3.elig_age_flag,
878             tab3.elig_los_flag,
879             tab3.elig_per_typ_flag,
880             tab3.elig_fl_tm_pt_tm_flag,
881             tab3.elig_ee_stat_flag,
882             tab3.elig_grd_flag,
883             tab3.elig_pct_fl_tm_flag,
884             tab3.elig_asnt_set_flag,
885             tab3.elig_hrs_wkd_flag,
886             tab3.elig_comp_lvl_flag,
887             tab3.elig_org_unit_flag,
888             tab3.elig_loa_rsn_flag,
889             tab3.elig_pyrl_flag,
890             tab3.elig_schedd_hrs_flag,
891             tab3.elig_py_bss_flag,
892             tab3.eligy_prfl_rl_flag,
893             tab3.elig_cmbn_age_los_flag,
894             tab3.cntng_prtn_elig_prfl_flag,
895             tab3.elig_prtt_pl_flag,
896             tab3.elig_ppl_grp_flag,
897             tab3.elig_svc_area_flag,
898             tab3.elig_ptip_prte_flag,
899             tab3.elig_no_othr_cvg_flag,
900             tab3.elig_enrld_pl_flag,
901             tab3.elig_enrld_oipl_flag,
902             tab3.elig_enrld_pgm_flag,
903             tab3.elig_dpnt_cvrd_pl_flag,
904             tab3.elig_lvg_rsn_flag,
905             tab3.elig_optd_mdcr_flag,
906             tab3.elig_tbco_use_flag,
907             tab3.elig_dpnt_othr_ptip_flag,
908             tab3.ELIG_DSBLD_FLAG,
909             tab3.ELIG_TTL_CVG_VOL_FLAG,
910             tab3.ELIG_TTL_PRTT_FLAG,
911             tab3.ELIG_COMPTNCY_FLAG,
912             tab3.ELIG_HLTH_CVG_FLAG,
913             tab3.ELIG_ANTHR_PL_FLAG
914     from  ben_prtn_elig_f tab1,
915           ben_prtn_elig_prfl_f tab2,
916           ben_eligy_prfl_f tab3
917     where tab1.plip_id = c_plip_id
918     and tab1.prtn_elig_id = tab2.prtn_elig_id
919     and c_effective_date
920       between tab1.effective_start_date     and tab1.effective_end_date
921     and tab2.eligy_prfl_id = tab3.eligy_prfl_id
922     and c_effective_date
923       between tab2.effective_start_date     and tab2.effective_end_date
924     and c_effective_date
925       between tab3.effective_start_date     and tab3.effective_end_date
926     order by tab1.pgm_id,
927              tab1.ptip_id,
928              tab1.plip_id,
929              tab1.pl_id,
930              tab1.oipl_id,
931              decode(tab2.mndtry_flag,'Y',1,2);
932   --
933   cursor c_plinstance
934     (c_pl_id          number
935     ,c_effective_date date
936     )
937   is
938     select  tab1.pgm_id,
939             tab1.ptip_id,
940             tab1.plip_id,
941             tab1.pl_id,
942             tab1.oipl_id,
943             tab1.prtn_elig_id,
944             tab2.mndtry_flag,
945             tab3.eligy_prfl_id,
946             tab3.asmt_to_use_cd,
947             tab3.elig_enrld_plip_flag,
948             tab3.elig_cbr_quald_bnf_flag,
949             tab3.elig_enrld_ptip_flag,
950             tab3.elig_dpnt_cvrd_plip_flag,
951             tab3.elig_dpnt_cvrd_ptip_flag,
952             tab3.elig_dpnt_cvrd_pgm_flag,
953             tab3.elig_job_flag,
954             tab3.elig_hrly_slrd_flag,
955             tab3.elig_pstl_cd_flag,
956             tab3.elig_lbr_mmbr_flag,
957             tab3.elig_lgl_enty_flag,
958             tab3.elig_benfts_grp_flag,
959             tab3.elig_wk_loc_flag,
960             tab3.elig_brgng_unit_flag,
961             tab3.elig_age_flag,
962             tab3.elig_los_flag,
963             tab3.elig_per_typ_flag,
964             tab3.elig_fl_tm_pt_tm_flag,
965             tab3.elig_ee_stat_flag,
966             tab3.elig_grd_flag,
967             tab3.elig_pct_fl_tm_flag,
968             tab3.elig_asnt_set_flag,
969             tab3.elig_hrs_wkd_flag,
970             tab3.elig_comp_lvl_flag,
971             tab3.elig_org_unit_flag,
972             tab3.elig_loa_rsn_flag,
973             tab3.elig_pyrl_flag,
974             tab3.elig_schedd_hrs_flag,
975             tab3.elig_py_bss_flag,
976             tab3.eligy_prfl_rl_flag,
977             tab3.elig_cmbn_age_los_flag,
978             tab3.cntng_prtn_elig_prfl_flag,
979             tab3.elig_prtt_pl_flag,
980             tab3.elig_ppl_grp_flag,
981             tab3.elig_svc_area_flag,
982             tab3.elig_ptip_prte_flag,
983             tab3.elig_no_othr_cvg_flag,
984             tab3.elig_enrld_pl_flag,
985             tab3.elig_enrld_oipl_flag,
986             tab3.elig_enrld_pgm_flag,
987             tab3.elig_dpnt_cvrd_pl_flag,
988             tab3.elig_lvg_rsn_flag,
989             tab3.elig_optd_mdcr_flag,
990             tab3.elig_tbco_use_flag,
991             tab3.elig_dpnt_othr_ptip_flag,
992             tab3.ELIG_DSBLD_FLAG,
993             tab3.ELIG_TTL_CVG_VOL_FLAG,
994             tab3.ELIG_TTL_PRTT_FLAG,
995             tab3.ELIG_COMPTNCY_FLAG,
996             tab3.ELIG_HLTH_CVG_FLAG,
997             tab3.ELIG_ANTHR_PL_FLAG
998     from  ben_prtn_elig_f tab1,
999           ben_prtn_elig_prfl_f tab2,
1000           ben_eligy_prfl_f tab3
1001     where tab1.pl_id = c_pl_id
1002     and tab1.prtn_elig_id = tab2.prtn_elig_id
1003     and c_effective_date
1004       between tab1.effective_start_date     and tab1.effective_end_date
1005     and tab2.eligy_prfl_id = tab3.eligy_prfl_id
1006     and c_effective_date
1007       between tab2.effective_start_date     and tab2.effective_end_date
1008     and c_effective_date
1009       between tab3.effective_start_date     and tab3.effective_end_date
1010     order by tab1.pgm_id,
1011              tab1.ptip_id,
1012              tab1.plip_id,
1013              tab1.pl_id,
1014              tab1.oipl_id,
1015              decode(tab2.mndtry_flag,'Y',1,2);
1016   --
1017   cursor c_oiplinstance
1018     (c_oipl_id        number
1019     ,c_effective_date date
1020     )
1021   is
1022     select  tab1.pgm_id,
1023             tab1.ptip_id,
1024             tab1.plip_id,
1025             tab1.pl_id,
1026             tab1.oipl_id,
1027             tab1.prtn_elig_id,
1028             tab2.mndtry_flag,
1029             tab3.eligy_prfl_id,
1030             tab3.asmt_to_use_cd,
1031             tab3.elig_enrld_plip_flag,
1032             tab3.elig_cbr_quald_bnf_flag,
1033             tab3.elig_enrld_ptip_flag,
1034             tab3.elig_dpnt_cvrd_plip_flag,
1035             tab3.elig_dpnt_cvrd_ptip_flag,
1036             tab3.elig_dpnt_cvrd_pgm_flag,
1037             tab3.elig_job_flag,
1038             tab3.elig_hrly_slrd_flag,
1039             tab3.elig_pstl_cd_flag,
1040             tab3.elig_lbr_mmbr_flag,
1041             tab3.elig_lgl_enty_flag,
1042             tab3.elig_benfts_grp_flag,
1043             tab3.elig_wk_loc_flag,
1044             tab3.elig_brgng_unit_flag,
1045             tab3.elig_age_flag,
1046             tab3.elig_los_flag,
1047             tab3.elig_per_typ_flag,
1048             tab3.elig_fl_tm_pt_tm_flag,
1049             tab3.elig_ee_stat_flag,
1050             tab3.elig_grd_flag,
1051             tab3.elig_pct_fl_tm_flag,
1052             tab3.elig_asnt_set_flag,
1053             tab3.elig_hrs_wkd_flag,
1054             tab3.elig_comp_lvl_flag,
1055             tab3.elig_org_unit_flag,
1056             tab3.elig_loa_rsn_flag,
1057             tab3.elig_pyrl_flag,
1058             tab3.elig_schedd_hrs_flag,
1059             tab3.elig_py_bss_flag,
1060             tab3.eligy_prfl_rl_flag,
1061             tab3.elig_cmbn_age_los_flag,
1062             tab3.cntng_prtn_elig_prfl_flag,
1063             tab3.elig_prtt_pl_flag,
1064             tab3.elig_ppl_grp_flag,
1065             tab3.elig_svc_area_flag,
1066             tab3.elig_ptip_prte_flag,
1067             tab3.elig_no_othr_cvg_flag,
1068             tab3.elig_enrld_pl_flag,
1069             tab3.elig_enrld_oipl_flag,
1070             tab3.elig_enrld_pgm_flag,
1071             tab3.elig_dpnt_cvrd_pl_flag,
1072             tab3.elig_lvg_rsn_flag,
1073             tab3.elig_optd_mdcr_flag,
1074             tab3.elig_tbco_use_flag,
1075             tab3.elig_dpnt_othr_ptip_flag,
1076             tab3.ELIG_DSBLD_FLAG,
1077             tab3.ELIG_TTL_CVG_VOL_FLAG,
1078             tab3.ELIG_TTL_PRTT_FLAG,
1079             tab3.ELIG_COMPTNCY_FLAG,
1080             tab3.ELIG_HLTH_CVG_FLAG,
1081             tab3.ELIG_ANTHR_PL_FLAG
1082     from  ben_prtn_elig_f tab1,
1083           ben_prtn_elig_prfl_f tab2,
1084           ben_eligy_prfl_f tab3
1085     where tab1.oipl_id = c_oipl_id
1086     and tab1.prtn_elig_id = tab2.prtn_elig_id
1087     and c_effective_date
1088       between tab1.effective_start_date   and tab1.effective_end_date
1089     and tab2.eligy_prfl_id = tab3.eligy_prfl_id
1090     and c_effective_date
1091       between tab2.effective_start_date   and tab2.effective_end_date
1092     and c_effective_date
1093       between tab3.effective_start_date   and tab3.effective_end_date
1094     order by tab1.pgm_id,
1095              tab1.ptip_id,
1096              tab1.plip_id,
1097              tab1.pl_id,
1098              tab1.oipl_id,
1099              decode(tab2.mndtry_flag,'Y',1,2);
1100   --
1101 begin
1102   --
1103   hr_utility.set_location(' Entering  '||l_proc,10);
1104   --
1105   -- Get the instance details
1106   --
1107   l_hv := mod(nvl(p_pgm_id,1)+nvl(p_ptip_id,2)+nvl(p_plip_id,3)
1108           +nvl(p_pl_id,4)+nvl(p_oipl_id,5),ben_hash_utility.get_hash_key);
1109   --
1110   -- Get a unique hash value
1111   --
1112   if g_copcep_odlookup.exists(l_hv) then
1113     --
1114     if nvl(g_copcep_odlookup(l_hv).id,-1)        = nvl(p_pgm_id,-1)
1115       and nvl(g_copcep_odlookup(l_hv).fk_id,-1)  = nvl(p_ptip_id,-1)
1116       and nvl(g_copcep_odlookup(l_hv).fk1_id,-1) = nvl(p_plip_id,-1)
1117       and nvl(g_copcep_odlookup(l_hv).fk2_id,-1) = nvl(p_pl_id,-1)
1118       and nvl(g_copcep_odlookup(l_hv).fk3_id,-1) = nvl(p_oipl_id,-1)
1119     then
1120       --
1121       null;
1122       --
1123     else
1124       --
1125       l_not_hash_found := false;
1126       --
1127       -- Loop until un-allocated has value is derived
1128       --
1129       while not l_not_hash_found loop
1130         --
1131         l_hv := ben_hash_utility.get_next_hash_index(p_hash_index => l_hv);
1132         --
1133         -- Check if the hash index exists, and compare the values
1134         --
1135         if nvl(g_copcep_odlookup(l_hv).id,-1)        = nvl(p_pgm_id,-1)
1136           and nvl(g_copcep_odlookup(l_hv).fk_id,-1)  = nvl(p_ptip_id,-1)
1137           and nvl(g_copcep_odlookup(l_hv).fk1_id,-1) = nvl(p_plip_id,-1)
1138           and nvl(g_copcep_odlookup(l_hv).fk2_id,-1) = nvl(p_pl_id,-1)
1139           and nvl(g_copcep_odlookup(l_hv).fk3_id,-1) = nvl(p_oipl_id,-1)
1140         then
1141           --
1142           l_not_hash_found := true;
1143           exit;
1144           --
1145         else
1146           --
1147           l_not_hash_found := false;
1148           --
1149         end if;
1150         --
1151       end loop;
1152       --
1153     end if;
1154     --
1155   end if;
1156   --
1157   g_copcep_odlookup(l_hv).id     := p_pgm_id;
1158   g_copcep_odlookup(l_hv).fk_id  := p_ptip_id;
1159   g_copcep_odlookup(l_hv).fk1_id := p_plip_id;
1160   g_copcep_odlookup(l_hv).fk2_id := p_pl_id;
1161   g_copcep_odlookup(l_hv).fk3_id := p_oipl_id;
1162   --
1163   hr_utility.set_location(' Dn Look  '||l_proc,10);
1164   --
1165   l_starttorele_num := nvl(g_copcep_nxelenum,1);
1166   l_torrwnum        := l_starttorele_num;
1167   --
1168   hr_utility.set_location(' Bef inst loop  '||l_proc,10);
1169   --
1170   if p_pgm_id is not null then
1171     --
1172     open c_pgminstance
1173       (c_pgm_id         => p_pgm_id
1174       ,c_effective_date => p_effective_date
1175       );
1176     --
1177   elsif p_ptip_id is not null then
1178     --
1179     open c_ptipinstance
1180       (c_ptip_id        => p_ptip_id
1181       ,c_effective_date => p_effective_date
1182       );
1183     --
1184   elsif p_plip_id is not null then
1185     --
1186     open c_plipinstance
1187       (c_plip_id        => p_plip_id
1188       ,c_effective_date => p_effective_date
1189       );
1190     --
1191   elsif p_pl_id is not null then
1192     --
1193     open c_plinstance
1194       (c_pl_id          => p_pl_id
1195       ,c_effective_date => p_effective_date
1196       );
1197     --
1198   elsif p_oipl_id is not null then
1199     --
1200     open c_oiplinstance
1201       (c_oipl_id        => p_oipl_id
1202       ,c_effective_date => p_effective_date
1203       );
1204     --
1205   end if;
1206   --
1207   loop
1208     --
1209     if p_pgm_id is not null then
1210       --
1211       fetch c_pgminstance into l_instance;
1212       exit when c_pgminstance%NOTFOUND;
1213       --
1214     elsif p_ptip_id is not null then
1215       --
1216       fetch c_ptipinstance into l_instance;
1217       exit when c_ptipinstance%NOTFOUND;
1218       --
1219     elsif p_plip_id is not null then
1220       --
1221       fetch c_plipinstance into l_instance;
1222       exit when c_plipinstance%NOTFOUND;
1223       --
1224     elsif p_pl_id is not null then
1225       --
1226       fetch c_plinstance into l_instance;
1227       exit when c_plinstance%NOTFOUND;
1228       --
1229     elsif p_oipl_id is not null then
1230       --
1231       fetch c_oiplinstance into l_instance;
1232       exit when c_oiplinstance%NOTFOUND;
1233       --
1234     end if;
1235     --
1236     hr_utility.set_location(' Assign inst  '||l_proc,10);
1237     --
1238     g_copcep_odinst.extend(1);
1239     g_copcep_odinst(l_torrwnum).pgm_id                   := l_instance.pgm_id;
1240     g_copcep_odinst(l_torrwnum).ptip_id                  := l_instance.ptip_id;
1241     g_copcep_odinst(l_torrwnum).plip_id                  := l_instance.plip_id;
1242     g_copcep_odinst(l_torrwnum).pl_id                    := l_instance.pl_id;
1243     g_copcep_odinst(l_torrwnum).oipl_id                  := l_instance.oipl_id;
1244     g_copcep_odinst(l_torrwnum).prtn_elig_id             := l_instance.prtn_elig_id;
1245     g_copcep_odinst(l_torrwnum).mndtry_flag              := l_instance.mndtry_flag;
1246     g_copcep_odinst(l_torrwnum).eligy_prfl_id            := l_instance.eligy_prfl_id;
1247     g_copcep_odinst(l_torrwnum).asmt_to_use_cd           := l_instance.asmt_to_use_cd;
1248     g_copcep_odinst(l_torrwnum).elig_enrld_plip_flag     := l_instance.elig_enrld_plip_flag;
1249     g_copcep_odinst(l_torrwnum).elig_cbr_quald_bnf_flag  := l_instance.elig_cbr_quald_bnf_flag;
1250     g_copcep_odinst(l_torrwnum).elig_enrld_ptip_flag     := l_instance.elig_enrld_ptip_flag;
1251     g_copcep_odinst(l_torrwnum).elig_dpnt_cvrd_plip_flag := l_instance.elig_dpnt_cvrd_plip_flag;
1252     g_copcep_odinst(l_torrwnum).elig_dpnt_cvrd_ptip_flag := l_instance.elig_dpnt_cvrd_ptip_flag;
1253     g_copcep_odinst(l_torrwnum).elig_dpnt_cvrd_pgm_flag  := l_instance.elig_dpnt_cvrd_pgm_flag;
1254     g_copcep_odinst(l_torrwnum).elig_job_flag            := l_instance.elig_job_flag;
1255     g_copcep_odinst(l_torrwnum).elig_hrly_slrd_flag      := l_instance.elig_hrly_slrd_flag;
1256     g_copcep_odinst(l_torrwnum).elig_pstl_cd_flag        := l_instance.elig_pstl_cd_flag;
1257     g_copcep_odinst(l_torrwnum).elig_lbr_mmbr_flag       := l_instance.elig_lbr_mmbr_flag;
1258     g_copcep_odinst(l_torrwnum).elig_lgl_enty_flag       := l_instance.elig_lgl_enty_flag;
1259     g_copcep_odinst(l_torrwnum).elig_benfts_grp_flag     := l_instance.elig_benfts_grp_flag;
1260     g_copcep_odinst(l_torrwnum).elig_wk_loc_flag         := l_instance.elig_wk_loc_flag;
1261     g_copcep_odinst(l_torrwnum).elig_brgng_unit_flag     := l_instance.elig_brgng_unit_flag;
1262     g_copcep_odinst(l_torrwnum).elig_age_flag            := l_instance.elig_age_flag;
1263     g_copcep_odinst(l_torrwnum).elig_los_flag            := l_instance.elig_los_flag;
1264     g_copcep_odinst(l_torrwnum).elig_per_typ_flag        := l_instance.elig_per_typ_flag;
1265     g_copcep_odinst(l_torrwnum).elig_fl_tm_pt_tm_flag    := l_instance.elig_fl_tm_pt_tm_flag;
1266     g_copcep_odinst(l_torrwnum).elig_ee_stat_flag        := l_instance.elig_ee_stat_flag;
1267     g_copcep_odinst(l_torrwnum).elig_grd_flag            := l_instance.elig_grd_flag;
1268     g_copcep_odinst(l_torrwnum).elig_pct_fl_tm_flag      := l_instance.elig_pct_fl_tm_flag;
1269     g_copcep_odinst(l_torrwnum).elig_asnt_set_flag       := l_instance.elig_asnt_set_flag;
1270     g_copcep_odinst(l_torrwnum).elig_hrs_wkd_flag        := l_instance.elig_hrs_wkd_flag;
1271     g_copcep_odinst(l_torrwnum).elig_comp_lvl_flag       := l_instance.elig_comp_lvl_flag;
1272     g_copcep_odinst(l_torrwnum).elig_org_unit_flag       := l_instance.elig_org_unit_flag;
1273     g_copcep_odinst(l_torrwnum).elig_loa_rsn_flag        := l_instance.elig_loa_rsn_flag;
1274     g_copcep_odinst(l_torrwnum).elig_pyrl_flag           := l_instance.elig_pyrl_flag;
1275     g_copcep_odinst(l_torrwnum).elig_schedd_hrs_flag     := l_instance.elig_schedd_hrs_flag;
1276     g_copcep_odinst(l_torrwnum).elig_py_bss_flag         := l_instance.elig_py_bss_flag;
1277     g_copcep_odinst(l_torrwnum).eligy_prfl_rl_flag       := l_instance.eligy_prfl_rl_flag;
1278     g_copcep_odinst(l_torrwnum).elig_cmbn_age_los_flag   := l_instance.elig_cmbn_age_los_flag;
1279     g_copcep_odinst(l_torrwnum).cntng_prtn_elig_prfl_flag := l_instance.cntng_prtn_elig_prfl_flag;
1280     g_copcep_odinst(l_torrwnum).elig_prtt_pl_flag         := l_instance.elig_prtt_pl_flag;
1281     g_copcep_odinst(l_torrwnum).elig_ppl_grp_flag         := l_instance.elig_ppl_grp_flag;
1282     g_copcep_odinst(l_torrwnum).elig_svc_area_flag        := l_instance.elig_svc_area_flag;
1283     g_copcep_odinst(l_torrwnum).elig_ptip_prte_flag       := l_instance.elig_ptip_prte_flag;
1284     g_copcep_odinst(l_torrwnum).elig_no_othr_cvg_flag     := l_instance.elig_no_othr_cvg_flag;
1285     g_copcep_odinst(l_torrwnum).elig_enrld_pl_flag        := l_instance.elig_enrld_pl_flag;
1286     g_copcep_odinst(l_torrwnum).elig_enrld_oipl_flag      := l_instance.elig_enrld_oipl_flag;
1287     g_copcep_odinst(l_torrwnum).elig_enrld_pgm_flag       := l_instance.elig_enrld_pgm_flag;
1288     g_copcep_odinst(l_torrwnum).elig_dpnt_cvrd_pl_flag    := l_instance.elig_dpnt_cvrd_pl_flag;
1289     g_copcep_odinst(l_torrwnum).elig_lvg_rsn_flag         := l_instance.elig_lvg_rsn_flag;
1290     g_copcep_odinst(l_torrwnum).elig_optd_mdcr_flag       := l_instance.elig_optd_mdcr_flag;
1291     g_copcep_odinst(l_torrwnum).elig_tbco_use_flag        := l_instance.elig_tbco_use_flag;
1292     g_copcep_odinst(l_torrwnum).elig_dpnt_othr_ptip_flag  := l_instance.elig_dpnt_othr_ptip_flag;
1293     g_copcep_odinst(l_torrwnum).ELIG_DSBLD_FLAG       	  := l_instance.ELIG_DSBLD_FLAG       ;
1294     g_copcep_odinst(l_torrwnum).ELIG_TTL_CVG_VOL_FLAG	  := l_instance.ELIG_TTL_CVG_VOL_FLAG ;
1295     g_copcep_odinst(l_torrwnum).ELIG_TTL_PRTT_FLAG    	  := l_instance.ELIG_TTL_PRTT_FLAG    ;
1296     g_copcep_odinst(l_torrwnum).ELIG_COMPTNCY_FLAG    	  := l_instance.ELIG_COMPTNCY_FLAG    ;
1297     g_copcep_odinst(l_torrwnum).ELIG_HLTH_CVG_FLAG    	  := l_instance.ELIG_HLTH_CVG_FLAG    ;
1298     g_copcep_odinst(l_torrwnum).ELIG_ANTHR_PL_FLAG    	  := l_instance.ELIG_ANTHR_PL_FLAG    ;
1299     hr_utility.set_location(' Dn Assign inst  '||l_proc,10);
1300     --
1301     l_torrwnum := l_torrwnum+1;
1302     --
1303   end loop;
1304   --
1305   if p_pgm_id is not null then
1306     --
1307     close c_pgminstance;
1308     --
1309   elsif p_ptip_id is not null then
1310     --
1311     close c_ptipinstance;
1312     --
1313   elsif p_plip_id is not null then
1314     --
1315     close c_plipinstance;
1316     --
1317   elsif p_pl_id is not null then
1318     --
1319     close c_plinstance;
1320     --
1321   elsif p_oipl_id is not null then
1322     --
1323     close c_oiplinstance;
1324     --
1325   end if;
1326   --
1327   -- Check if any rows were found
1328   --
1329   if l_torrwnum > nvl(g_copcep_nxelenum,1)
1330   then
1331     --
1332     g_copcep_odlookup(l_hv).starttorele_num := l_starttorele_num;
1333     g_copcep_odlookup(l_hv).endtorele_num   := l_torrwnum-1;
1334     g_copcep_nxelenum := l_torrwnum;
1335     --
1336     p_hv := l_hv;
1337     --
1338   else
1339     --
1340     p_hv := null;
1341     --
1342   end if;
1343   --
1344   begin
1345     --
1346     dbms_session.free_unused_user_memory;
1347     --
1348   end;
1349   hr_utility.set_location(' Leaving  '||l_proc,10);
1350 end write_cobcep_odcache;
1351 --
1352 procedure cobcep_odgetdets
1353   (p_effective_date in     date
1354   ,p_pgm_id         in     number default hr_api.g_number
1355   ,p_pl_id          in     number default hr_api.g_number
1356   ,p_oipl_id        in     number default hr_api.g_number
1357   ,p_plip_id        in     number default hr_api.g_number
1358   ,p_ptip_id        in     number default hr_api.g_number
1359   --
1360   ,p_inst_set       in out nocopy ben_elp_cache.g_cobcep_odcache
1361   )
1362 is
1363   --
1364   l_proc varchar2(72) := g_package||'cobcep_odgetdets';
1365   --
1366   l_inst_set       ben_elp_cache.g_cobcep_odcache := ben_elp_cache.g_cobcep_odcache();
1367   --
1368   l_hv             pls_integer;
1369   l_not_hash_found boolean;
1370   l_insttorrw_num  pls_integer;
1371   l_torrwnum       pls_integer;
1372   --
1373 begin
1374   --
1375   if g_copcep_odcached = 0
1376   then
1377     --
1378     -- Build the cache
1379     --
1380     clear_down_cache;
1381     --
1382     g_copcep_odcached := 1;
1383     --
1384   end if;
1385   hr_utility.set_location(' Derive hv  '||l_proc,10);
1386   --
1387   -- Get the instance details
1388   --
1389   l_hv := mod(nvl(p_pgm_id,1)+nvl(p_ptip_id,2)+nvl(p_plip_id,3)
1390           +nvl(p_pl_id,4)+nvl(p_oipl_id,5),ben_hash_utility.get_hash_key);
1391   --
1392   -- Check if hashed value is already allocated
1393   --
1394   if g_copcep_odlookup.exists(l_hv) then
1395     --
1396     if nvl(g_copcep_odlookup(l_hv).id,-1)        = nvl(p_pgm_id,-1)
1397       and nvl(g_copcep_odlookup(l_hv).fk_id,-1)  = nvl(p_ptip_id,-1)
1398       and nvl(g_copcep_odlookup(l_hv).fk1_id,-1) = nvl(p_plip_id,-1)
1399       and nvl(g_copcep_odlookup(l_hv).fk2_id,-1) = nvl(p_pl_id,-1)
1400       and nvl(g_copcep_odlookup(l_hv).fk3_id,-1) = nvl(p_oipl_id,-1)
1401     then
1402       --
1403       null;
1404       --
1405     else
1406       --
1407       l_not_hash_found := false;
1408       --
1409       -- Loop until un-allocated has value is derived
1410       --
1411       while not l_not_hash_found loop
1412         --
1413         l_hv := ben_hash_utility.get_next_hash_index(p_hash_index => l_hv);
1414         --
1415         -- Check if the hash index exists, and compare the values
1416         --
1417         if nvl(g_copcep_odlookup(l_hv).id,-1)        = nvl(p_pgm_id,-1)
1418           and nvl(g_copcep_odlookup(l_hv).fk_id,-1)  = nvl(p_ptip_id,-1)
1419           and nvl(g_copcep_odlookup(l_hv).fk1_id,-1) = nvl(p_plip_id,-1)
1420           and nvl(g_copcep_odlookup(l_hv).fk2_id,-1) = nvl(p_pl_id,-1)
1421           and nvl(g_copcep_odlookup(l_hv).fk3_id,-1) = nvl(p_oipl_id,-1)
1422         then
1423           --
1424           l_not_hash_found := true;
1425           exit;
1426           --
1427         else
1428           --
1429           l_not_hash_found := false;
1430           --
1431         end if;
1432         --
1433       end loop;
1434       --
1435     end if;
1436     --
1437   else
1438     --
1439     write_cobcep_odcache
1440       (p_effective_date => p_effective_date
1441       ,p_pgm_id         => p_pgm_id
1442       ,p_pl_id          => p_pl_id
1443       ,p_oipl_id        => p_oipl_id
1444       ,p_plip_id        => p_plip_id
1445       ,p_ptip_id        => p_ptip_id
1446       --
1447       ,p_hv             => l_hv
1448       );
1449     --
1450   end if;
1451   hr_utility.set_location(' Got hv  '||l_proc,10);
1452   --
1453   if l_hv is not null then
1454     --
1455     l_torrwnum := 1;
1456     --
1457     hr_utility.set_location(' Get loop  '||l_proc,10);
1458     for l_insttorrw_num in g_copcep_odlookup(l_hv).starttorele_num ..
1459       g_copcep_odlookup(l_hv).endtorele_num
1460     loop
1461       --
1462       l_inst_set.extend(1);
1463       l_inst_set(l_torrwnum) := g_copcep_odinst(l_insttorrw_num);
1464       l_torrwnum := l_torrwnum+1;
1465       --
1466     end loop;
1467     --
1468     hr_utility.set_location(' Dn Get loop  '||l_proc,10);
1469     p_inst_set := l_inst_set;
1470     --
1471   end if;
1472   hr_utility.set_location(' Leaving  '||l_proc,10);
1473 exception
1474   --
1475   when no_data_found then
1476     --
1477     null;
1478     --
1479 end cobcep_odgetdets;
1480 --
1481 procedure elpelc_getdets
1482 (p_business_group_id in     number
1483 ,p_effective_date    in     date
1484 ,p_eligy_prfl_id in     number default hr_api.g_number
1485 ,p_cache_code in     varchar2 default hr_api.g_varchar2
1486 --
1487 ,p_inst_set             out nocopy ben_elp_cache.g_elpelc_cache
1488 ,p_inst_count           out nocopy number
1489 )
1490 is
1491 --
1492 l_proc varchar2(72) :=  'elpelc_getdets';
1493 --
1494 l_instcolnm_set    ben_cache.InstColNmType;
1495 l_tabdet_set       ben_cache.TabDetType;
1496 --
1497 l_torrwnum         pls_integer;
1498 l_insttorrw_num    pls_integer;
1499 l_index            pls_integer;
1500 l_instcolnm_num    pls_integer;
1501 l_not_hash_found   boolean;
1502 l_mastertab_name   varchar2(100);
1503 l_masterpkcol_name varchar2(100);
1504 l_lkup_name        varchar2(100);
1505 l_inst_name        varchar2(100);
1506 l_table1_name      varchar2(100);
1507 l_tab1jncol_name   varchar2(100);
1508 l_table2_name      varchar2(100);
1509 l_tab2jncol_name   varchar2(100);
1510 l_table3_name      varchar2(100);
1511 --
1512 begin
1513 --
1514 -- Check if the lookup cache is populated
1515 --
1516 if (p_cache_code = 'ELPEPT' and ben_elp_cache.g_elpept_lookup.count = 0)
1517 or (p_cache_code = 'ELPEES' and ben_elp_cache.g_elpees_lookup.count = 0)
1518 or (p_cache_code = 'ELPESA' and ben_elp_cache.g_elpesa_lookup.count = 0)
1519 or (p_cache_code = 'ELPEHS' and ben_elp_cache.g_elpehs_lookup.count = 0)
1520 or (p_cache_code = 'ELPELS' and ben_elp_cache.g_elpels_lookup.count = 0)
1521 or (p_cache_code = 'ELPECP' and ben_elp_cache.g_elpecp_lookup.count = 0)
1522 then
1523 --
1524 -- Column and cache details
1525 --
1526 if p_cache_code = 'ELPEPT' then
1527 --
1528 l_mastertab_name            := 'ben_eligy_prfl_f';
1529 l_masterpkcol_name          := 'eligy_prfl_id';
1530 l_lkup_name                 := 'ben_elp_cache.g_elpept_lookup';
1531 l_inst_name                 := 'ben_elp_cache.g_elpept_inst';
1532 l_tabdet_set(0).tab_name    := 'ben_elig_per_typ_prte_f';
1533 --
1534 elsif p_cache_code = 'ELPEES' then
1535 --
1536 l_mastertab_name            := 'ben_eligy_prfl_f';
1537 l_masterpkcol_name          := 'eligy_prfl_id';
1538 l_lkup_name                 := 'ben_elp_cache.g_elpees_lookup';
1539 l_inst_name                 := 'ben_elp_cache.g_elpees_inst';
1540 l_tabdet_set(0).tab_name    := 'ben_elig_ee_stat_prte_f';
1541 --
1542 elsif p_cache_code = 'ELPESA' then
1543 --
1544 l_mastertab_name            := 'ben_eligy_prfl_f';
1545 l_masterpkcol_name          := 'eligy_prfl_id';
1546 l_lkup_name                 := 'ben_elp_cache.g_elpesa_lookup';
1547 l_inst_name                 := 'ben_elp_cache.g_elpesa_inst';
1548 l_tabdet_set(0).tab_name    := 'ben_elig_svc_area_prte_f';
1549 l_tabdet_set(0).tab_jncolnm := 'svc_area_id';
1550 l_tabdet_set(1).tab_name    := 'ben_svc_area_pstl_zip_rng_f';
1551 l_tabdet_set(1).tab_jncolnm := 'pstl_zip_rng_id';
1552 l_tabdet_set(2).tab_name    := 'ben_pstl_zip_rng_f';
1553 --
1554 elsif p_cache_code = 'ELPEHS' then
1555 --
1556 l_mastertab_name            := 'ben_eligy_prfl_f';
1557 l_masterpkcol_name          := 'eligy_prfl_id';
1558 l_lkup_name                 := 'ben_elp_cache.g_elpehs_lookup';
1559 l_inst_name                 := 'ben_elp_cache.g_elpehs_inst';
1560 l_tabdet_set(0).tab_name    := 'ben_elig_hrly_slrd_prte_f';
1561 --
1562 elsif p_cache_code = 'ELPELS' then
1563 --
1564 l_mastertab_name            := 'ben_eligy_prfl_f';
1565 l_masterpkcol_name          := 'eligy_prfl_id';
1566 l_lkup_name                 := 'ben_elp_cache.g_elpels_lookup';
1567 l_inst_name                 := 'ben_elp_cache.g_elpels_inst';
1568 l_tabdet_set(0).tab_name    := 'ben_elig_los_prte_f';
1569 l_tabdet_set(0).tab_jncolnm := 'los_fctr_id';
1570 l_tabdet_set(1).tab_name    := 'ben_los_fctr';
1571 l_tabdet_set(1).tab_datetype := 'nondt';
1572 --
1573 elsif p_cache_code = 'ELPECP' then
1574 --
1575 l_mastertab_name            := 'ben_eligy_prfl_f';
1576 l_masterpkcol_name          := 'eligy_prfl_id';
1577 l_lkup_name                 := 'ben_elp_cache.g_elpecp_lookup';
1578 l_inst_name                 := 'ben_elp_cache.g_elpecp_inst';
1579 l_tabdet_set(0).tab_name    := 'ben_elig_cmbn_age_los_prte_f';
1580 l_tabdet_set(0).tab_jncolnm := 'cmbn_age_los_fctr_id';
1581 l_tabdet_set(1).tab_name    := 'ben_cmbn_age_los_fctr';
1582 l_tabdet_set(1).tab_datetype := 'nondt';
1583 --
1584 end if;
1585 --
1586 l_instcolnm_num := 0;
1587 --
1588 l_instcolnm_set(l_instcolnm_num).col_name    := l_masterpkcol_name;
1589 l_instcolnm_set(l_instcolnm_num).caccol_name := 'eligy_prfl_id';
1590 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table1';
1591 l_instcolnm_set(l_instcolnm_num).col_type    := 'MASTER';
1592 l_instcolnm_num := l_instcolnm_num+1;
1593 --
1594 l_instcolnm_set(l_instcolnm_num).col_name    := 'excld_flag';
1595 l_instcolnm_set(l_instcolnm_num).caccol_name := 'excld_flag';
1596 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table1';
1597 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1598 l_instcolnm_num := l_instcolnm_num+1;
1599 --
1600 if p_cache_code = 'ELPEPT' then
1601 -- Not supporting per_typ_cd,instead use person_type_id
1602 --l_instcolnm_set(l_instcolnm_num).col_name    := 'per_typ_cd';
1603 l_instcolnm_set(l_instcolnm_num).col_name    := 'person_type_id';
1604 l_instcolnm_set(l_instcolnm_num).caccol_name := 'code';
1605 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table1';
1606 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1607 l_instcolnm_num := l_instcolnm_num+1;
1608 --
1609 elsif p_cache_code = 'ELPEES' then
1610 l_instcolnm_set(l_instcolnm_num).col_name    := 'assignment_status_type_id';
1611 l_instcolnm_set(l_instcolnm_num).caccol_name := 'id';
1612 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table1';
1613 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1614 l_instcolnm_num := l_instcolnm_num+1;
1615 --
1616 elsif p_cache_code = 'ELPESA' then
1617 l_instcolnm_set(l_instcolnm_num).col_name    := 'from_value';
1618 l_instcolnm_set(l_instcolnm_num).caccol_name := 'from_value';
1619 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table3';
1620 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1621 l_instcolnm_num := l_instcolnm_num+1;
1622 --
1623 l_instcolnm_set(l_instcolnm_num).col_name    := 'to_value';
1624 l_instcolnm_set(l_instcolnm_num).caccol_name := 'to_value';
1625 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table3';
1626 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1627 l_instcolnm_num := l_instcolnm_num+1;
1628 --
1629 elsif p_cache_code = 'ELPELS' then
1630 l_instcolnm_set(l_instcolnm_num).col_name    := 'mx_los_num';
1631 l_instcolnm_set(l_instcolnm_num).caccol_name := 'mx_num';
1632 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1633 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1634 l_instcolnm_num := l_instcolnm_num+1;
1635 --
1636 l_instcolnm_set(l_instcolnm_num).col_name    := 'mn_los_num';
1637 l_instcolnm_set(l_instcolnm_num).caccol_name := 'mn_num';
1638 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1639 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1640 l_instcolnm_num := l_instcolnm_num+1;
1641 --
1642 l_instcolnm_set(l_instcolnm_num).col_name    := 'no_mx_los_num_apls_flag';
1643 l_instcolnm_set(l_instcolnm_num).caccol_name := 'no_mx_num_apls_flag';
1644 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1645 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1646 l_instcolnm_num := l_instcolnm_num+1;
1647 --
1648 l_instcolnm_set(l_instcolnm_num).col_name    := 'no_mn_los_num_apls_flag';
1649 l_instcolnm_set(l_instcolnm_num).caccol_name := 'no_mn_num_apls_flag';
1650 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1651 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1652 l_instcolnm_num := l_instcolnm_num+1;
1653 --
1654 elsif p_cache_code = 'ELPECP' then
1655 l_instcolnm_set(l_instcolnm_num).col_name    := 'los_fctr_id';
1656 l_instcolnm_set(l_instcolnm_num).caccol_name := 'id';
1657 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1658 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1659 l_instcolnm_num := l_instcolnm_num+1;
1660 --
1661 l_instcolnm_set(l_instcolnm_num).col_name    := 'age_fctr_id';
1662 l_instcolnm_set(l_instcolnm_num).caccol_name := 'id1';
1663 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1664 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1665 l_instcolnm_num := l_instcolnm_num+1;
1666 --
1667 l_instcolnm_set(l_instcolnm_num).col_name    := 'cmbnd_min_val';
1668 l_instcolnm_set(l_instcolnm_num).caccol_name := 'cmbnd_min_val';
1669 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1670 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1671 l_instcolnm_num := l_instcolnm_num+1;
1672 --
1673 l_instcolnm_set(l_instcolnm_num).col_name    := 'cmbnd_max_val';
1674 l_instcolnm_set(l_instcolnm_num).caccol_name := 'cmbnd_max_val';
1675 l_instcolnm_set(l_instcolnm_num).col_alias   := 'table2';
1676 l_instcolnm_set(l_instcolnm_num).col_type    := 'SELECT';
1677 l_instcolnm_num := l_instcolnm_num+1;
1678 --
1679 end if;
1680 ben_cache.Write_BGP_Cache
1681 (p_mastertab_name    => l_mastertab_name
1682 ,p_masterpkcol_name  => l_masterpkcol_name
1683 ,p_tabdet_set        => l_tabdet_set
1684 ,p_table1_name       => l_table1_name
1685 ,p_tab1jncol_name    => l_tab1jncol_name
1686 ,p_table2_name       => l_table2_name
1687 ,p_tab2jncol_name    => l_tab2jncol_name
1688 ,p_table3_name       => l_table3_name
1689 ,p_business_group_id => p_business_group_id
1690 ,p_effective_date    => p_effective_date
1691 ,p_lkup_name         => l_lkup_name
1692 ,p_inst_name         => l_inst_name
1693 ,p_instcolnm_set     => l_instcolnm_set
1694 );
1695 --
1696 end if;
1697 --
1698 -- Get the instance details
1699 --
1700 l_torrwnum := 0;
1701 --
1702 if upper(p_cache_code) = 'ELPEPT' then
1703 --
1704 l_index  := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
1705 --
1706 -- Check if hashed value is already allocated
1707 --
1708 if g_elpept_lookup.exists(l_index) then
1709 --
1710 -- If it does exist make sure its the right one
1711 --
1712 if g_elpept_lookup(l_index).id <> p_eligy_prfl_id then
1713 --
1714 l_not_hash_found := false;
1715 --
1716 -- Loop until un-allocated has value is derived
1717 --
1718 while not l_not_hash_found loop
1719 --
1720 l_index := ben_hash_utility.get_next_hash_index
1721 (p_hash_index => l_index);
1722 --
1723 -- Check if the hash index exists, if not we can use it
1724 --
1725 if not g_elpept_lookup.exists(l_index) then
1726 --
1727 -- Lets store the hash value in the index
1728 --
1729 l_not_hash_found := true;
1730 exit;
1731 --
1732 else
1733 --
1734 l_not_hash_found := false;
1735 --
1736 end if;
1737 --
1738 end loop;
1739 --
1740 end if;
1741 --
1742 end if;
1743 --
1744 for l_insttorrw_num in g_elpept_lookup(l_index).starttorele_num ..
1745 g_elpept_lookup(l_index).endtorele_num
1746 loop
1747 --
1748 --
1749 p_inst_set(l_torrwnum) := g_elpept_inst(l_insttorrw_num);
1750 l_torrwnum := l_torrwnum+1;
1751 --
1752 end loop;
1753 --
1754 elsif upper(p_cache_code) = 'ELPEES' then
1755 --
1756 l_index  := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
1757 --
1758 -- Check if hashed value is already allocated
1759 --
1760 if g_elpees_lookup.exists(l_index) then
1761 --
1762 -- If it does exist make sure its the right one
1763 --
1764 if g_elpees_lookup(l_index).id <> p_eligy_prfl_id then
1765 --
1766 l_not_hash_found := false;
1767 --
1768 -- Loop until un-allocated has value is derived
1769 --
1770 while not l_not_hash_found loop
1771 --
1772 l_index := ben_hash_utility.get_next_hash_index
1773 (p_hash_index => l_index);
1774 --
1775 -- Check if the hash index exists, if not we can use it
1776 --
1777 if not g_elpees_lookup.exists(l_index) then
1778 --
1779 -- Lets store the hash value in the index
1780 --
1781 l_not_hash_found := true;
1782 exit;
1783 --
1784 else
1785 --
1786 l_not_hash_found := false;
1787 --
1788 end if;
1789 --
1790 end loop;
1791 --
1792 end if;
1793 --
1794 end if;
1795 --
1796 for l_insttorrw_num in g_elpees_lookup(l_index).starttorele_num ..
1797 g_elpees_lookup(l_index).endtorele_num
1798 loop
1799 --
1800 --
1801 p_inst_set(l_torrwnum) := g_elpees_inst(l_insttorrw_num);
1802 l_torrwnum := l_torrwnum+1;
1803 --
1804 end loop;
1805 --
1806 elsif upper(p_cache_code) = 'ELPESA' then
1807 --
1808 l_index  := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
1809 --
1810 -- Check if hashed value is already allocated
1811 --
1812 if g_elpesa_lookup.exists(l_index) then
1813 --
1814 -- If it does exist make sure its the right one
1815 --
1816 if g_elpesa_lookup(l_index).id <> p_eligy_prfl_id then
1817 --
1818 l_not_hash_found := false;
1819 --
1820 -- Loop until un-allocated has value is derived
1821 --
1822 while not l_not_hash_found loop
1823 --
1824 l_index := ben_hash_utility.get_next_hash_index
1825 (p_hash_index => l_index);
1826 --
1827 -- Check if the hash index exists, if not we can use it
1828 --
1829 if not g_elpesa_lookup.exists(l_index) then
1830 --
1831 -- Lets store the hash value in the index
1832 --
1833 l_not_hash_found := true;
1834 exit;
1835 --
1836 else
1837 --
1838 l_not_hash_found := false;
1839 --
1840 end if;
1841 --
1842 end loop;
1843 --
1844 end if;
1845 --
1846 end if;
1847 --
1848 for l_insttorrw_num in g_elpesa_lookup(l_index).starttorele_num ..
1849 g_elpesa_lookup(l_index).endtorele_num
1850 loop
1851 --
1852 --
1853 p_inst_set(l_torrwnum) := g_elpesa_inst(l_insttorrw_num);
1854 l_torrwnum := l_torrwnum+1;
1855 --
1856 end loop;
1857 --
1858 elsif upper(p_cache_code) = 'ELPEHS' then
1859 --
1860 l_index  := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
1861 --
1862 -- Check if hashed value is already allocated
1863 --
1864 if g_elpehs_lookup.exists(l_index) then
1865 --
1866 -- If it does exist make sure its the right one
1867 --
1868 if g_elpehs_lookup(l_index).id <> p_eligy_prfl_id then
1869 --
1870 l_not_hash_found := false;
1871 --
1872 -- Loop until un-allocated has value is derived
1873 --
1874 while not l_not_hash_found loop
1875 --
1876 l_index := ben_hash_utility.get_next_hash_index
1877 (p_hash_index => l_index);
1878 --
1879 -- Check if the hash index exists, if not we can use it
1880 --
1881 if not g_elpehs_lookup.exists(l_index) then
1882 --
1883 -- Lets store the hash value in the index
1884 --
1885 l_not_hash_found := true;
1886 exit;
1887 --
1888 else
1889 --
1890 l_not_hash_found := false;
1891 --
1892 end if;
1893 --
1894 end loop;
1895 --
1896 end if;
1897 --
1898 end if;
1899 --
1900 for l_insttorrw_num in g_elpehs_lookup(l_index).starttorele_num ..
1901 g_elpehs_lookup(l_index).endtorele_num
1902 loop
1903 --
1904 --
1905 p_inst_set(l_torrwnum) := g_elpehs_inst(l_insttorrw_num);
1906 l_torrwnum := l_torrwnum+1;
1907 --
1908 end loop;
1909 --
1910 elsif upper(p_cache_code) = 'ELPELS' then
1911 --
1912 l_index  := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
1913 --
1914 -- Check if hashed value is already allocated
1915 --
1916 if g_elpels_lookup.exists(l_index) then
1917 --
1918 -- If it does exist make sure its the right one
1919 --
1920 if g_elpels_lookup(l_index).id <> p_eligy_prfl_id then
1921 --
1922 l_not_hash_found := false;
1923 --
1924 -- Loop until un-allocated has value is derived
1925 --
1926 while not l_not_hash_found loop
1927 --
1928 l_index := ben_hash_utility.get_next_hash_index
1929 (p_hash_index => l_index);
1930 --
1931 -- Check if the hash index exists, if not we can use it
1932 --
1933 if not g_elpels_lookup.exists(l_index) then
1934 --
1935 -- Lets store the hash value in the index
1936 --
1937 l_not_hash_found := true;
1938 exit;
1939 --
1940 else
1941 --
1942 l_not_hash_found := false;
1943 --
1944 end if;
1945 --
1946 end loop;
1947 --
1948 end if;
1949 --
1950 end if;
1951 --
1952 for l_insttorrw_num in g_elpels_lookup(l_index).starttorele_num ..
1953 g_elpels_lookup(l_index).endtorele_num
1954 loop
1955 --
1956 --
1957 p_inst_set(l_torrwnum) := g_elpels_inst(l_insttorrw_num);
1958 l_torrwnum := l_torrwnum+1;
1959 --
1960 end loop;
1961 --
1962 elsif upper(p_cache_code) = 'ELPECP' then
1963 --
1964 l_index  := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
1965 --
1966 -- Check if hashed value is already allocated
1967 --
1968 if g_elpecp_lookup.exists(l_index) then
1969 --
1970 -- If it does exist make sure its the right one
1971 --
1972 if g_elpecp_lookup(l_index).id <> p_eligy_prfl_id then
1973 --
1974 l_not_hash_found := false;
1975 --
1976 -- Loop until un-allocated has value is derived
1977 --
1978 while not l_not_hash_found loop
1979 --
1980 l_index := ben_hash_utility.get_next_hash_index
1981 (p_hash_index => l_index);
1982 --
1983 -- Check if the hash index exists, if not we can use it
1984 --
1985 if not g_elpecp_lookup.exists(l_index) then
1986 --
1987 -- Lets store the hash value in the index
1988 --
1989 l_not_hash_found := true;
1990 exit;
1991 --
1992 else
1993 --
1994 l_not_hash_found := false;
1995 --
1996 end if;
1997 --
1998 end loop;
1999 --
2000 end if;
2001 --
2002 end if;
2003 --
2004 for l_insttorrw_num in g_elpecp_lookup(l_index).starttorele_num ..
2005 g_elpecp_lookup(l_index).endtorele_num
2006 loop
2007 --
2008 --
2009 p_inst_set(l_torrwnum) := g_elpecp_inst(l_insttorrw_num);
2010 l_torrwnum := l_torrwnum+1;
2011 --
2012 end loop;
2013 --
2014 end if;
2015 --
2016 p_inst_count := l_torrwnum;
2017 --
2018 exception
2019 when no_data_found then
2020 --
2021 p_inst_count := 0;
2022 --
2023 end elpelc_getdets;
2024 --
2025 procedure elpepg_writecache
2026   (p_effective_date in date,
2027    p_refresh_cache  in boolean default FALSE) is
2028   --
2029   l_proc varchar2(72) :=  'elpepg_writecache';
2030   l_torrwnum pls_integer;
2031   l_prev_id number;
2032   l_id number;
2033   --
2034   cursor c_elpepg_look is
2035     select elp.eligy_prfl_id,
2036            elp.business_group_id
2037     from   ben_eligy_prfl_f elp
2038     where  p_effective_date
2039            between elp.effective_start_date
2040            and     elp.effective_end_date
2041     and    exists(select null
2042                   from   ben_elig_ppl_grp_prte_f epg
2043                   where  p_effective_date
2044                          between epg.effective_start_date
2045                          and     epg.effective_end_date
2046                  and     epg.eligy_prfl_id = elp.eligy_prfl_id)
2047     order  by elp.eligy_prfl_id;
2048   --
2049   cursor c_elpepg_inst is
2050     select epg.eligy_prfl_id,
2051            epg.elig_ppl_grp_prte_id pk_id,
2052            'EPG' short_code,
2053            epg.people_group_id,
2054            epg.excld_flag,
2055            epg.criteria_score,
2056            epg.criteria_weight,
2057            ppg.segment1 ,
2058            ppg.segment2 ,
2059            ppg.segment3 ,
2060            ppg.segment4 ,
2061            ppg.segment5 ,
2062            ppg.segment6 ,
2063            ppg.segment7 ,
2064            ppg.segment8 ,
2065            ppg.segment9 ,
2066            ppg.segment10,
2067            ppg.segment11,
2068            ppg.segment12,
2069            ppg.segment13,
2070            ppg.segment14,
2071            ppg.segment15,
2072            ppg.segment16,
2073            ppg.segment17,
2074            ppg.segment18,
2075            ppg.segment19,
2076            ppg.segment20,
2077            ppg.segment21,
2078            ppg.segment22,
2079            ppg.segment23,
2080            ppg.segment24,
2081            ppg.segment25,
2082            ppg.segment26,
2083            ppg.segment27,
2084            ppg.segment28,
2085            ppg.segment29,
2086            ppg.segment30
2087     from   ben_elig_ppl_grp_prte_f epg
2088           ,pay_people_groups ppg
2089     where  p_effective_date
2090              between epg.effective_start_date
2091              and     epg.effective_end_date
2092            and epg.people_group_id = ppg.people_group_id
2093     order  by epg.eligy_prfl_id,
2094            decode(epg.excld_flag,'Y',1,2),
2095            epg.ordr_num;
2096   --
2097   l_not_hash_found boolean;
2098   --
2099 begin
2100   --
2101   for objlook in c_elpepg_look loop
2102     --
2103     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
2104     --
2105     -- Check if hashed value is already allocated
2106     --
2107     if g_cache_elpepg_lookup.exists(l_id) then
2108       --
2109       l_not_hash_found := false;
2110       --
2111       -- Loop until un-allocated has value is derived
2112       --
2113       while not l_not_hash_found loop
2114         --
2115         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2116         --
2117         -- Check if the hash index exists, if not we can use it
2118         --
2119         if not g_cache_elpepg_lookup.exists(l_id) then
2120           --
2121           -- Lets store the hash value in the index
2122           --
2123           l_not_hash_found := true;
2124           exit;
2125           --
2126         else
2127           --
2128           l_not_hash_found := false;
2129           --
2130         end if;
2131         --
2132       end loop;
2133       --
2134     end if;
2135     --
2136     g_cache_elpepg_lookup(l_id).id := objlook.eligy_prfl_id;
2137     g_cache_elpepg_lookup(l_id).fk_id := objlook.business_group_id;
2138     --
2139   end loop;
2140   --
2141   l_torrwnum := 0;
2142   l_prev_id := -1;
2143   --
2144   for objinst in c_elpepg_inst loop
2145     --
2146     -- Populate the cache lookup details
2147     --
2148     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
2149     --
2150     -- Check if hashed value is already allocated
2151     --
2152     if g_cache_elpepg_lookup(l_id).id = objinst.eligy_prfl_id then
2153       --
2154       null;
2155       --
2156     else
2157       --
2158       loop
2159         --
2160         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2161         --
2162         if g_cache_elpepg_lookup(l_id).id = objinst.eligy_prfl_id then
2163           --
2164           exit;
2165           --
2166         end if;
2167         --
2168       end loop;
2169       --
2170     end if;
2171     --
2172     -- Check for first row
2173     --
2174     if l_prev_id = -1 then
2175       --
2176       g_cache_elpepg_lookup(l_id).starttorele_num := l_torrwnum;
2177       --
2178     elsif l_id <> l_prev_id then
2179       --
2180       g_cache_elpepg_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2181       g_cache_elpepg_lookup(l_id).starttorele_num := l_torrwnum;
2182       --
2183     end if;
2184     --
2185     -- Populate the cache instance details
2186     --
2187     g_cache_elpepg_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
2188     g_cache_elpepg_inst(l_torrwnum).pk_id := objinst.pk_id;
2189     g_cache_elpepg_inst(l_torrwnum).short_code := objinst.short_code;
2190     g_cache_elpepg_inst(l_torrwnum).criteria_score := objinst.criteria_score;
2191     g_cache_elpepg_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
2192     g_cache_elpepg_inst(l_torrwnum).people_group_id := objinst.people_group_id;
2193     g_cache_elpepg_inst(l_torrwnum).excld_flag := objinst.excld_flag;
2194     g_cache_elpepg_inst(l_torrwnum).segment1  := objinst.segment1 ;
2195     g_cache_elpepg_inst(l_torrwnum).segment2  := objinst.segment2 ;
2196     g_cache_elpepg_inst(l_torrwnum).segment3  := objinst.segment3 ;
2197     g_cache_elpepg_inst(l_torrwnum).segment4  := objinst.segment4 ;
2198     g_cache_elpepg_inst(l_torrwnum).segment5  := objinst.segment5 ;
2199     g_cache_elpepg_inst(l_torrwnum).segment6  := objinst.segment6 ;
2200     g_cache_elpepg_inst(l_torrwnum).segment7  := objinst.segment7 ;
2201     g_cache_elpepg_inst(l_torrwnum).segment8  := objinst.segment8 ;
2202     g_cache_elpepg_inst(l_torrwnum).segment9  := objinst.segment9 ;
2203     g_cache_elpepg_inst(l_torrwnum).segment10 := objinst.segment10;
2204     g_cache_elpepg_inst(l_torrwnum).segment11 := objinst.segment11;
2205     g_cache_elpepg_inst(l_torrwnum).segment12 := objinst.segment12;
2206     g_cache_elpepg_inst(l_torrwnum).segment13 := objinst.segment13;
2207     g_cache_elpepg_inst(l_torrwnum).segment14 := objinst.segment14;
2208     g_cache_elpepg_inst(l_torrwnum).segment15 := objinst.segment15;
2209     g_cache_elpepg_inst(l_torrwnum).segment16 := objinst.segment16;
2210     g_cache_elpepg_inst(l_torrwnum).segment17 := objinst.segment17;
2211     g_cache_elpepg_inst(l_torrwnum).segment18 := objinst.segment18;
2212     g_cache_elpepg_inst(l_torrwnum).segment19 := objinst.segment19;
2213     g_cache_elpepg_inst(l_torrwnum).segment20 := objinst.segment20;
2214     g_cache_elpepg_inst(l_torrwnum).segment21 := objinst.segment21;
2215     g_cache_elpepg_inst(l_torrwnum).segment22 := objinst.segment22;
2216     g_cache_elpepg_inst(l_torrwnum).segment23 := objinst.segment23;
2217     g_cache_elpepg_inst(l_torrwnum).segment24 := objinst.segment24;
2218     g_cache_elpepg_inst(l_torrwnum).segment25 := objinst.segment25;
2219     g_cache_elpepg_inst(l_torrwnum).segment26 := objinst.segment26;
2220     g_cache_elpepg_inst(l_torrwnum).segment27 := objinst.segment27;
2221     g_cache_elpepg_inst(l_torrwnum).segment28 := objinst.segment28;
2222     g_cache_elpepg_inst(l_torrwnum).segment29 := objinst.segment29;
2223     g_cache_elpepg_inst(l_torrwnum).segment30 := objinst.segment30;
2224     --
2225     l_torrwnum := l_torrwnum+1;
2226     l_prev_id := l_id;
2227     --
2228   end loop;
2229   --
2230   g_cache_elpepg_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2231   --
2232 end elpepg_writecache;
2233 --
2234 procedure elpepg_getcacdets
2235   (p_effective_date    in  date,
2236    p_business_group_id in  number,
2237    p_eligy_prfl_id     in  number,
2238    p_refresh_cache     in  boolean default FALSE,
2239    p_inst_set          out nocopy ben_elp_cache.g_cache_elpepg_instor,
2240    p_inst_count        out nocopy number) is
2241   --
2242   l_proc varchar2(72) :=  'elpepg_getcacdets';
2243   l_torrwnum pls_integer;
2244   l_insttorrw_num pls_integer;
2245   l_index         pls_integer;
2246   --
2247   l_not_hash_found boolean;
2248   --
2249 begin
2250   --
2251   -- Flush the cache
2252   --
2253   if p_refresh_cache then
2254     --
2255     g_cache_elpepg_lookup.delete;
2256     g_cache_elpepg_inst.delete;
2257     --
2258   end if;
2259   --
2260   -- Populate the global cache
2261   --
2262   if g_cache_elpepg_lookup.count = 0 then
2263     --
2264     -- Build the cache
2265     --
2266     ben_elp_cache.elpepg_writecache
2267       (p_effective_date => p_effective_date,
2268        p_refresh_cache  => p_refresh_cache);
2269     --
2270   end if;
2271   --
2272   -- Get the instance details
2273   --
2274   l_torrwnum := 0;
2275   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
2276   --
2277   -- Check if hashed value is already allocated
2278   --
2279   if g_cache_elpepg_lookup.exists(l_index) then
2280     --
2281     -- If it does exist make sure its the right one
2282     --
2283     if g_cache_elpepg_lookup(l_index).id <> p_eligy_prfl_id then
2284       --
2285       l_not_hash_found := false;
2286       --
2287       -- Loop until un-allocated has value is derived
2288       --
2289       while not l_not_hash_found loop
2290         --
2291         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
2292         --
2293         -- Check if the hash index exists, if not we can use it
2294         --
2295         if not g_cache_elpepg_lookup.exists(l_index) then
2296           --
2297           -- Lets store the hash value in the index
2298           --
2299           l_not_hash_found := true;
2300           exit;
2301           --
2302         else
2303           --
2304           l_not_hash_found := false;
2305           --
2306         end if;
2307         --
2308       end loop;
2309     --
2310     end if;
2311     --
2312   end if;
2313   --
2314   for l_insttorrw_num in g_cache_elpepg_lookup(l_index).starttorele_num ..
2315     g_cache_elpepg_lookup(l_index).endtorele_num loop
2316     --
2317     p_inst_set(l_torrwnum) := g_cache_elpepg_inst(l_insttorrw_num);
2318     l_torrwnum := l_torrwnum+1;
2319     --
2320   end loop;
2321   --
2322   p_inst_count := l_torrwnum;
2323   --
2324 exception
2325   --
2326   when no_data_found then
2327     --
2328     p_inst_count := 0;
2329     --
2330 end elpepg_getcacdets;
2331 --
2332 procedure elpept_writecache
2333   (p_effective_date in date,
2334    p_refresh_cache  in boolean default FALSE) is
2335   --
2336   l_proc varchar2(72) :=  'elpept_writecache';
2337   l_torrwnum pls_integer;
2338   l_prev_id number;
2339   l_id number;
2340   --
2341   cursor c_elpept_look is
2342     select elp.eligy_prfl_id,
2343            elp.business_group_id
2344     from   ben_eligy_prfl_f elp
2345     where  p_effective_date
2346            between elp.effective_start_date
2347            and     elp.effective_end_date
2348     and    exists(select null
2349                   from   ben_elig_per_typ_prte_f ept
2350                   where  p_effective_date
2351                          between ept.effective_start_date
2352                          and     ept.effective_end_date
2353                   and    ept.eligy_prfl_id = elp.eligy_prfl_id)
2354     order  by elp.eligy_prfl_id;
2355   --
2356   -- Not supporting per_typ_cd,instead use person_type_id
2357   --
2358   cursor c_elpept_inst is
2359     select ept.eligy_prfl_id,
2360            ept.elig_per_typ_prte_id pk_id,
2361            'EPT' short_code,
2362            --ept.per_typ_cd,
2363            ept.person_type_id,
2364            ept.excld_flag,
2365            ept.criteria_score,
2366            ept.criteria_weight
2367     from   ben_elig_per_typ_prte_f ept
2368     where  p_effective_date
2369            between ept.effective_start_date
2370            and     ept.effective_end_date
2371     order  by ept.eligy_prfl_id,
2372            decode(ept.excld_flag,'Y',1,2),
2373            ept.ordr_num;
2374   --
2375   l_not_hash_found boolean;
2376   --
2377 begin
2378   --
2379   for objlook in c_elpept_look loop
2380     --
2381     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
2382     --
2383     -- Check if hashed value is already allocated
2384     --
2385     if g_cache_elpept_lookup.exists(l_id) then
2386       --
2387       l_not_hash_found := false;
2388       --
2389       -- Loop until un-allocated has value is derived
2390       --
2391       while not l_not_hash_found loop
2392         --
2393         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2394         --
2395         -- Check if the hash index exists, if not we can use it
2396         --
2397         if not g_cache_elpept_lookup.exists(l_id) then
2398           --
2399           -- Lets store the hash value in the index
2400           --
2401           l_not_hash_found := true;
2402           exit;
2403           --
2404         else
2405           --
2406           l_not_hash_found := false;
2407           --
2408         end if;
2409       --
2410       end loop;
2411       --
2412     end if;
2413     --
2414     g_cache_elpept_lookup(l_id).id := objlook.eligy_prfl_id;
2415     g_cache_elpept_lookup(l_id).fk_id := objlook.business_group_id;
2416     --
2417   end loop;
2418   --
2419   l_torrwnum := 0;
2420   l_prev_id := -1;
2421   --
2422   for objinst in c_elpept_inst loop
2423     --
2424     -- Populate the cache lookup details
2425     --
2426     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
2427     --
2428     -- Check if hashed value is already allocated
2429     --
2430     if g_cache_elpept_lookup(l_id).id = objinst.eligy_prfl_id then
2431       --
2432       null;
2433       --
2434     else
2435       --
2436       loop
2437         --
2438         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2439         --
2440         if g_cache_elpept_lookup(l_id).id = objinst.eligy_prfl_id then
2441           --
2442           exit;
2443           --
2444         end if;
2445         --
2446       end loop;
2447       --
2448     end if;
2449     --
2450     -- Check for first row
2451     --
2452     if l_prev_id = -1 then
2453       --
2454       g_cache_elpept_lookup(l_id).starttorele_num := l_torrwnum;
2455       --
2456     elsif l_id <> l_prev_id then
2457       --
2458       g_cache_elpept_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2459       g_cache_elpept_lookup(l_id).starttorele_num := l_torrwnum;
2460       --
2461     end if;
2462     --
2463     -- Populate the cache instance details
2464     --
2465     g_cache_elpept_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
2466     g_cache_elpept_inst(l_torrwnum).pk_id := objinst.pk_id;
2467     g_cache_elpept_inst(l_torrwnum).short_code := objinst.short_code;
2468     g_cache_elpept_inst(l_torrwnum).criteria_score := objinst.criteria_score;
2469     g_cache_elpept_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
2470     --
2471     -- Not supporting per_typ_cd,instead use person_type_id
2472     -- g_cache_elpept_inst(l_torrwnum).per_typ_cd := objinst.per_typ_cd;
2473     --
2474     g_cache_elpept_inst(l_torrwnum).person_type_id := objinst.person_type_id;
2475     g_cache_elpept_inst(l_torrwnum).excld_flag := objinst.excld_flag;
2476     --
2477     l_torrwnum := l_torrwnum+1;
2478     l_prev_id := l_id;
2479     --
2480   end loop;
2481   --
2482   g_cache_elpept_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2483   --
2484 end elpept_writecache;
2485 --
2486 procedure elpept_getcacdets
2487   (p_effective_date    in date,
2488    p_business_group_id in number,
2489    p_eligy_prfl_id     in number,
2490    p_refresh_cache     in boolean default FALSE,
2491    p_inst_set          out nocopy ben_elp_cache.g_cache_elpept_instor,
2492    p_inst_count        out nocopy number) is
2493   --
2494   l_proc varchar2(72) :=  'elpept_getcacdets';
2495   l_torrwnum pls_integer;
2496   l_insttorrw_num pls_integer;
2497   l_index         pls_integer;
2498   --
2499   l_not_hash_found boolean;
2500   --
2501 begin
2502   --
2503   -- Flush the cache
2504   --
2505   if p_refresh_cache then
2506     --
2507     g_cache_elpept_lookup.delete;
2508     g_cache_elpept_inst.delete;
2509     --
2510   end if;
2511   --
2512   -- Populate the global cache
2513   --
2514   if g_cache_elpept_lookup.count = 0 then
2515     --
2516     -- Build the cache
2517     --
2518     ben_elp_cache.elpept_writecache
2519       (p_effective_date => p_effective_date,
2520        p_refresh_cache  => p_refresh_cache);
2521     --
2522   end if;
2523   --
2524   -- Get the instance details
2525   --
2526   l_torrwnum := 0;
2527   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
2528   --
2529   -- Check if hashed value is already allocated
2530   --
2531   if g_cache_elpept_lookup.exists(l_index) then
2532     --
2533     -- If it does exist make sure its the right one
2534     --
2535     if g_cache_elpept_lookup(l_index).id <> p_eligy_prfl_id then
2536       --
2537       l_not_hash_found := false;
2538       --
2539       -- Loop until un-allocated has value is derived
2540       --
2541       while not l_not_hash_found loop
2542         --
2543         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
2544         --
2545         -- Check if the hash index exists, if not we can use it
2546         --
2547         if not g_cache_elpept_lookup.exists(l_index) then
2548           --
2549           -- Lets store the hash value in the index
2550           --
2551           l_not_hash_found := true;
2552           exit;
2553           --
2554         else
2555           --
2556           l_not_hash_found := false;
2557           --
2558         end if;
2559         --
2560       end loop;
2561       --
2562     end if;
2563     --
2564   end if;
2565   --
2566   for l_insttorrw_num in g_cache_elpept_lookup(l_index).starttorele_num ..
2567     g_cache_elpept_lookup(l_index).endtorele_num loop
2568     --
2569     p_inst_set(l_torrwnum) := g_cache_elpept_inst(l_insttorrw_num);
2570     l_torrwnum := l_torrwnum+1;
2571     --
2572   end loop;
2573   --
2574   p_inst_count := l_torrwnum;
2575   --
2576 exception
2577   --
2578   when no_data_found then
2579     --
2580     p_inst_count := 0;
2581     --
2582 end elpept_getcacdets;
2583 --
2584 procedure elpean_writecache
2585   (p_effective_date in date,
2586    p_refresh_cache  in boolean default FALSE) is
2587   --
2588   l_proc varchar2(72) :=  'elpean_writecache';
2589   l_torrwnum pls_integer;
2590   l_prev_id number;
2591   l_id number;
2592   --
2593   cursor c_elpean_look is
2594     select elp.eligy_prfl_id,
2595            elp.business_group_id
2596     from   ben_eligy_prfl_f elp
2597     where  p_effective_date
2598            between elp.effective_start_date
2599            and     elp.effective_end_date
2600     and    exists(select null
2601                   from   ben_elig_asnt_set_prte_f ean
2602                   where  p_effective_date
2603                          between ean.effective_start_date
2604                          and     ean.effective_end_date
2605                   and    ean.eligy_prfl_id = elp.eligy_prfl_id)
2606     order  by elp.eligy_prfl_id;
2607   --
2608   cursor c_elpean_inst is
2609     select ean.eligy_prfl_id,
2610            ean.elig_asnt_set_prte_id pk_id,
2611            'EAN' short_code,
2612            ass.formula_id,
2613            ean.excld_flag,
2614            ean.criteria_score,
2615            ean.criteria_weight
2616     from   ben_elig_asnt_set_prte_f ean,
2617            hr_assignment_sets ass
2618     where  p_effective_date
2619            between ean.effective_start_date
2620            and     ean.effective_end_date
2621     and    ean.assignment_set_id = ass.assignment_set_id
2622     order  by ean.eligy_prfl_id,
2623            decode(ean.excld_flag,'Y',1,2),
2624            ean.ordr_num;
2625   --
2626   l_not_hash_found boolean;
2627   --
2628 begin
2629   --
2630   for objlook in c_elpean_look loop
2631     --
2632     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
2633     --
2634     -- Check if hashed value is already allocated
2635     --
2636     if g_cache_elpean_lookup.exists(l_id) then
2637       --
2638       l_not_hash_found := false;
2639       --
2640       -- Loop until un-allocated has value is derived
2641       --
2642       while not l_not_hash_found loop
2643         --
2644         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2645         --
2646         -- Check if the hash index exists, if not we can use it
2647         --
2648         if not g_cache_elpean_lookup.exists(l_id) then
2649           --
2650           -- Lets store the hash value in the index
2651           --
2652           l_not_hash_found := true;
2653           exit;
2654           --
2655         else
2656           --
2657           l_not_hash_found := false;
2658           --
2659         end if;
2660       --
2661       end loop;
2662       --
2663     end if;
2664     --
2665     g_cache_elpean_lookup(l_id).id := objlook.eligy_prfl_id;
2666     g_cache_elpean_lookup(l_id).fk_id := objlook.business_group_id;
2667     --
2668   end loop;
2669   --
2670   l_torrwnum := 0;
2671   l_prev_id := -1;
2672   --
2673   for objinst in c_elpean_inst loop
2674     --
2675     -- Populate the cache lookup details
2676     --
2677     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
2678     --
2679     -- Check if hashed value is already allocated
2680     --
2681     if g_cache_elpean_lookup(l_id).id = objinst.eligy_prfl_id then
2682       --
2683       null;
2684       --
2685     else
2686       --
2687       loop
2688         --
2689         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2690         --
2691         if g_cache_elpean_lookup(l_id).id = objinst.eligy_prfl_id then
2692           --
2693           exit;
2694           --
2695         end if;
2696         --
2697       end loop;
2698       --
2699     end if;
2700     --
2701     -- Check for first row
2702     --
2703     if l_prev_id = -1 then
2704       --
2705       g_cache_elpean_lookup(l_id).starttorele_num := l_torrwnum;
2706       --
2707     elsif l_id <> l_prev_id then
2708       --
2709       g_cache_elpean_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2710       g_cache_elpean_lookup(l_id).starttorele_num := l_torrwnum;
2711       --
2712     end if;
2713     --
2714     -- Populate the cache instance details
2715     --
2716     g_cache_elpean_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
2717     g_cache_elpean_inst(l_torrwnum).pk_id := objinst.pk_id;
2718     g_cache_elpean_inst(l_torrwnum).short_code := objinst.short_code;
2719     g_cache_elpean_inst(l_torrwnum).criteria_score := objinst.criteria_score;
2720     g_cache_elpean_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
2721     g_cache_elpean_inst(l_torrwnum).formula_id := objinst.formula_id;
2722     g_cache_elpean_inst(l_torrwnum).excld_flag := objinst.excld_flag;
2723     --
2724     l_torrwnum := l_torrwnum+1;
2725     l_prev_id := l_id;
2726     --
2727   end loop;
2728   --
2729   g_cache_elpean_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2730   --
2731 end elpean_writecache;
2732 --
2733 procedure elpean_getcacdets
2734   (p_effective_date    in date,
2735    p_business_group_id in number,
2736    p_eligy_prfl_id     in number,
2737    p_refresh_cache     in boolean default FALSE,
2738    p_inst_set          out nocopy ben_elp_cache.g_cache_elpean_instor,
2739    p_inst_count        out nocopy number) is
2740   --
2741   l_proc varchar2(72) :=  'elpean_getcacdets';
2742   l_torrwnum pls_integer;
2743   l_insttorrw_num pls_integer;
2744   l_index         pls_integer;
2745   --
2746   l_not_hash_found boolean;
2747   --
2748 begin
2749   --
2750   -- Flush the cache
2751   --
2752   if p_refresh_cache then
2753     --
2754     g_cache_elpean_lookup.delete;
2755     g_cache_elpean_inst.delete;
2756     --
2757   end if;
2758   --
2759   -- Populate the global cache
2760   --
2761   if g_cache_elpean_lookup.count = 0 then
2762     --
2763     -- Build the cache
2764     --
2765     ben_elp_cache.elpean_writecache
2766       (p_effective_date => p_effective_date,
2767        p_refresh_cache  => p_refresh_cache);
2768     --
2769   end if;
2770   --
2771   -- Get the instance details
2772   --
2773   l_torrwnum := 0;
2774   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
2775   --
2776   -- Check if hashed value is already allocated
2777   --
2778   if g_cache_elpean_lookup.exists(l_index) then
2779     --
2780     -- If it does exist make sure its the right one
2781     --
2782     if g_cache_elpean_lookup(l_index).id <> p_eligy_prfl_id then
2783       --
2784       l_not_hash_found := false;
2785       --
2786       -- Loop until un-allocated has value is derived
2787       --
2788       while not l_not_hash_found loop
2789         --
2790         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
2791         --
2792         -- Check if the hash index exists, if not we can use it
2793         --
2794         if not g_cache_elpean_lookup.exists(l_index) then
2795           --
2796           -- Lets store the hash value in the index
2797           --
2798           l_not_hash_found := true;
2799           exit;
2800           --
2801         else
2802           --
2803           l_not_hash_found := false;
2804           --
2805         end if;
2806         --
2807       end loop;
2808       --
2809     end if;
2810     --
2811   end if;
2812   --
2813   for l_insttorrw_num in g_cache_elpean_lookup(l_index).starttorele_num ..
2814     g_cache_elpean_lookup(l_index).endtorele_num loop
2815     --
2816     p_inst_set(l_torrwnum) := g_cache_elpean_inst(l_insttorrw_num);
2817     l_torrwnum := l_torrwnum+1;
2818     --
2819   end loop;
2820   --
2821   p_inst_count := l_torrwnum;
2822   --
2823 exception
2824   --
2825   when no_data_found then
2826     --
2827     p_inst_count := 0;
2828     --
2829 end elpean_getcacdets;
2830 --
2831 procedure elperl_writecache
2832   (p_effective_date in date,
2833    p_refresh_cache  in boolean default FALSE) is
2834   --
2835   l_proc varchar2(72) :=  'elperl_writecache';
2836   l_torrwnum pls_integer;
2837   l_prev_id number;
2838   l_id number;
2839   --
2840   cursor c_elperl_look is
2841     select elp.eligy_prfl_id,
2842            elp.business_group_id
2843     from   ben_eligy_prfl_f elp
2844     where  p_effective_date
2845            between elp.effective_start_date
2846            and     elp.effective_end_date
2847     and    exists(select null
2848                   from   ben_eligy_prfl_rl_f erl
2849                   where  p_effective_date
2850                          between erl.effective_start_date
2851                          and     erl.effective_end_date
2852                   and    erl.eligy_prfl_id = elp.eligy_prfl_id)
2853     order  by elp.eligy_prfl_id;
2854   --
2855   cursor c_elperl_inst is
2856     select erl.eligy_prfl_id,
2857            erl.eligy_prfl_rl_id pk_id,
2858            'ERL' short_code,
2859            erl.formula_id,
2860            erl.criteria_score,
2861            erl.criteria_weight
2862     from   ben_eligy_prfl_rl_f erl
2863     where  p_effective_date
2864            between erl.effective_start_date
2865            and     erl.effective_end_date
2866     order  by erl.eligy_prfl_id,
2867            erl.ordr_to_aply_num;
2868   --
2869   l_not_hash_found boolean;
2870   --
2871 begin
2872   --
2873   for objlook in c_elperl_look loop
2874     --
2875     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
2876     --
2877     -- Check if hashed value is already allocated
2878     --
2879     if g_cache_elperl_lookup.exists(l_id) then
2880       --
2881       l_not_hash_found := false;
2882       --
2883       -- Loop until un-allocated has value is derived
2884       --
2885       while not l_not_hash_found loop
2886         --
2887         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2888         --
2889         -- Check if the hash index exists, if not we can use it
2890         --
2891         if not g_cache_elperl_lookup.exists(l_id) then
2892           --
2893           -- Lets store the hash value in the index
2894           --
2895           l_not_hash_found := true;
2896           exit;
2897           --
2898         else
2899           --
2900           l_not_hash_found := false;
2901           --
2902         end if;
2903       --
2904       end loop;
2905       --
2906     end if;
2907     --
2908     g_cache_elperl_lookup(l_id).id := objlook.eligy_prfl_id;
2909     g_cache_elperl_lookup(l_id).fk_id := objlook.business_group_id;
2910     --
2911   end loop;
2912   --
2913   l_torrwnum := 0;
2914   l_prev_id := -1;
2915   --
2916   for objinst in c_elperl_inst loop
2917     --
2918     -- Populate the cache lookup details
2919     --
2920     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
2921     --
2922     -- Check if hashed value is already allocated
2923     --
2924     if g_cache_elperl_lookup(l_id).id = objinst.eligy_prfl_id then
2925       --
2926       null;
2927       --
2928     else
2929       --
2930       loop
2931         --
2932         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
2933         --
2934         if g_cache_elperl_lookup(l_id).id = objinst.eligy_prfl_id then
2935           --
2936           exit;
2937           --
2938         end if;
2939         --
2940       end loop;
2941       --
2942     end if;
2943     --
2944     -- Check for first row
2945     --
2946     if l_prev_id = -1 then
2947       --
2948       g_cache_elperl_lookup(l_id).starttorele_num := l_torrwnum;
2949       --
2950     elsif l_id <> l_prev_id then
2951       --
2952       g_cache_elperl_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2953       g_cache_elperl_lookup(l_id).starttorele_num := l_torrwnum;
2954       --
2955     end if;
2956     --
2957     -- Populate the cache instance details
2958     --
2959     g_cache_elperl_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
2960     g_cache_elperl_inst(l_torrwnum).pk_id := objinst.pk_id;
2961     g_cache_elperl_inst(l_torrwnum).short_code := objinst.short_code;
2962     g_cache_elperl_inst(l_torrwnum).criteria_score := objinst.criteria_score;
2963     g_cache_elperl_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
2964     g_cache_elperl_inst(l_torrwnum).formula_id := objinst.formula_id;
2965     --
2966     l_torrwnum := l_torrwnum+1;
2967     l_prev_id := l_id;
2968     --
2969   end loop;
2970   --
2971   g_cache_elperl_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
2972   --
2973 end elperl_writecache;
2974 --
2975 procedure elperl_getcacdets
2976   (p_effective_date    in date,
2977    p_business_group_id in number,
2978    p_eligy_prfl_id     in number,
2979    p_refresh_cache     in boolean default FALSE,
2980    p_inst_set          out nocopy ben_elp_cache.g_cache_elperl_instor,
2981    p_inst_count        out nocopy number) is
2982   --
2983   l_proc varchar2(72) :=  'elperl_getcacdets';
2984   l_torrwnum pls_integer;
2985   l_insttorrw_num pls_integer;
2986   l_index         pls_integer;
2987   --
2988   l_not_hash_found boolean;
2989   --
2990 begin
2991   --
2992   -- Flush the cache
2993   --
2994   if p_refresh_cache then
2995     --
2996     g_cache_elperl_lookup.delete;
2997     g_cache_elperl_inst.delete;
2998     --
2999   end if;
3000   --
3001   -- Populate the global cache
3002   --
3003   if g_cache_elperl_lookup.count = 0 then
3004     --
3005     -- Build the cache
3006     --
3007     ben_elp_cache.elperl_writecache
3008       (p_effective_date => p_effective_date,
3009        p_refresh_cache  => p_refresh_cache);
3010     --
3011   end if;
3012   --
3013   -- Get the instance details
3014   --
3015   l_torrwnum := 0;
3016   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
3017   --
3018   -- Check if hashed value is already allocated
3019   --
3020   if g_cache_elperl_lookup.exists(l_index) then
3021     --
3022     -- If it does exist make sure its the right one
3023     --
3024     if g_cache_elperl_lookup(l_index).id <> p_eligy_prfl_id then
3025       --
3026       l_not_hash_found := false;
3027       --
3028       -- Loop until un-allocated has value is derived
3029       --
3030       while not l_not_hash_found loop
3031         --
3032         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
3033         --
3034         -- Check if the hash index exists, if not we can use it
3035         --
3036         if not g_cache_elperl_lookup.exists(l_index) then
3037           --
3038           -- Lets store the hash value in the index
3039           --
3040           l_not_hash_found := true;
3041           exit;
3042           --
3043         else
3044           --
3045           l_not_hash_found := false;
3046           --
3047         end if;
3048         --
3049       end loop;
3050       --
3051     end if;
3052     --
3053   end if;
3054   --
3055   for l_insttorrw_num in g_cache_elperl_lookup(l_index).starttorele_num ..
3056     g_cache_elperl_lookup(l_index).endtorele_num loop
3057     --
3058     p_inst_set(l_torrwnum) := g_cache_elperl_inst(l_insttorrw_num);
3059     l_torrwnum := l_torrwnum+1;
3060     --
3061   end loop;
3062   --
3063   p_inst_count := l_torrwnum;
3064   --
3065 exception
3066   --
3067   when no_data_found then
3068     --
3069     p_inst_count := 0;
3070     --
3071 end elperl_getcacdets;
3072 --
3073 procedure elpees_writecache
3074   (p_effective_date in date,
3075    p_refresh_cache  in boolean default FALSE) is
3076   --
3077   l_proc varchar2(72) :=  'elpees_writecache';
3078   l_torrwnum pls_integer;
3079   l_prev_id number;
3080   l_id number;
3081   --
3082   cursor c_elpees_look is
3083     select elp.eligy_prfl_id,
3084            elp.business_group_id
3085     from   ben_eligy_prfl_f elp
3086     where  p_effective_date
3087            between elp.effective_start_date
3088            and     elp.effective_end_date
3089     and    exists(select null
3090                   from   ben_elig_ee_stat_prte_f ees
3091                   where  p_effective_date
3092                          between ees.effective_start_date
3093                          and     ees.effective_end_date
3094                   and    ees.eligy_prfl_id = elp.eligy_prfl_id)
3095     order  by elp.eligy_prfl_id;
3096   --
3097   cursor c_elpees_inst is
3098     select ees.eligy_prfl_id,
3099            ees.elig_ee_stat_prte_id pk_id,
3100            'EES' short_code,
3101            ees.assignment_status_type_id,
3102            ees.excld_flag,
3103            ees.criteria_score,
3104            ees.criteria_weight
3105     from   ben_elig_ee_stat_prte_f ees
3106     where  p_effective_date
3107            between ees.effective_start_date
3108            and ees.effective_end_date
3109     order  by ees.eligy_prfl_id,
3110            decode(ees.excld_flag,'Y',1,2),
3111            ees.ordr_num;
3112   --
3113   l_not_hash_found boolean;
3114   --
3115 begin
3116   --
3117   for objlook in c_elpees_look loop
3118     --
3119     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
3120     --
3121     -- Check if hashed value is already allocated
3122     --
3123     if g_cache_elpees_lookup.exists(l_id) then
3124       --
3125       l_not_hash_found := false;
3126       --
3127       -- Loop until un-allocated has value is derived
3128       --
3129       while not l_not_hash_found loop
3130         --
3131         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3132         --
3133         -- Check if the hash index exists, if not we can use it
3134         --
3135         if not g_cache_elpees_lookup.exists(l_id) then
3136           --
3137           -- Lets store the hash value in the index
3138           --
3139           l_not_hash_found := true;
3140           exit;
3141           --
3142         else
3143           --
3144           l_not_hash_found := false;
3145           --
3146         end if;
3147       --
3148       end loop;
3149       --
3150     end if;
3151     --
3152     g_cache_elpees_lookup(l_id).id := objlook.eligy_prfl_id;
3153     g_cache_elpees_lookup(l_id).fk_id := objlook.business_group_id;
3154     --
3155   end loop;
3156   --
3157   l_torrwnum := 0;
3158   l_prev_id := -1;
3159   --
3160   for objinst in c_elpees_inst loop
3161     --
3162     -- Populate the cache lookup details
3163     --
3164     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
3165     --
3166     -- Check if hashed value is already allocated
3167     --
3168     if g_cache_elpees_lookup(l_id).id = objinst.eligy_prfl_id then
3169       --
3170       null;
3171       --
3172     else
3173       --
3174       loop
3175         --
3176         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3177         --
3178         if g_cache_elpees_lookup(l_id).id = objinst.eligy_prfl_id then
3179           --
3180           exit;
3181           --
3182         end if;
3183         --
3184       end loop;
3185       --
3186     end if;
3187     --
3188     -- Check for first row
3189     --
3190     if l_prev_id = -1 then
3191       --
3192       g_cache_elpees_lookup(l_id).starttorele_num := l_torrwnum;
3193       --
3194     elsif l_id <> l_prev_id then
3195       --
3196       g_cache_elpees_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3197       g_cache_elpees_lookup(l_id).starttorele_num := l_torrwnum;
3198       --
3199     end if;
3200     --
3201     -- Populate the cache instance details
3202     --
3203     g_cache_elpees_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
3204     g_cache_elpees_inst(l_torrwnum).pk_id := objinst.pk_id;
3205     g_cache_elpees_inst(l_torrwnum).short_code := objinst.short_code;
3206     g_cache_elpees_inst(l_torrwnum).criteria_score := objinst.criteria_score;
3207     g_cache_elpees_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
3208     g_cache_elpees_inst(l_torrwnum).assignment_status_type_id := objinst.assignment_status_type_id;
3209     g_cache_elpees_inst(l_torrwnum).excld_flag := objinst.excld_flag;
3210     --
3211     l_torrwnum := l_torrwnum+1;
3212     l_prev_id := l_id;
3213     --
3214   end loop;
3215   --
3216   g_cache_elpees_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3217   --
3218 end elpees_writecache;
3219 --
3220 procedure elpees_getcacdets
3221   (p_effective_date    in  date,
3222    p_business_group_id in  number,
3223    p_eligy_prfl_id     in  number,
3224    p_refresh_cache     in  boolean default FALSE,
3225    p_inst_set          out nocopy ben_elp_cache.g_cache_elpees_instor,
3226    p_inst_count        out nocopy number) is
3227   --
3228   l_proc varchar2(72) :=  'elpees_getcacdets';
3229   l_torrwnum pls_integer;
3230   l_insttorrw_num pls_integer;
3231   l_index         pls_integer;
3232   --
3233   l_not_hash_found boolean;
3234   --
3235 begin
3236   --
3237   -- Flush the cache
3238   --
3239   if p_refresh_cache then
3240     --
3241     g_cache_elpees_lookup.delete;
3242     g_cache_elpees_inst.delete;
3243     --
3244   end if;
3245   --
3246   -- Populate the global cache
3247   --
3248   if g_cache_elpees_lookup.count = 0 then
3249     --
3250     -- Build the cache
3251     --
3252     ben_elp_cache.elpees_writecache
3253       (p_effective_date => p_effective_date,
3254        p_refresh_cache  => p_refresh_cache);
3255     --
3256   end if;
3257   --
3258   -- Get the instance details
3259   --
3260   l_torrwnum := 0;
3261   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
3262   --
3263   -- Check if hashed value is already allocated
3264   --
3265   if g_cache_elpees_lookup.exists(l_index) then
3266     --
3267     -- If it does exist make sure its the right one
3268     --
3269     if g_cache_elpees_lookup(l_index).id <> p_eligy_prfl_id then
3270       --
3271       l_not_hash_found := false;
3272       --
3273       -- Loop until un-allocated has value is derived
3274       --
3275       while not l_not_hash_found loop
3276         --
3277         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
3278         --
3279         -- Check if the hash index exists, if not we can use it
3280         --
3281         if not g_cache_elpees_lookup.exists(l_index) then
3282           --
3283           -- Lets store the hash value in the index
3284           --
3285           l_not_hash_found := true;
3286           exit;
3287           --
3288         else
3289           --
3290           l_not_hash_found := false;
3291           --
3292         end if;
3293         --
3294       end loop;
3295       --
3296     end if;
3297     --
3298   end if;
3299   --
3300   for l_insttorrw_num in g_cache_elpees_lookup(l_index).starttorele_num ..
3301     g_cache_elpees_lookup(l_index).endtorele_num loop
3302     --
3303     p_inst_set(l_torrwnum) := g_cache_elpees_inst(l_insttorrw_num);
3304     l_torrwnum := l_torrwnum+1;
3305     --
3306   end loop;
3307   --
3308   p_inst_count := l_torrwnum;
3309   --
3310 exception
3311   --
3312   when no_data_found then
3313     --
3314     p_inst_count := 0;
3315     --
3316 end elpees_getcacdets;
3317 --
3318 procedure elpesa_writecache
3319   (p_effective_date in date,
3320    p_refresh_cache  in boolean default FALSE) is
3321   --
3322   l_proc varchar2(72) :=  'elpesa_writecache';
3323   l_torrwnum pls_integer;
3324   l_prev_id number;
3325   l_id number;
3326   --
3327   cursor c_elpesa_look is
3328     select elp.eligy_prfl_id, elp.business_group_id
3329     from   ben_eligy_prfl_f elp
3330     where  p_effective_date
3331            between elp.effective_start_date
3332            and     elp.effective_end_date
3333     and    exists (select null
3334                    from   ben_elig_svc_area_prte_f esa,
3335                           ben_svc_area_pstl_zip_rng_f saz,
3336                           ben_pstl_zip_rng_f rzr
3337                    where  p_effective_date
3338                           between esa.effective_start_date
3339                           and     esa.effective_end_date
3340                    and    esa.svc_area_id = saz.svc_area_id
3341                    and    esa.business_group_id = saz.business_group_id
3342                    and    p_effective_date
3343                           between rzr.effective_start_date
3344                           and     rzr.effective_end_date
3345                    and    saz.pstl_zip_rng_id = rzr.pstl_zip_rng_id
3346                    and    esa.business_group_id = rzr.business_group_id
3347                    and    esa.eligy_prfl_id = elp.eligy_prfl_id)
3348     order  by elp.eligy_prfl_id;
3349   --
3350   cursor c_elpesa_inst is
3351     select esa.eligy_prfl_id,
3352            esa.elig_svc_area_prte_id pk_id,
3353            'ESA' short_code,
3354            esa.excld_flag,
3355            esa.criteria_score,
3356            esa.criteria_weight,
3357            rzr.from_value,
3358            rzr.to_value
3359     from   ben_elig_svc_area_prte_f esa,
3360            ben_svc_area_pstl_zip_rng_f saz,
3361            ben_pstl_zip_rng_f rzr
3362     where  p_effective_date
3363            between esa.effective_start_date
3364            and     esa.effective_end_date
3365     and    esa.svc_area_id = saz.svc_area_id
3366     and    esa.business_group_id = saz.business_group_id
3367     and    p_effective_date
3368            between rzr.effective_start_date
3369            and     rzr.effective_end_date
3370     and    saz.pstl_zip_rng_id = rzr.pstl_zip_rng_id
3371     and    saz.business_group_id = rzr.business_group_id
3372     order  by esa.eligy_prfl_id,
3373            decode(esa.excld_flag,'Y',1,2),
3374            esa.ordr_num;
3375   --
3376   l_not_hash_found boolean;
3377   --
3378 begin
3379   --
3380   for objlook in c_elpesa_look loop
3381     --
3382     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
3383     --
3384     -- Check if hashed value is already allocated
3385     --
3386     if g_cache_elpesa_lookup.exists(l_id) then
3387       --
3388       l_not_hash_found := false;
3389       --
3390       -- Loop until un-allocated has value is derived
3391       --
3392       while not l_not_hash_found loop
3393         --
3394         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3395         --
3396         -- Check if the hash index exists, if not we can use it
3397         --
3398         if not g_cache_elpesa_lookup.exists(l_id) then
3399           --
3400           -- Lets store the hash value in the index
3401           --
3402           l_not_hash_found := true;
3403           exit;
3404           --
3405         else
3406           --
3407           l_not_hash_found := false;
3408           --
3409         end if;
3410       --
3411       end loop;
3412       --
3413     end if;
3414     --
3415     g_cache_elpesa_lookup(l_id).id := objlook.eligy_prfl_id;
3416     g_cache_elpesa_lookup(l_id).fk_id := objlook.business_group_id;
3417     --
3418   end loop;
3419   --
3420   l_torrwnum := 0;
3421   l_prev_id := -1;
3422   --
3423   for objinst in c_elpesa_inst loop
3424     --
3425     -- Populate the cache lookup details
3426     --
3427     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
3428     --
3429     -- Check if hashed value is already allocated
3430     --
3431     if g_cache_elpesa_lookup(l_id).id = objinst.eligy_prfl_id then
3432       --
3433       null;
3434       --
3435     else
3436       --
3437       loop
3438         --
3439         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3440         --
3441         if g_cache_elpesa_lookup(l_id).id = objinst.eligy_prfl_id then
3442           --
3443           exit;
3444           --
3445         end if;
3446         --
3447       end loop;
3448       --
3449     end if;
3450     --
3451     -- Check for first row
3452     --
3453     if l_prev_id = -1 then
3454       --
3455       g_cache_elpesa_lookup(l_id).starttorele_num := l_torrwnum;
3456       --
3457     elsif l_id <> l_prev_id then
3458       --
3459       g_cache_elpesa_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3460       g_cache_elpesa_lookup(l_id).starttorele_num := l_torrwnum;
3461       --
3462     end if;
3463     --
3464     -- Populate the cache instance details
3465     --
3466     g_cache_elpesa_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
3467     g_cache_elpesa_inst(l_torrwnum).pk_id := objinst.pk_id;
3468     g_cache_elpesa_inst(l_torrwnum).short_code := objinst.short_code;
3469     g_cache_elpesa_inst(l_torrwnum).criteria_score := objinst.criteria_score;
3470     g_cache_elpesa_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
3471     g_cache_elpesa_inst(l_torrwnum).excld_flag := objinst.excld_flag;
3472     g_cache_elpesa_inst(l_torrwnum).from_value := objinst.from_value;
3473     g_cache_elpesa_inst(l_torrwnum).to_value := objinst.to_value;
3474     --
3475     l_torrwnum := l_torrwnum+1;
3476     l_prev_id := l_id;
3477     --
3478   end loop;
3479   --
3480   g_cache_elpesa_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3481   --
3482 end elpesa_writecache;
3483 --
3484 procedure elpesa_getcacdets
3485   (p_effective_date    in  date,
3486    p_business_group_id in  number,
3487    p_eligy_prfl_id     in  number,
3488    p_refresh_cache     in  boolean default FALSE,
3489    p_inst_set          out nocopy ben_elp_cache.g_cache_elpesa_instor,
3490    p_inst_count        out nocopy number) is
3491   --
3492   l_proc varchar2(72) :=  'elpesa_getcacdets';
3493   l_torrwnum pls_integer;
3494   l_insttorrw_num pls_integer;
3495   l_index         pls_integer;
3496   --
3497   l_not_hash_found boolean;
3498   --
3499 begin
3500   --
3501   -- Flush the cache
3502   --
3503   if p_refresh_cache then
3504     --
3505     g_cache_elpesa_lookup.delete;
3506     g_cache_elpesa_inst.delete;
3507     --
3508   end if;
3509   --
3510   -- Populate the global cache
3511   --
3512   if g_cache_elpesa_lookup.count = 0 then
3513     --
3514     -- Build the cache
3515     --
3516     ben_elp_cache.elpesa_writecache
3517       (p_effective_date => p_effective_date,
3518        p_refresh_cache  => p_refresh_cache);
3519     --
3520   end if;
3521   --
3522   -- Get the instance details
3523   --
3524   l_torrwnum := 0;
3525   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
3526   --
3527   -- Check if hashed value is already allocated
3528   --
3529   if g_cache_elpesa_lookup.exists(l_index) then
3530     --
3531     -- If it does exist make sure its the right one
3532     --
3533     if g_cache_elpesa_lookup(l_index).id <> p_eligy_prfl_id then
3534       --
3535       l_not_hash_found := false;
3536       --
3537       -- Loop until un-allocated has value is derived
3538       --
3539       while not l_not_hash_found loop
3540         --
3541         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
3542         --
3543         -- Check if the hash index exists, if not we can use it
3544         --
3545         if not g_cache_elpesa_lookup.exists(l_index) then
3546           --
3547           -- Lets store the hash value in the index
3548           --
3549           l_not_hash_found := true;
3550           exit;
3551           --
3552         else
3553           --
3554           l_not_hash_found := false;
3555           --
3556         end if;
3557         --
3558       end loop;
3559       --
3560     end if;
3561     --
3562   end if;
3563   --
3564   for l_insttorrw_num in g_cache_elpesa_lookup(l_index).starttorele_num ..
3565     g_cache_elpesa_lookup(l_index).endtorele_num loop
3566     --
3567     p_inst_set(l_torrwnum) := g_cache_elpesa_inst(l_insttorrw_num);
3568     l_torrwnum := l_torrwnum+1;
3569     --
3570   end loop;
3571   --
3572   p_inst_count := l_torrwnum;
3573   --
3574 exception
3575   --
3576   when no_data_found then
3577     --
3578     p_inst_count := 0;
3579     --
3580 end elpesa_getcacdets;
3581 --
3582 procedure elpels_writecache
3583   (p_effective_date in date,
3584    p_refresh_cache  in boolean default FALSE) is
3585   --
3586   l_proc varchar2(72) :=  'elpels_writecache';
3587   l_torrwnum pls_integer;
3588   l_prev_id number;
3589   l_id number;
3590   --
3591   cursor c_elpels_look is
3592     select elp.eligy_prfl_id,
3593            elp.business_group_id
3594     from   ben_eligy_prfl_f elp
3595     where  p_effective_date
3596            between elp.effective_start_date
3597            and     elp.effective_end_date
3598     and    exists(select null
3599                   from   ben_elig_los_prte_f els,
3600                          ben_los_fctr lsf
3601                   where  p_effective_date
3602                          between els.effective_start_date
3603                          and     els.effective_end_date
3604                   and    els.los_fctr_id = lsf.los_fctr_id
3605                   and    els.business_group_id = lsf.business_group_id
3606                   and    els.eligy_prfl_id = elp.eligy_prfl_id)
3607     order  by elp.eligy_prfl_id;
3608   --
3609   cursor c_elpels_inst is
3610     select els.eligy_prfl_id,
3611            els.elig_los_prte_id pk_id,
3612            'ELS' short_code,
3613            els.los_fctr_id,
3614            els.excld_flag,
3615            els.criteria_score,
3616            els.criteria_weight,
3617            lsf.mx_los_num,
3618            lsf.mn_los_num,
3619            lsf.no_mx_los_num_apls_flag,
3620            lsf.no_mn_los_num_apls_flag
3621     from   ben_elig_los_prte_f els,
3622            ben_los_fctr lsf
3623     where  p_effective_date
3624            between els.effective_start_date
3625            and     els.effective_end_date
3626     and    els.los_fctr_id = lsf.los_fctr_id
3627     and    els.business_group_id = lsf.business_group_id
3628     order  by els.eligy_prfl_id,
3629            decode(els.excld_flag,'Y',1,2),
3630            els.ordr_num;
3631   --
3632   l_not_hash_found boolean;
3633   --
3634 begin
3635   --
3636   for objlook in c_elpels_look loop
3637     --
3638     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
3639     --
3640     -- Check if hashed value is already allocated
3641     --
3642     if g_cache_elpels_lookup.exists(l_id) then
3643       --
3644       l_not_hash_found := false;
3645       --
3646       -- Loop until un-allocated has value is derived
3647       --
3648       while not l_not_hash_found loop
3649         --
3650         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3651         --
3652         -- Check if the hash index exists, if not we can use it
3653         --
3654         if not g_cache_elpels_lookup.exists(l_id) then
3655           --
3656           -- Lets store the hash value in the index
3657           --
3658           l_not_hash_found := true;
3659           exit;
3660           --
3661         else
3662           --
3663           l_not_hash_found := false;
3664           --
3665         end if;
3666       --
3667       end loop;
3668       --
3669     end if;
3670     --
3671     g_cache_elpels_lookup(l_id).id := objlook.eligy_prfl_id;
3672     g_cache_elpels_lookup(l_id).fk_id := objlook.business_group_id;
3673     --
3674   end loop;
3675   --
3676   l_torrwnum := 0;
3677   l_prev_id := -1;
3678   --
3679   for objinst in c_elpels_inst loop
3680     --
3681     -- Populate the cache lookup details
3682     --
3683     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
3684     --
3685     -- Check if hashed value is already allocated
3686     --
3687     if g_cache_elpels_lookup(l_id).id = objinst.eligy_prfl_id then
3688       --
3689       null;
3690       --
3691     else
3692       --
3693       loop
3694         --
3695         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3696         --
3697         if g_cache_elpels_lookup(l_id).id = objinst.eligy_prfl_id then
3698           --
3699           exit;
3700           --
3701         end if;
3702         --
3703       end loop;
3704       --
3705     end if;
3706     --
3707     -- Check for first row
3708     --
3709     if l_prev_id = -1 then
3710       --
3711       g_cache_elpels_lookup(l_id).starttorele_num := l_torrwnum;
3712       --
3713     elsif l_id <> l_prev_id then
3714       --
3715       g_cache_elpels_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3716       g_cache_elpels_lookup(l_id).starttorele_num := l_torrwnum;
3717       --
3718     end if;
3719     --
3720     -- Populate the cache instance details
3721     --
3722     g_cache_elpels_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
3723     g_cache_elpels_inst(l_torrwnum).pk_id := objinst.pk_id;
3724     g_cache_elpels_inst(l_torrwnum).short_code := objinst.short_code;
3725     g_cache_elpels_inst(l_torrwnum).criteria_score := objinst.criteria_score;
3726     g_cache_elpels_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
3727     g_cache_elpels_inst(l_torrwnum).los_fctr_id := objinst.los_fctr_id;
3728     g_cache_elpels_inst(l_torrwnum).excld_flag := objinst.excld_flag;
3729     g_cache_elpels_inst(l_torrwnum).criteria_score := objinst.criteria_score;
3730     g_cache_elpels_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
3731     g_cache_elpels_inst(l_torrwnum).mx_los_num := objinst.mx_los_num;
3732     g_cache_elpels_inst(l_torrwnum).mn_los_num := objinst.mn_los_num;
3733     g_cache_elpels_inst(l_torrwnum).no_mx_los_num_apls_flag := objinst.no_mx_los_num_apls_flag;
3734     g_cache_elpels_inst(l_torrwnum).no_mn_los_num_apls_flag := objinst.no_mn_los_num_apls_flag;
3735     --
3736     l_torrwnum := l_torrwnum+1;
3737     l_prev_id := l_id;
3738     --
3739   end loop;
3740   --
3741   g_cache_elpels_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3742   --
3743 end elpels_writecache;
3744 --
3745 procedure elpels_getcacdets
3746   (p_effective_date    in  date,
3747    p_business_group_id in  number,
3748    p_eligy_prfl_id     in  number,
3749    p_refresh_cache     in  boolean default FALSE,
3750    p_inst_set          out nocopy ben_elp_cache.g_cache_elpels_instor,
3751    p_inst_count        out nocopy number) is
3752   --
3753   l_proc varchar2(72) :=  'elpels_getcacdets';
3754   l_torrwnum pls_integer;
3755   l_insttorrw_num pls_integer;
3756   l_index         pls_integer;
3757   --
3758   l_not_hash_found boolean;
3759   --
3760 begin
3761   --
3762   -- Flush the cache
3763   --
3764   if p_refresh_cache then
3765     --
3766     g_cache_elpels_lookup.delete;
3767     g_cache_elpels_inst.delete;
3768     --
3769   end if;
3770   --
3771   -- Populate the global cache
3772   --
3773   if g_cache_elpels_lookup.count = 0 then
3774     --
3775     -- Build the cache
3776     --
3777     ben_elp_cache.elpels_writecache
3778       (p_effective_date => p_effective_date,
3779        p_refresh_cache  => p_refresh_cache);
3780     --
3781   end if;
3782   --
3783   -- Get the instance details
3784   --
3785   l_torrwnum := 0;
3786   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
3787   --
3788   -- Check if hashed value is already allocated
3789   --
3790   if g_cache_elpels_lookup.exists(l_index) then
3791     --
3792     -- If it does exist make sure its the right one
3793     --
3794     if g_cache_elpels_lookup(l_index).id <> p_eligy_prfl_id then
3795       --
3796       l_not_hash_found := false;
3797       --
3798       -- Loop until un-allocated has value is derived
3799       --
3800       while not l_not_hash_found loop
3801         --
3802         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
3803         --
3804         -- Check if the hash index exists, if not we can use it
3805         --
3806         if not g_cache_elpels_lookup.exists(l_index) then
3807           --
3808           -- Lets store the hash value in the index
3809           --
3810           l_not_hash_found := true;
3811           exit;
3812           --
3813         else
3814           --
3815           l_not_hash_found := false;
3816           --
3817         end if;
3818         --
3819       end loop;
3820       --
3821     end if;
3822     --
3823   end if;
3824   --
3825   for l_insttorrw_num in g_cache_elpels_lookup(l_index).starttorele_num ..
3826     g_cache_elpels_lookup(l_index).endtorele_num loop
3827     --
3828     p_inst_set(l_torrwnum) := g_cache_elpels_inst(l_insttorrw_num);
3829     l_torrwnum := l_torrwnum+1;
3830     --
3831   end loop;
3832   --
3833   p_inst_count := l_torrwnum;
3834   --
3835 exception
3836   --
3837   when no_data_found then
3838     --
3839     p_inst_count := 0;
3840     --
3841 end elpels_getcacdets;
3842 --
3843 procedure elpecp_writecache
3844   (p_effective_date in date,
3845    p_refresh_cache  in boolean default FALSE) is
3846   --
3847   l_proc varchar2(72) :=  'elpecp_writecache';
3848   --
3849   l_torrwnum pls_integer;
3850   --
3851   l_prev_id number;
3852   l_id number;
3853   --
3854   cursor c_elpecp_look is
3855     select elp.eligy_prfl_id,
3856            elp.business_group_id
3857     from   ben_eligy_prfl_f elp
3858     where  p_effective_date
3859            between elp.effective_start_date
3860            and     elp.effective_end_date
3861     and    exists(select null
3862                   from   ben_elig_cmbn_age_los_prte_f ecp,
3863                          ben_cmbn_age_los_fctr cla
3864                   where  ecp.cmbn_age_los_fctr_id = cla.cmbn_age_los_fctr_id
3865                   and    ecp.business_group_id = cla.business_group_id
3866                   and    p_effective_date
3867                          between ecp.effective_start_date
3868                          and     ecp.effective_end_date
3869                   and    ecp.eligy_prfl_id = elp.eligy_prfl_id)
3870     order  by elp.eligy_prfl_id;
3871   --
3872   cursor c_elpecp_inst is
3873     select ecp.eligy_prfl_id,
3874            ecp.elig_cmbn_age_los_prte_id pk_id,
3875            'ECP' short_code,
3876            ecp.cmbn_age_los_fctr_id,
3877            ecp.excld_flag,
3878            ecp.criteria_score,
3879            ecp.criteria_weight,
3880            cla.cmbnd_min_val,
3881            cla.cmbnd_max_val,
3882            cla.los_fctr_id,
3883            cla.age_fctr_id
3884     from   ben_elig_cmbn_age_los_prte_f ecp,
3885            ben_cmbn_age_los_fctr cla
3886     where  ecp.cmbn_age_los_fctr_id = cla.cmbn_age_los_fctr_id
3887     and    ecp.business_group_id = cla.business_group_id
3888     and    p_effective_date
3889            between ecp.effective_start_date
3890            and     ecp.effective_end_date
3891     order  by ecp.eligy_prfl_id,
3892            decode(ecp.excld_flag,'Y',1,2),
3893            ecp.ordr_num;
3894   --
3895   l_not_hash_found boolean;
3896   --
3897 begin
3898   --
3899   for objlook in c_elpecp_look loop
3900     --
3901     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
3902     --
3903     -- Check if hashed value is already allocated
3904     --
3905     if g_cache_elpecp_lookup.exists(l_id) then
3906       --
3907       l_not_hash_found := false;
3908       --
3909       -- Loop until un-allocated has value is derived
3910       --
3911       while not l_not_hash_found loop
3912         --
3913         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3914         --
3915         -- Check if the hash index exists, if not we can use it
3916         --
3917         if not g_cache_elpecp_lookup.exists(l_id) then
3918           --
3919           -- Lets store the hash value in the index
3920           --
3921           l_not_hash_found := true;
3922           exit;
3923           --
3924         else
3925           --
3926           l_not_hash_found := false;
3927           --
3928         end if;
3929       --
3930       end loop;
3931       --
3932     end if;
3933     --
3934     g_cache_elpecp_lookup(l_id).id := objlook.eligy_prfl_id;
3935     g_cache_elpecp_lookup(l_id).fk_id := objlook.business_group_id;
3936     --
3937   end loop;
3938   --
3939   l_torrwnum := 0;
3940   l_prev_id := -1;
3941   --
3942   for objinst in c_elpecp_inst loop
3943     --
3944     -- Populate the cache lookup details
3945     --
3946     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
3947     --
3948     -- Check if hashed value is already allocated
3949     --
3950     if g_cache_elpecp_lookup(l_id).id = objinst.eligy_prfl_id then
3951       --
3952       null;
3953       --
3954     else
3955       --
3956       loop
3957         --
3958         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
3959         --
3960         if g_cache_elpecp_lookup(l_id).id = objinst.eligy_prfl_id then
3961           --
3962           exit;
3963           --
3964         end if;
3965         --
3966       end loop;
3967       --
3968     end if;
3969     --
3970     -- Check for first row
3971     --
3972     if l_prev_id = -1 then
3973       --
3974       g_cache_elpecp_lookup(l_id).starttorele_num := l_torrwnum;
3975       --
3976     elsif l_id <> l_prev_id then
3977       --
3978       g_cache_elpecp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
3979       g_cache_elpecp_lookup(l_id).starttorele_num := l_torrwnum;
3980       --
3981     end if;
3982     --
3983     -- Populate the cache instance details
3984     --
3985     g_cache_elpecp_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
3986     g_cache_elpecp_inst(l_torrwnum).pk_id := objinst.pk_id;
3987     g_cache_elpecp_inst(l_torrwnum).short_code := objinst.short_code;
3988     g_cache_elpecp_inst(l_torrwnum).criteria_score := objinst.criteria_score;
3989     g_cache_elpecp_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
3990     g_cache_elpecp_inst(l_torrwnum).cmbn_age_los_fctr_id := objinst.cmbn_age_los_fctr_id;
3991     g_cache_elpecp_inst(l_torrwnum).excld_flag := objinst.excld_flag;
3992     g_cache_elpecp_inst(l_torrwnum).cmbnd_min_val := objinst.cmbnd_min_val;
3993     g_cache_elpecp_inst(l_torrwnum).cmbnd_max_val := objinst.cmbnd_max_val;
3994     g_cache_elpecp_inst(l_torrwnum).los_fctr_id := objinst.los_fctr_id;
3995     g_cache_elpecp_inst(l_torrwnum).age_fctr_id := objinst.age_fctr_id;
3996     --
3997     l_torrwnum := l_torrwnum+1;
3998     l_prev_id := l_id;
3999     --
4000   end loop;
4001   --
4002   g_cache_elpecp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4003   --
4004 end elpecp_writecache;
4005 --
4006 procedure elpecp_getcacdets
4007   (p_effective_date    in  date,
4008    p_business_group_id in  number,
4009    p_eligy_prfl_id     in  number,
4010    p_refresh_cache     in  boolean default FALSE,
4011    p_inst_set          out nocopy ben_elp_cache.g_cache_elpecp_instor,
4012    p_inst_count        out nocopy number) is
4013   --
4014   l_proc varchar2(72) :=  'elpecp_getcacdets';
4015   l_torrwnum pls_integer;
4016   l_insttorrw_num pls_integer;
4017   l_index         pls_integer;
4018   --
4019   l_not_hash_found boolean;
4020   --
4021 begin
4022   --
4023   -- Flush the cache
4024   --
4025   if p_refresh_cache then
4026     --
4027     g_cache_elpecp_lookup.delete;
4028     g_cache_elpecp_inst.delete;
4029     --
4030   end if;
4031   --
4032   -- Populate the global cache
4033   --
4034   if g_cache_elpecp_lookup.count = 0 then
4035     --
4036     -- Build the cache
4037     --
4038     ben_elp_cache.elpecp_writecache
4039       (p_effective_date => p_effective_date,
4040        p_refresh_cache  => p_refresh_cache);
4041     --
4042   end if;
4043   --
4044   -- Get the instance details
4045   --
4046   l_torrwnum := 0;
4047   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
4048   --
4049   -- Check if hashed value is already allocated
4050   --
4051   if g_cache_elpecp_lookup.exists(l_index) then
4052     --
4053     -- If it does exist make sure its the right one
4054     --
4055     if g_cache_elpecp_lookup(l_index).id <> p_eligy_prfl_id then
4056       --
4057       l_not_hash_found := false;
4058       --
4059       -- Loop until un-allocated has value is derived
4060       --
4061       while not l_not_hash_found loop
4062         --
4063         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
4064         --
4065         -- Check if the hash index exists, if not we can use it
4066         --
4067         if not g_cache_elpecp_lookup.exists(l_index) then
4068           --
4069           -- Lets store the hash value in the index
4070           --
4071           l_not_hash_found := true;
4072           exit;
4073           --
4074         else
4075           --
4076           l_not_hash_found := false;
4077           --
4078         end if;
4079         --
4080       end loop;
4081       --
4082     end if;
4083     --
4084   end if;
4085   --
4086   for l_insttorrw_num in g_cache_elpecp_lookup(l_index).starttorele_num ..
4087     g_cache_elpecp_lookup(l_index).endtorele_num loop
4088     --
4089     p_inst_set(l_torrwnum) := g_cache_elpecp_inst(l_insttorrw_num);
4090     l_torrwnum := l_torrwnum+1;
4091     --
4092   end loop;
4093   --
4094   p_inst_count := l_torrwnum;
4095   --
4096 exception
4097   --
4098   when no_data_found then
4099     --
4100     p_inst_count := 0;
4101     --
4102 end elpecp_getcacdets;
4103 --
4104 procedure elpewl_writecache
4105   (p_effective_date in date,
4106    p_refresh_cache  in boolean default FALSE) is
4107   --
4108   l_proc varchar2(72) :=  'elpewl_writecache';
4109   l_torrwnum pls_integer;
4110   l_prev_id number;
4111   l_id number;
4112   --
4113   cursor c_elpewl_look is
4114     select elp.eligy_prfl_id,
4115            elp.business_group_id
4116     from   ben_eligy_prfl_f elp
4117     where  p_effective_date
4118            between elp.effective_start_date
4119            and     elp.effective_end_date
4120     and    exists(select null
4121                   from   ben_elig_wk_loc_prte_f ewl
4122                   where  p_effective_date
4123                          between ewl.effective_start_date
4124                          and     ewl.effective_end_date
4125                   and    ewl.eligy_prfl_id = elp.eligy_prfl_id)
4126     order  by elp.eligy_prfl_id;
4127   --
4128   cursor c_elpewl_inst is
4129     select ewl.eligy_prfl_id,
4130            ewl.elig_wk_loc_prte_id pk_id,
4131            'EWL' short_code,
4132            ewl.location_id,
4133            ewl.excld_flag,
4134            ewl.criteria_score,
4135            ewl.criteria_weight
4136     from   ben_elig_wk_loc_prte_f ewl
4137     where  p_effective_date
4138            between ewl.effective_start_date
4139            and     ewl.effective_end_date
4140     order  by ewl.eligy_prfl_id,
4141            decode(ewl.excld_flag,'Y',1,2),
4142            ewl.ordr_num;
4143   --
4144   l_not_hash_found boolean;
4145   --
4146 begin
4147   --
4148   for objlook in c_elpewl_look loop
4149     --
4150     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
4151     --
4152     -- Check if hashed value is already allocated
4153     --
4154     if g_cache_elpewl_lookup.exists(l_id) then
4155       --
4156       l_not_hash_found := false;
4157       --
4158       -- Loop until un-allocated has value is derived
4159       --
4160       while not l_not_hash_found loop
4161         --
4162         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4163         --
4164         -- Check if the hash index exists, if not we can use it
4165         --
4166         if not g_cache_elpewl_lookup.exists(l_id) then
4167           --
4168           -- Lets store the hash value in the index
4169           --
4170           l_not_hash_found := true;
4171           exit;
4172           --
4173         else
4174           --
4175           l_not_hash_found := false;
4176           --
4177         end if;
4178       --
4179       end loop;
4180       --
4181     end if;
4182     --
4183     g_cache_elpewl_lookup(l_id).id := objlook.eligy_prfl_id;
4184     g_cache_elpewl_lookup(l_id).fk_id := objlook.business_group_id;
4185     --
4186   end loop;
4187   --
4188   l_torrwnum := 0;
4189   l_prev_id := -1;
4190   --
4191   for objinst in c_elpewl_inst loop
4192     --
4193     -- Populate the cache lookup details
4194     --
4195     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
4196     --
4197     -- Check if hashed value is already allocated
4198     --
4199     if g_cache_elpewl_lookup(l_id).id = objinst.eligy_prfl_id then
4200       --
4201       null;
4202       --
4203     else
4204       --
4205       loop
4206         --
4207         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4208         --
4209         if g_cache_elpewl_lookup(l_id).id = objinst.eligy_prfl_id then
4210           --
4211           exit;
4212           --
4213         end if;
4214         --
4215       end loop;
4216       --
4217     end if;
4218     --
4219     -- Check for first row
4220     --
4221     if l_prev_id = -1 then
4222       --
4223       g_cache_elpewl_lookup(l_id).starttorele_num := l_torrwnum;
4224       --
4225     elsif l_id <> l_prev_id then
4226       --
4227       g_cache_elpewl_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4228       g_cache_elpewl_lookup(l_id).starttorele_num := l_torrwnum;
4229       --
4230     end if;
4231     --
4232     -- Populate the cache instance details
4233     --
4234     g_cache_elpewl_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
4235     g_cache_elpewl_inst(l_torrwnum).pk_id := objinst.pk_id;
4236     g_cache_elpewl_inst(l_torrwnum).short_code := objinst.short_code;
4237     g_cache_elpewl_inst(l_torrwnum).criteria_score := objinst.criteria_score;
4238     g_cache_elpewl_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
4239     g_cache_elpewl_inst(l_torrwnum).location_id := objinst.location_id;
4240     g_cache_elpewl_inst(l_torrwnum).excld_flag := objinst.excld_flag;
4241     --
4242     l_torrwnum := l_torrwnum+1;
4243     l_prev_id := l_id;
4244     --
4245   end loop;
4246   --
4247   g_cache_elpewl_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4248   --
4249 end elpewl_writecache;
4250 --
4251 procedure elpewl_getcacdets
4252   (p_effective_date    in  date,
4253    p_business_group_id in  number,
4254    p_eligy_prfl_id     in  number,
4255    p_refresh_cache     in  boolean default FALSE,
4256    p_inst_set          out nocopy ben_elp_cache.g_cache_elpewl_instor,
4257    p_inst_count        out nocopy number) is
4258   --
4259   l_proc varchar2(72) :=  'elpewl_getcacdets';
4260   l_torrwnum pls_integer;
4261   l_insttorrw_num pls_integer;
4262   l_index         pls_integer;
4263   --
4264   l_not_hash_found boolean;
4265   --
4266 begin
4267   --
4268   -- Flush the cache
4269   --
4270   if p_refresh_cache then
4271     --
4272     g_cache_elpewl_lookup.delete;
4273     g_cache_elpewl_inst.delete;
4274     --
4275   end if;
4276   --
4277   -- Populate the global cache
4278   --
4279   if g_cache_elpewl_lookup.count = 0 then
4280     --
4281     -- Build the cache
4282     --
4283     ben_elp_cache.elpewl_writecache
4284       (p_effective_date => p_effective_date,
4285        p_refresh_cache  => p_refresh_cache);
4286     --
4287   end if;
4288   --
4289   -- Get the instance details
4290   --
4291   l_torrwnum := 0;
4292   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
4293   --
4294   -- Check if hashed value is already allocated
4295   --
4296   if g_cache_elpewl_lookup.exists(l_index) then
4297     --
4298     -- If it does exist make sure its the right one
4299     --
4300     if g_cache_elpewl_lookup(l_index).id <> p_eligy_prfl_id then
4301       --
4302       l_not_hash_found := false;
4303       --
4304       -- Loop until un-allocated has value is derived
4305       --
4306       while not l_not_hash_found loop
4307         --
4308         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
4309         --
4310         -- Check if the hash index exists, if not we can use it
4311         --
4312         if not g_cache_elpewl_lookup.exists(l_index) then
4313           --
4314           -- Lets store the hash value in the index
4315           --
4316           l_not_hash_found := true;
4317           exit;
4318           --
4319         else
4320           --
4321           l_not_hash_found := false;
4322           --
4323         end if;
4324         --
4325       end loop;
4326       --
4327     end if;
4328     --
4329   end if;
4330   --
4331   for l_insttorrw_num in g_cache_elpewl_lookup(l_index).starttorele_num ..
4332     g_cache_elpewl_lookup(l_index).endtorele_num loop
4333     --
4334     p_inst_set(l_torrwnum) := g_cache_elpewl_inst(l_insttorrw_num);
4335     l_torrwnum := l_torrwnum+1;
4336     --
4337   end loop;
4338   --
4339   p_inst_count := l_torrwnum;
4340   --
4341 exception
4342   --
4343   when no_data_found then
4344     --
4345     p_inst_count := 0;
4346     --
4347 end elpewl_getcacdets;
4348 --
4349 procedure elpeou_writecache
4350   (p_effective_date in date,
4351    p_refresh_cache  in boolean default FALSE) is
4352   --
4353   l_proc varchar2(72) :=  'elpeou_writecache';
4354   l_torrwnum pls_integer;
4355   l_prev_id number;
4356   l_id number;
4357   --
4358   cursor c_elpeou_look is
4359     select elp.eligy_prfl_id,
4360            elp.business_group_id
4361     from   ben_eligy_prfl_f elp
4362     where  p_effective_date
4363            between elp.effective_start_date
4364            and     elp.effective_end_date
4365     and    exists(select null
4366                   from   ben_elig_org_unit_prte_f eou
4367                   where  p_effective_date
4368                          between eou.effective_start_date
4369                          and     eou.effective_end_date
4370                   and    eou.eligy_prfl_id = elp.eligy_prfl_id)
4371     order  by elp.eligy_prfl_id;
4372   --
4373   cursor c_elpeou_inst is
4374     select eou.eligy_prfl_id,
4375            eou.elig_org_unit_prte_id pk_id,
4376            'EOU' short_code,
4377            eou.organization_id,
4378            eou.excld_flag,
4379            eou.criteria_score,
4380            eou.criteria_weight
4381     from   ben_elig_org_unit_prte_f eou
4382     where  p_effective_date
4383            between eou.effective_start_date
4384            and     eou.effective_end_date
4385     order  by eou.eligy_prfl_id,
4386            decode(eou.excld_flag,'Y',1,2),
4387            eou.ordr_num;
4388   --
4389   l_not_hash_found boolean;
4390   --
4391 begin
4392   --
4393   for objlook in c_elpeou_look loop
4394     --
4395     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
4396     --
4397     -- Check if hashed value is already allocated
4398     --
4399     if g_cache_elpeou_lookup.exists(l_id) then
4400       --
4401       l_not_hash_found := false;
4402       --
4403       -- Loop until un-allocated has value is derived
4404       --
4405       while not l_not_hash_found loop
4406         --
4407         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4408         --
4409         -- Check if the hash index exists, if not we can use it
4410         --
4411         if not g_cache_elpeou_lookup.exists(l_id) then
4412           --
4413           -- Lets store the hash value in the index
4414           --
4415           l_not_hash_found := true;
4416           exit;
4417           --
4418         else
4419           --
4420           l_not_hash_found := false;
4421           --
4422         end if;
4423       --
4424       end loop;
4425       --
4426     end if;
4427     --
4428     g_cache_elpeou_lookup(l_id).id := objlook.eligy_prfl_id;
4429     g_cache_elpeou_lookup(l_id).fk_id := objlook.business_group_id;
4430     --
4431   end loop;
4432   --
4433   l_torrwnum := 0;
4434   l_prev_id := -1;
4435   --
4436   for objinst in c_elpeou_inst loop
4437     --
4438     -- Populate the cache lookup details
4439     --
4440     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
4441     --
4442     -- Check if hashed value is already allocated
4443     --
4444     if g_cache_elpeou_lookup(l_id).id = objinst.eligy_prfl_id then
4445       --
4446       null;
4447       --
4448     else
4449       --
4450       loop
4451         --
4452         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4453         --
4454         if g_cache_elpeou_lookup(l_id).id = objinst.eligy_prfl_id then
4455           --
4456           exit;
4457           --
4458         end if;
4459         --
4460       end loop;
4461       --
4462     end if;
4463     --
4464     -- Check for first row
4465     --
4466     if l_prev_id = -1 then
4467       --
4468       g_cache_elpeou_lookup(l_id).starttorele_num := l_torrwnum;
4469       --
4470     elsif l_id <> l_prev_id then
4471       --
4472       g_cache_elpeou_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4473       g_cache_elpeou_lookup(l_id).starttorele_num := l_torrwnum;
4474       --
4475     end if;
4476     --
4477     -- Populate the cache instance details
4478     --
4479     g_cache_elpeou_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
4480     g_cache_elpeou_inst(l_torrwnum).pk_id := objinst.pk_id;
4481     g_cache_elpeou_inst(l_torrwnum).short_code := objinst.short_code;
4482     g_cache_elpeou_inst(l_torrwnum).criteria_score := objinst.criteria_score;
4483     g_cache_elpeou_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
4484     g_cache_elpeou_inst(l_torrwnum).organization_id := objinst.organization_id;
4485     g_cache_elpeou_inst(l_torrwnum).excld_flag := objinst.excld_flag;
4486     --
4487     l_torrwnum := l_torrwnum+1;
4488     l_prev_id := l_id;
4489     --
4490   end loop;
4491   --
4492   g_cache_elpeou_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4493   --
4494 end elpeou_writecache;
4495 --
4496 procedure elpeou_getcacdets
4497   (p_effective_date    in  date,
4498    p_business_group_id in  number,
4499    p_eligy_prfl_id     in  number,
4500    p_refresh_cache     in  boolean default FALSE,
4501    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeou_instor,
4502    p_inst_count        out nocopy number) is
4503   --
4504   l_proc varchar2(72) :=  'elpeou_getcacdets';
4505   l_torrwnum pls_integer;
4506   l_insttorrw_num pls_integer;
4507   l_index         pls_integer;
4508   --
4509   l_not_hash_found boolean;
4510   --
4511 begin
4512   --
4513   -- Flush the cache
4514   --
4515   if p_refresh_cache then
4516     --
4517     g_cache_elpeou_lookup.delete;
4518     g_cache_elpeou_inst.delete;
4519     --
4520   end if;
4521   --
4522   -- Populate the global cache
4523   --
4524   if g_cache_elpeou_lookup.count = 0 then
4525     --
4526     -- Build the cache
4527     --
4528     ben_elp_cache.elpeou_writecache
4529       (p_effective_date => p_effective_date,
4530        p_refresh_cache  => p_refresh_cache);
4531     --
4532   end if;
4533   --
4534   -- Get the instance details
4535   --
4536   l_torrwnum := 0;
4537   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
4538   --
4539   -- Check if hashed value is already allocated
4540   --
4541   if g_cache_elpeou_lookup.exists(l_index) then
4542     --
4543     -- If it does exist make sure its the right one
4544     --
4545     if g_cache_elpeou_lookup(l_index).id <> p_eligy_prfl_id then
4546       --
4547       l_not_hash_found := false;
4548       --
4549       -- Loop until un-allocated has value is derived
4550       --
4551       while not l_not_hash_found loop
4552         --
4553         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
4554         --
4555         -- Check if the hash index exists, if not we can use it
4556         --
4557         if not g_cache_elpeou_lookup.exists(l_index) then
4558           --
4559           -- Lets store the hash value in the index
4560           --
4561           l_not_hash_found := true;
4562           exit;
4563           --
4564         else
4565           --
4566           l_not_hash_found := false;
4567           --
4568         end if;
4569         --
4570       end loop;
4571       --
4572     end if;
4573     --
4574   end if;
4575   --
4576   for l_insttorrw_num in g_cache_elpeou_lookup(l_index).starttorele_num ..
4577     g_cache_elpeou_lookup(l_index).endtorele_num loop
4578     --
4579     p_inst_set(l_torrwnum) := g_cache_elpeou_inst(l_insttorrw_num);
4580     l_torrwnum := l_torrwnum+1;
4581     --
4582   end loop;
4583   --
4584   p_inst_count := l_torrwnum;
4585   --
4586 exception
4587   --
4588   when no_data_found then
4589     --
4590     p_inst_count := 0;
4591     --
4592 end elpeou_getcacdets;
4593 --
4594 procedure elpehs_writecache
4595   (p_effective_date in date,
4596    p_refresh_cache  in boolean default FALSE) is
4597   --
4598   l_proc varchar2(72) :=  'elpehs_writecache';
4599   l_torrwnum pls_integer;
4600   l_prev_id number;
4601   l_id number;
4602   --
4603   cursor c_elpehs_look is
4604     select elp.eligy_prfl_id, elp.business_group_id
4605     from   ben_eligy_prfl_f elp
4606     where  p_effective_date
4607            between elp.effective_start_date
4608            and     elp.effective_end_date
4609     and    exists(select null
4610                   from   ben_elig_hrly_slrd_prte_f ehs
4611                   where  p_effective_date
4612                          between ehs.effective_start_date
4613                          and     ehs.effective_end_date
4614                   and    ehs.eligy_prfl_id = elp.eligy_prfl_id)
4615     order  by elp.eligy_prfl_id;
4616   --
4617   cursor c_elpehs_inst is
4618     select ehs.eligy_prfl_id,
4619            ehs.elig_hrly_slrd_prte_id pk_id,
4620            'EHS' short_code,
4621            ehs.hrly_slrd_cd,
4622            ehs.excld_flag,
4623            ehs.criteria_score,
4624            ehs.criteria_weight
4625     from   ben_elig_hrly_slrd_prte_f ehs
4626     where  p_effective_date
4627            between ehs.effective_start_date
4628            and ehs.effective_end_date
4629     order  by ehs.eligy_prfl_id,
4630            decode(ehs.excld_flag,'Y',1,2),
4631            ehs.ordr_num;
4632   --
4633   l_not_hash_found boolean;
4634   --
4635 begin
4636   --
4637   for objlook in c_elpehs_look loop
4638     --
4639     l_id := ben_hash_utility.get_hashed_index(objlook.eligy_prfl_id);
4640     --
4641     -- Check if hashed value is already allocated
4642     --
4643     if g_cache_elpehs_lookup.exists(l_id) then
4644       --
4645       l_not_hash_found := false;
4646       --
4647       -- Loop until un-allocated has value is derived
4648       --
4649       while not l_not_hash_found loop
4650         --
4651         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4652         --
4653         -- Check if the hash index exists, if not we can use it
4654         --
4655         if not g_cache_elpehs_lookup.exists(l_id) then
4656           --
4657           -- Lets store the hash value in the index
4658           --
4659           l_not_hash_found := true;
4660           exit;
4661           --
4662         else
4663           --
4664           l_not_hash_found := false;
4665           --
4666         end if;
4667       --
4668       end loop;
4669       --
4670     end if;
4671     --
4672     g_cache_elpehs_lookup(l_id).id := objlook.eligy_prfl_id;
4673     g_cache_elpehs_lookup(l_id).fk_id := objlook.business_group_id;
4674     --
4675   end loop;
4676   --
4677   l_torrwnum := 0;
4678   l_prev_id := -1;
4679   --
4680   for objinst in c_elpehs_inst loop
4681     --
4682     -- Populate the cache lookup details
4683     --
4684     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
4685     --
4686     -- Check if hashed value is already allocated
4687     --
4688     if g_cache_elpehs_lookup(l_id).id = objinst.eligy_prfl_id then
4689       --
4690       null;
4691       --
4692     else
4693       --
4694       loop
4695         --
4696         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4697         --
4698         if g_cache_elpehs_lookup(l_id).id = objinst.eligy_prfl_id then
4699           --
4700           exit;
4701           --
4702         end if;
4703         --
4704       end loop;
4705       --
4706     end if;
4707     --
4708     -- Check for first row
4709     --
4710     if l_prev_id = -1 then
4711       --
4712       g_cache_elpehs_lookup(l_id).starttorele_num := l_torrwnum;
4713       --
4714     elsif l_id <> l_prev_id then
4715       --
4716       g_cache_elpehs_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4717       g_cache_elpehs_lookup(l_id).starttorele_num := l_torrwnum;
4718       --
4719     end if;
4720     --
4721     -- Populate the cache instance details
4722     --
4723     g_cache_elpehs_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
4724     g_cache_elpehs_inst(l_torrwnum).pk_id := objinst.pk_id;
4725     g_cache_elpehs_inst(l_torrwnum).short_code := objinst.short_code;
4726     g_cache_elpehs_inst(l_torrwnum).criteria_score := objinst.criteria_score;
4727     g_cache_elpehs_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
4728     g_cache_elpehs_inst(l_torrwnum).hrly_slrd_cd := objinst.hrly_slrd_cd;
4729     g_cache_elpehs_inst(l_torrwnum).excld_flag := objinst.excld_flag;
4730     --
4731     l_torrwnum := l_torrwnum+1;
4732     l_prev_id := l_id;
4733     --
4734   end loop;
4735   --
4736   g_cache_elpehs_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4737   --
4738 end elpehs_writecache;
4739 --
4740 procedure elpehs_getcacdets
4741   (p_effective_date    in date,
4742    p_business_group_id in number,
4743    p_eligy_prfl_id     in number,
4744    p_refresh_cache     in boolean default FALSE,
4745    p_inst_set          out nocopy ben_elp_cache.g_cache_elpehs_instor,
4746    p_inst_count        out nocopy number) is
4747   --
4748   l_proc varchar2(72) :=  'elpehs_getcacdets';
4749   l_torrwnum pls_integer;
4750   l_insttorrw_num pls_integer;
4751   l_index         pls_integer;
4752   --
4753   l_not_hash_found boolean;
4754   --
4755 begin
4756 --  hr_utility.set_location('Entering : '||l_proc,10);
4757   --
4758   -- Flush the cache
4759   --
4760   if p_refresh_cache then
4761     --
4762     g_cache_elpehs_lookup.delete;
4763     g_cache_elpehs_inst.delete;
4764     --
4765   end if;
4766   --
4767   -- Populate the global cache
4768   --
4769   if g_cache_elpehs_lookup.count = 0 then
4770     --
4771     -- Build the cache
4772     --
4773     ben_elp_cache.elpehs_writecache
4774       (p_effective_date => p_effective_date,
4775        p_refresh_cache  => p_refresh_cache);
4776     --
4777   end if;
4778 --  hr_utility.set_location('Done write cache : '||l_proc,20);
4779   --
4780   -- Get the instance details
4781   --
4782   l_torrwnum := 0;
4783   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
4784   --
4785   -- Check if hashed value is already allocated
4786   --
4787   if g_cache_elpehs_lookup.exists(l_index) then
4788     --
4789     -- If it does exist make sure its the right one
4790     --
4791     if g_cache_elpehs_lookup(l_index).id <> p_eligy_prfl_id then
4792       --
4793       l_not_hash_found := false;
4794       --
4795       -- Loop until un-allocated has value is derived
4796       --
4797     --  hr_utility.set_location('Hashing  '||l_proc,40);
4798       while not l_not_hash_found loop
4799         --
4800         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
4801         --
4802         -- Check if the hash index exists, if not we can use it
4803         --
4804         if not g_cache_elpehs_lookup.exists(l_index) then
4805           --
4806           -- Lets store the hash value in the index
4807           --
4808           l_not_hash_found := true;
4809           exit;
4810           --
4811         else
4812           --
4813           l_not_hash_found := false;
4814           --
4815         end if;
4816         --
4817       end loop;
4818       --
4819     end if;
4820     --
4821   end if;
4822   --
4823 --  hr_utility.set_location('Populate  '||l_proc,80);
4824   for l_insttorrw_num in g_cache_elpehs_lookup(l_index).starttorele_num ..
4825     g_cache_elpehs_lookup(l_index).endtorele_num loop
4826     --
4827     p_inst_set(l_torrwnum) := g_cache_elpehs_inst(l_insttorrw_num);
4828     l_torrwnum := l_torrwnum+1;
4829     --
4830   end loop;
4831   --
4832   p_inst_count := l_torrwnum;
4833   --
4834 --  hr_utility.set_location('Leaving : '||l_proc,100);
4835 exception
4836   --
4837   when no_data_found then
4838     --
4839     p_inst_count := 0;
4840     --
4841 end elpehs_getcacdets;
4842 --
4843 procedure elpefp_writecache
4844   (p_effective_date in date,
4845    p_refresh_cache  in boolean default FALSE) is
4846   --
4847   l_proc varchar2(72) :=  'elpefp_writecache';
4848   l_torrwnum pls_integer;
4849   l_prev_id number;
4850   l_id number;
4851   --
4852   cursor c_elpefp_look is
4853     select elp.eligy_prfl_id, elp.business_group_id
4854     from   ben_eligy_prfl_f elp
4855     where  p_effective_date
4856            between elp.effective_start_date
4857            and     elp.effective_end_date
4858     and    exists(select null
4859                   from   ben_elig_fl_tm_pt_tm_prte_f efp
4860                   where  p_effective_date
4861                          between efp.effective_start_date
4862                          and     efp.effective_end_date
4863                   and efp.eligy_prfl_id = elp.eligy_prfl_id)
4864     order  by elp.eligy_prfl_id;
4865   --
4866   cursor c_elpefp_inst is
4867     select efp.eligy_prfl_id,
4868            efp.elig_fl_tm_pt_tm_prte_id pk_id,
4869            'EFP' short_code,
4870            efp.fl_tm_pt_tm_cd,
4871            efp.excld_flag,
4872            efp.criteria_score,
4873            efp.criteria_weight
4874     from   ben_elig_fl_tm_pt_tm_prte_f efp
4875     where  p_effective_date
4876            between efp.effective_start_date
4877            and efp.effective_end_date
4878     order  by efp.eligy_prfl_id,
4879            decode(efp.excld_flag,'Y',1,2),
4880            efp.ordr_num;
4881   --
4882   l_not_hash_found boolean;
4883   --
4884 begin
4885   --
4886   for objlook in c_elpefp_look loop
4887     --
4888     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
4889     --
4890     -- Check if hashed value is already allocated
4891     --
4892     if g_cache_elpefp_lookup.exists(l_id) then
4893       --
4894       l_not_hash_found := false;
4895       --
4896       -- Loop until un-allocated has value is derived
4897       --
4898       while not l_not_hash_found loop
4899         --
4900         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4901         --
4902         -- Check if the hash index exists, if not we can use it
4903         --
4904         if not g_cache_elpefp_lookup.exists(l_id) then
4905           --
4906           -- Lets store the hash value in the index
4907           --
4908           l_not_hash_found := true;
4909           exit;
4910           --
4911         else
4912           --
4913           l_not_hash_found := false;
4914           --
4915         end if;
4916       --
4917       end loop;
4918       --
4919     end if;
4920     --
4921     g_cache_elpefp_lookup(l_id).id := objlook.eligy_prfl_id;
4922     g_cache_elpefp_lookup(l_id).fk_id := objlook.business_group_id;
4923     --
4924   end loop;
4925   --
4926   l_torrwnum := 0;
4927   l_prev_id := -1;
4928   --
4929   for objinst in c_elpefp_inst loop
4930     --
4931     -- Populate the cache lookup details
4932     --
4933     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
4934     --
4935     -- Check if hashed value is already allocated
4936     --
4937     if g_cache_elpefp_lookup(l_id).id = objinst.eligy_prfl_id then
4938       --
4939       null;
4940       --
4941     else
4942       --
4943       loop
4944         --
4945         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
4946         --
4947         if g_cache_elpefp_lookup(l_id).id = objinst.eligy_prfl_id then
4948           --
4949           exit;
4950           --
4951         end if;
4952         --
4953       end loop;
4954       --
4955     end if;
4956     --
4957     -- Check for first row
4958     --
4959     if l_prev_id = -1 then
4960       --
4961       g_cache_elpefp_lookup(l_id).starttorele_num := l_torrwnum;
4962       --
4963     elsif l_id <> l_prev_id then
4964       --
4965       g_cache_elpefp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4966       g_cache_elpefp_lookup(l_id).starttorele_num := l_torrwnum;
4967       --
4968     end if;
4969     --
4970     -- Populate the cache instance details
4971     --
4972     g_cache_elpefp_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
4973     g_cache_elpefp_inst(l_torrwnum).pk_id := objinst.pk_id;
4974     g_cache_elpefp_inst(l_torrwnum).short_code := objinst.short_code;
4975     g_cache_elpefp_inst(l_torrwnum).criteria_score := objinst.criteria_score;
4976     g_cache_elpefp_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
4977     g_cache_elpefp_inst(l_torrwnum).fl_tm_pt_tm_cd := objinst.fl_tm_pt_tm_cd;
4978     g_cache_elpefp_inst(l_torrwnum).excld_flag := objinst.excld_flag;
4979     --
4980     l_torrwnum := l_torrwnum+1;
4981     l_prev_id := l_id;
4982     --
4983   end loop;
4984   --
4985   g_cache_elpefp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
4986   --
4987 end elpefp_writecache;
4988 --
4989 procedure elpefp_getcacdets
4990   (p_effective_date    in  date,
4991    p_business_group_id in  number,
4992    p_eligy_prfl_id     in  number,
4993    p_refresh_cache     in  boolean default FALSE,
4994    p_inst_set          out nocopy ben_elp_cache.g_cache_elpefp_instor,
4995    p_inst_count        out nocopy number) is
4996   --
4997   l_proc varchar2(72) :=  'elpefp_getcacdets';
4998   l_torrwnum pls_integer;
4999   l_insttorrw_num pls_integer;
5000   l_index         pls_integer;
5001   --
5002   l_not_hash_found boolean;
5003   --
5004 begin
5005   --
5006   -- Flush the cache
5007   --
5008   if p_refresh_cache then
5009     --
5010     g_cache_elpefp_lookup.delete;
5011     g_cache_elpefp_inst.delete;
5012     --
5013   end if;
5014   --
5015   -- Populate the global cache
5016   --
5017   if g_cache_elpefp_lookup.count = 0 then
5018     --
5019     -- Build the cache
5020     --
5021     ben_elp_cache.elpefp_writecache
5022       (p_effective_date => p_effective_date,
5023        p_refresh_cache  => p_refresh_cache);
5024     --
5025   end if;
5026   --
5027   -- Get the instance details
5028   --
5029   l_torrwnum := 0;
5030   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
5031   --
5032   -- Check if hashed value is already allocated
5033   --
5034   if g_cache_elpefp_lookup.exists(l_index) then
5035     --
5036     -- If it does exist make sure its the right one
5037     --
5038     if g_cache_elpefp_lookup(l_index).id <> p_eligy_prfl_id then
5039       --
5040       l_not_hash_found := false;
5041       --
5042       -- Loop until un-allocated has value is derived
5043       --
5044       while not l_not_hash_found loop
5045         --
5046         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
5047         --
5048         -- Check if the hash index exists, if not we can use it
5049         --
5050         if not g_cache_elpefp_lookup.exists(l_index) then
5051           --
5052           -- Lets store the hash value in the index
5053           --
5054           l_not_hash_found := true;
5055           exit;
5056           --
5057         else
5058           --
5059           l_not_hash_found := false;
5060           --
5061         end if;
5062         --
5063       end loop;
5064       --
5065     end if;
5066     --
5067   end if;
5068   --
5069   for l_insttorrw_num in g_cache_elpefp_lookup(l_index).starttorele_num ..
5070     g_cache_elpefp_lookup(l_index).endtorele_num loop
5071     --
5072     p_inst_set(l_torrwnum) := g_cache_elpefp_inst(l_insttorrw_num);
5073     l_torrwnum := l_torrwnum+1;
5074     --
5075   end loop;
5076   --
5077   p_inst_count := l_torrwnum;
5078   --
5079 exception
5080   --
5081   when no_data_found then
5082     --
5083     p_inst_count := 0;
5084     --
5085 end elpefp_getcacdets;
5086 --
5087 procedure elpesh_writecache
5088   (p_effective_date in date,
5089    p_refresh_cache  in boolean default FALSE) is
5090   --
5091   l_proc varchar2(72) :=  'elpesh_writecache';
5092   l_torrwnum pls_integer;
5093   l_prev_id number;
5094   l_id number;
5095   --
5096   cursor c_elpesh_look is
5097     select elp.eligy_prfl_id,
5098            elp.business_group_id
5099     from   ben_eligy_prfl_f elp
5100     where  p_effective_date
5101            between elp.effective_start_date
5102            and elp.effective_end_date
5103     and    exists(select null
5104                   from   ben_elig_schedd_hrs_prte_f esh
5105                   where  p_effective_date
5106                          between esh.effective_start_date
5107                          and     esh.effective_end_date
5108                   and    esh.eligy_prfl_id = elp.eligy_prfl_id)
5109     order  by elp.eligy_prfl_id;
5110   --
5111   cursor c_elpesh_inst is
5112     select esh.eligy_prfl_id,
5113            esh.elig_schedd_hrs_prte_id pk_id,
5114            'ESH' short_code,
5115            esh.hrs_num,
5116            esh.determination_cd,
5117            esh.determination_rl,
5118            esh.rounding_cd,
5119            esh.rounding_rl,
5120            esh.max_hrs_num,
5121            esh.schedd_hrs_rl,
5122            esh.freq_cd,
5123            esh.excld_flag,
5124            esh.criteria_score,
5125            esh.criteria_weight
5126     from   ben_elig_schedd_hrs_prte_f esh
5127     where  p_effective_date
5128            between esh.effective_start_date
5129            and     esh.effective_end_date
5130     order  by esh.eligy_prfl_id,
5131            decode(esh.excld_flag,'Y',1,2),
5132            esh.ordr_num;
5133   --
5134   l_not_hash_found boolean;
5135   --
5136 begin
5137   --
5138   for objlook in c_elpesh_look loop
5139     --
5140     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
5141     --
5142     -- Check if hashed value is already allocated
5143     --
5144     if g_cache_elpesh_lookup.exists(l_id) then
5145       --
5146       l_not_hash_found := false;
5147       --
5148       -- Loop until un-allocated has value is derived
5149       --
5150       while not l_not_hash_found loop
5151         --
5152         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5153         --
5154         -- Check if the hash index exists, if not we can use it
5155         --
5156         if not g_cache_elpesh_lookup.exists(l_id) then
5157           --
5158           -- Lets store the hash value in the index
5159           --
5160           l_not_hash_found := true;
5161           exit;
5162           --
5163         else
5164           --
5165           l_not_hash_found := false;
5166           --
5167         end if;
5168       --
5169       end loop;
5170       --
5171     end if;
5172     --
5173     g_cache_elpesh_lookup(l_id).id := objlook.eligy_prfl_id;
5174     g_cache_elpesh_lookup(l_id).fk_id := objlook.business_group_id;
5175     --
5176   end loop;
5177   --
5178   l_torrwnum := 0;
5179   l_prev_id := -1;
5180   --
5181   for objinst in c_elpesh_inst loop
5182     --
5183     -- Populate the cache lookup details
5184     --
5185     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
5186     --
5187     -- Check if hashed value is already allocated
5188     --
5189     if g_cache_elpesh_lookup(l_id).id = objinst.eligy_prfl_id then
5190       --
5191       null;
5192       --
5193     else
5194       --
5195       loop
5196         --
5197         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5198         --
5199         if g_cache_elpesh_lookup(l_id).id = objinst.eligy_prfl_id then
5200           --
5201           exit;
5202           --
5203         end if;
5204         --
5205       end loop;
5206       --
5207     end if;
5208     --
5209     -- Check for first row
5210     --
5211     if l_prev_id = -1 then
5212       --
5213       g_cache_elpesh_lookup(l_id).starttorele_num := l_torrwnum;
5214       --
5215     elsif l_id <> l_prev_id then
5216       --
5217       g_cache_elpesh_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
5218       g_cache_elpesh_lookup(l_id).starttorele_num := l_torrwnum;
5219       --
5220     end if;
5221     --
5222     -- Populate the cache instance details
5223     --
5224     g_cache_elpesh_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
5225     g_cache_elpesh_inst(l_torrwnum).pk_id := objinst.pk_id;
5226     g_cache_elpesh_inst(l_torrwnum).short_code := objinst.short_code;
5227     g_cache_elpesh_inst(l_torrwnum).criteria_score := objinst.criteria_score;
5228     g_cache_elpesh_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
5229     g_cache_elpesh_inst(l_torrwnum).hrs_num := objinst.hrs_num;
5230     g_cache_elpesh_inst(l_torrwnum).determination_cd:= objinst.determination_cd;
5231     g_cache_elpesh_inst(l_torrwnum).determination_rl:= objinst.determination_rl;
5232     g_cache_elpesh_inst(l_torrwnum).rounding_cd:= objinst.rounding_cd;
5233     g_cache_elpesh_inst(l_torrwnum).rounding_rl:= objinst.rounding_rl;
5234     g_cache_elpesh_inst(l_torrwnum).max_hrs_num:= objinst.max_hrs_num;
5235     g_cache_elpesh_inst(l_torrwnum).schedd_hrs_rl:= objinst.schedd_hrs_rl;
5236     g_cache_elpesh_inst(l_torrwnum).freq_cd := objinst.freq_cd;
5237     g_cache_elpesh_inst(l_torrwnum).excld_flag := objinst.excld_flag;
5238     --
5239     l_torrwnum := l_torrwnum+1;
5240     l_prev_id := l_id;
5241     --
5242   end loop;
5243   --
5244   g_cache_elpesh_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
5245   --
5246 end elpesh_writecache;
5247 --
5248 procedure elpesh_getcacdets
5249   (p_effective_date    in  date,
5250    p_business_group_id in  number,
5251    p_eligy_prfl_id     in  number,
5252    p_refresh_cache     in  boolean default FALSE,
5253    p_inst_set          out nocopy ben_elp_cache.g_cache_elpesh_instor,
5254    p_inst_count        out nocopy number) is
5255   --
5256   l_proc varchar2(72) :=  'elpesh_getcacdets';
5257   l_torrwnum pls_integer;
5258   l_insttorrw_num pls_integer;
5259   l_index         pls_integer;
5260   --
5261   l_not_hash_found boolean;
5262   --
5263 begin
5264   --
5265   -- Flush the cache
5266   --
5267   if p_refresh_cache then
5268     --
5269     g_cache_elpesh_lookup.delete;
5270     g_cache_elpesh_inst.delete;
5271     --
5272   end if;
5273   --
5274   -- Populate the global cache
5275   --
5276   if g_cache_elpesh_lookup.count = 0 then
5277     --
5278     -- Build the cache
5279     --
5280     ben_elp_cache.elpesh_writecache
5281       (p_effective_date => p_effective_date,
5282        p_refresh_cache  => p_refresh_cache);
5283     --
5284   end if;
5285   --
5286   -- Get the instance details
5287   --
5288   l_torrwnum := 0;
5289   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
5290   --
5291   -- Check if hashed value is already allocated
5292   --
5293   if g_cache_elpesh_lookup.exists(l_index) then
5294     --
5295     -- If it does exist make sure its the right one
5296     --
5297     if g_cache_elpesh_lookup(l_index).id <> p_eligy_prfl_id then
5298       --
5299       l_not_hash_found := false;
5300       --
5301       -- Loop until un-allocated has value is derived
5302       --
5303       while not l_not_hash_found loop
5304         --
5305         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
5306         --
5307         -- Check if the hash index exists, if not we can use it
5308         --
5309         if not g_cache_elpesh_lookup.exists(l_index) then
5310           --
5311           -- Lets store the hash value in the index
5312           --
5313           l_not_hash_found := true;
5314           exit;
5315           --
5316         else
5317           --
5318           l_not_hash_found := false;
5319           --
5320         end if;
5321         --
5322       end loop;
5323       --
5324     end if;
5325     --
5326   end if;
5327   --
5328   for l_insttorrw_num in g_cache_elpesh_lookup(l_index).starttorele_num ..
5329     g_cache_elpesh_lookup(l_index).endtorele_num loop
5330     --
5331     p_inst_set(l_torrwnum) := g_cache_elpesh_inst(l_insttorrw_num);
5332     l_torrwnum := l_torrwnum+1;
5333     --
5334   end loop;
5335   --
5336   p_inst_count := l_torrwnum;
5337   --
5338 exception
5339   --
5340   when no_data_found then
5341     --
5342     p_inst_count := 0;
5343     --
5344 end elpesh_getcacdets;
5345 --
5346 procedure elpehw_writecache
5347   (p_effective_date in date,
5348    p_refresh_cache  in boolean default FALSE) is
5349   --
5350   l_proc varchar2(72) :=  'elpehw_writecache';
5351   l_torrwnum pls_integer;
5352   l_prev_id number;
5353   l_id number;
5354   --
5355   cursor c_elpehw_look is
5356     select elp.eligy_prfl_id, elp.business_group_id
5357     from   ben_eligy_prfl_f elp
5358     where  p_effective_date
5359            between elp.effective_start_date
5360            and     elp.effective_end_date
5361     and    exists(select null
5362                   from   ben_elig_hrs_wkd_prte_f ecl,
5363                          ben_hrs_wkd_in_perd_fctr clf
5364                   where  ecl.hrs_wkd_in_perd_fctr_id =
5365                          clf.hrs_wkd_in_perd_fctr_id
5366                   and    ecl.business_group_id = clf.business_group_id
5367                   and    p_effective_date
5368                          between ecl.effective_start_date
5369                          and     ecl.effective_end_date
5370                   and    ecl.eligy_prfl_id = elp.eligy_prfl_id)
5371     order  by elp.eligy_prfl_id;
5372   --
5373   cursor c_elpehw_inst is
5374     select ecl.eligy_prfl_id,
5375            ecl.elig_hrs_wkd_prte_id pk_id,
5376            'EHW' short_code,
5377            ecl.hrs_wkd_in_perd_fctr_id,
5378            ecl.excld_flag,
5379            ecl.criteria_score,
5380            ecl.criteria_weight,
5381            clf.mn_hrs_num,
5382            clf.mx_hrs_num,
5383            clf.no_mn_hrs_wkd_flag,
5384            clf.no_mx_hrs_wkd_flag,
5385            clf.hrs_src_cd
5386     from   ben_elig_hrs_wkd_prte_f ecl,
5387            ben_hrs_wkd_in_perd_fctr clf
5388     where  ecl.hrs_wkd_in_perd_fctr_id = clf.hrs_wkd_in_perd_fctr_id
5389     and    ecl.business_group_id = clf.business_group_id
5390     and    p_effective_date
5391            between ecl.effective_start_date
5392            and     ecl.effective_end_date
5393     order  by ecl.eligy_prfl_id,
5394            decode(ecl.excld_flag,'Y',1,2),
5395            ecl.ordr_num;
5396   --
5397   l_not_hash_found boolean;
5398   --
5399 begin
5400   --
5401   for objlook in c_elpehw_look loop
5402   --
5403     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
5404     --
5405     -- Check if hashed value is already allocated
5406     --
5407     if g_cache_elpehw_lookup.exists(l_id) then
5408       --
5409       l_not_hash_found := false;
5410       --
5411       -- Loop until un-allocated has value is derived
5412       --
5413       while not l_not_hash_found loop
5414         --
5415         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5416         --
5417         -- Check if the hash index exists, if not we can use it
5418         --
5419         if not g_cache_elpehw_lookup.exists(l_id) then
5420           --
5421           -- Lets store the hash value in the index
5422           --
5423           l_not_hash_found := true;
5424           exit;
5425           --
5426         else
5427           --
5428           l_not_hash_found := false;
5429           --
5430         end if;
5431       --
5432       end loop;
5433       --
5434     end if;
5435     --
5436     g_cache_elpehw_lookup(l_id).id := objlook.eligy_prfl_id;
5437     g_cache_elpehw_lookup(l_id).fk_id := objlook.business_group_id;
5438     --
5439   end loop;
5440   --
5441   l_torrwnum := 0;
5442   l_prev_id := -1;
5443   --
5444   for objinst in c_elpehw_inst loop
5445     --
5446     -- Populate the cache lookup details
5447     --
5448     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
5449     --
5450     -- Check if hashed value is already allocated
5451     --
5452     if g_cache_elpehw_lookup(l_id).id = objinst.eligy_prfl_id then
5453       --
5454       null;
5455       --
5456     else
5457       --
5458       loop
5459         --
5460         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5461         --
5462         if g_cache_elpehw_lookup(l_id).id = objinst.eligy_prfl_id then
5463           --
5464           exit;
5465           --
5466         end if;
5467         --
5468       end loop;
5469       --
5470     end if;
5471     --
5472     -- Check for first row
5473     --
5474     if l_prev_id = -1 then
5475       --
5476       g_cache_elpehw_lookup(l_id).starttorele_num := l_torrwnum;
5477       --
5478     elsif l_id <> l_prev_id then
5479       --
5480       g_cache_elpehw_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
5481       g_cache_elpehw_lookup(l_id).starttorele_num := l_torrwnum;
5482       --
5483     end if;
5484     --
5485     -- Populate the cache instance details
5486     --
5487     g_cache_elpehw_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
5488     g_cache_elpehw_inst(l_torrwnum).pk_id := objinst.pk_id;
5489     g_cache_elpehw_inst(l_torrwnum).short_code := objinst.short_code;
5490     g_cache_elpehw_inst(l_torrwnum).criteria_score := objinst.criteria_score;
5491     g_cache_elpehw_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
5492     g_cache_elpehw_inst(l_torrwnum).excld_flag := objinst.excld_flag;
5493     g_cache_elpehw_inst(l_torrwnum).mn_hrs_num := objinst.mn_hrs_num;
5494     g_cache_elpehw_inst(l_torrwnum).mx_hrs_num := objinst.mx_hrs_num;
5495     g_cache_elpehw_inst(l_torrwnum).no_mn_hrs_wkd_flag := objinst.no_mn_hrs_wkd_flag;
5496     g_cache_elpehw_inst(l_torrwnum).no_mx_hrs_wkd_flag := objinst.no_mx_hrs_wkd_flag;
5497     g_cache_elpehw_inst(l_torrwnum).hrs_src_cd := objinst.hrs_src_cd;
5498     --
5499     l_torrwnum := l_torrwnum+1;
5500     l_prev_id := l_id;
5501     --
5502   end loop;
5503   --
5504   g_cache_elpehw_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
5505   --
5506 end elpehw_writecache;
5507 --
5508 procedure elpehw_getcacdets
5509   (p_effective_date    in  date,
5510    p_business_group_id in  number,
5511    p_eligy_prfl_id     in  number,
5512    p_hrs_src_cd        in  varchar2 default null,
5513    p_refresh_cache     in  boolean default FALSE,
5514    p_inst_set          out nocopy ben_elp_cache.g_cache_elpehw_instor,
5515    p_inst_count        out nocopy number) is
5516   --
5517   l_proc varchar2(72) :=  'elpehw_getcacdets';
5518   l_torrwnum pls_integer;
5519   l_insttorrw_num pls_integer;
5520   l_index         pls_integer;
5521   --
5522   l_not_hash_found boolean;
5523   --
5524 begin
5525   --
5526   -- Flush the cache
5527   --
5528   if p_refresh_cache then
5529     --
5530     g_cache_elpehw_lookup.delete;
5531     g_cache_elpehw_inst.delete;
5532     --
5533   end if;
5534   --
5535   -- Populate the global cache
5536   --
5537   if g_cache_elpehw_lookup.count = 0 then
5538     --
5539     -- Build the cache
5540     --
5541     ben_elp_cache.elpehw_writecache
5542       (p_effective_date => p_effective_date,
5543        p_refresh_cache  => p_refresh_cache);
5544     --
5545   end if;
5546   --
5547   -- Get the instance details
5548   --
5549   l_torrwnum := 0;
5550   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
5551   --
5552   -- Check if hashed value is already allocated
5553   --
5554   if g_cache_elpehw_lookup.exists(l_index) then
5555     --
5556     -- If it does exist make sure its the right one
5557     --
5558     if g_cache_elpehw_lookup(l_index).id <> p_eligy_prfl_id then
5559       --
5560       l_not_hash_found := false;
5561       --
5562       -- Loop until un-allocated has value is derived
5563       --
5564       while not l_not_hash_found loop
5565         --
5566         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
5567         --
5568         -- Check if the hash index exists, if not we can use it
5569         --
5570         if not g_cache_elpehw_lookup.exists(l_index) then
5571           --
5572           -- Lets store the hash value in the index
5573           --
5574           l_not_hash_found := true;
5575           exit;
5576           --
5577         else
5578           --
5579           l_not_hash_found := false;
5580           --
5581         end if;
5582         --
5583       end loop;
5584       --
5585     end if;
5586     --
5587   end if;
5588   --
5589   for l_insttorrw_num in g_cache_elpehw_lookup(l_index).starttorele_num ..
5590     g_cache_elpehw_lookup(l_index).endtorele_num loop
5591     --
5592     if nvl(g_cache_elpehw_inst(l_insttorrw_num).hrs_src_cd,'ZZZZZ') = nvl(p_hrs_src_cd,'XXXXX') then
5593       --
5594       p_inst_set(l_torrwnum) := g_cache_elpehw_inst(l_insttorrw_num);
5595       l_torrwnum := l_torrwnum+1;
5596       --
5597     end if;
5598     --
5599   end loop;
5600   --
5601   p_inst_count := l_torrwnum;
5602   --
5603 exception
5604   --
5605   when no_data_found then
5606     --
5607     p_inst_count := 0;
5608     --
5609 end elpehw_getcacdets;
5610 --
5611 procedure elpecl_writecache
5612   (p_effective_date in date,
5613    p_refresh_cache  in boolean default FALSE) is
5614   --
5615   l_proc varchar2(72) :=  'elpecl_writecache';
5616   l_torrwnum pls_integer;
5617   l_prev_id number;
5618   l_id number;
5619   --
5620   cursor c_elpecl_look is
5621     select elp.eligy_prfl_id, elp.business_group_id
5622     from   ben_eligy_prfl_f elp
5623     where  p_effective_date
5624            between elp.effective_start_date
5625            and elp.effective_end_date
5626     and    exists(select null
5627                   from   ben_elig_comp_lvl_prte_f ecl,
5628                          ben_comp_lvl_fctr clf
5629                   where  ecl.comp_lvl_fctr_id = clf.comp_lvl_fctr_id
5630                   and    ecl.business_group_id = clf.business_group_id
5631                   and    p_effective_date
5632                          between ecl.effective_start_date
5633                          and     ecl.effective_end_date
5634                   and ecl.eligy_prfl_id = elp.eligy_prfl_id)
5635     order  by elp.eligy_prfl_id;
5636   --
5637   cursor c_elpecl_inst is
5638     select ecl.eligy_prfl_id,
5639            ecl.elig_comp_lvl_prte_id pk_id,
5640            'ECL' short_code,
5641            ecl.excld_flag,
5642            ecl.criteria_score,
5643            ecl.criteria_weight,
5644            clf.mn_comp_val,
5645            clf.mx_comp_val,
5646            clf.no_mn_comp_flag,
5647            clf.no_mx_comp_flag,
5648            clf.comp_src_cd,
5649            clf.comp_lvl_fctr_id
5650     from   ben_elig_comp_lvl_prte_f ecl,
5651            ben_comp_lvl_fctr clf
5652     where  ecl.comp_lvl_fctr_id = clf.comp_lvl_fctr_id
5653     and    ecl.business_group_id = clf.business_group_id
5654     and    p_effective_date
5655            between ecl.effective_start_date
5656            and     ecl.effective_end_date
5657     order  by ecl.eligy_prfl_id,
5658            decode(ecl.excld_flag,'Y',1,2),
5659            ecl.ordr_num;
5660   --
5661   l_not_hash_found boolean;
5662   --
5663 begin
5664   --
5665   for objlook in c_elpecl_look loop
5666     --
5667     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
5668     --
5669     -- Check if hashed value is already allocated
5670     --
5671     if g_cache_elpecl_lookup.exists(l_id) then
5672       --
5673       l_not_hash_found := false;
5674       --
5675       -- Loop until un-allocated has value is derived
5676       --
5677       while not l_not_hash_found loop
5678         --
5679         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5680         --
5681         -- Check if the hash index exists, if not we can use it
5682         --
5683         if not g_cache_elpecl_lookup.exists(l_id) then
5684           --
5685           -- Lets store the hash value in the index
5686           --
5687           l_not_hash_found := true;
5688           exit;
5689           --
5690         else
5691           --
5692           l_not_hash_found := false;
5693           --
5694         end if;
5695         --
5696       end loop;
5697       --
5698     end if;
5699     --
5700     g_cache_elpecl_lookup(l_id).id := objlook.eligy_prfl_id;
5701     g_cache_elpecl_lookup(l_id).fk_id := objlook.business_group_id;
5702     --
5703   end loop;
5704   --
5705   l_torrwnum := 0;
5706   l_prev_id := -1;
5707   --
5708   for objinst in c_elpecl_inst loop
5709     --
5710     -- Populate the cache lookup details
5711     --
5712     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
5713     --
5714     -- Check if hashed value is already allocated
5715     --
5716     if g_cache_elpecl_lookup(l_id).id = objinst.eligy_prfl_id then
5717       --
5718       null;
5719       --
5720     else
5721       --
5722       loop
5723         --
5724         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5725         --
5726         if g_cache_elpecl_lookup(l_id).id = objinst.eligy_prfl_id then
5727           --
5728           exit;
5729           --
5730         end if;
5731         --
5732       end loop;
5733       --
5734     end if;
5735     --
5736     -- Check for first row
5737     --
5738     if l_prev_id = -1 then
5739       --
5740       g_cache_elpecl_lookup(l_id).starttorele_num := l_torrwnum;
5741       --
5742     elsif l_id <> l_prev_id then
5743       --
5744       g_cache_elpecl_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
5745       g_cache_elpecl_lookup(l_id).starttorele_num := l_torrwnum;
5746       --
5747     end if;
5748     --
5749     -- Populate the cache instance details
5750     --
5751     g_cache_elpecl_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
5752     g_cache_elpecl_inst(l_torrwnum).pk_id := objinst.pk_id;
5753     g_cache_elpecl_inst(l_torrwnum).short_code := objinst.short_code;
5754     g_cache_elpecl_inst(l_torrwnum).criteria_score := objinst.criteria_score;
5755     g_cache_elpecl_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
5756     g_cache_elpecl_inst(l_torrwnum).excld_flag := objinst.excld_flag;
5757     g_cache_elpecl_inst(l_torrwnum).mn_comp_val := objinst.mn_comp_val;
5758     g_cache_elpecl_inst(l_torrwnum).mx_comp_val := objinst.mx_comp_val;
5759     g_cache_elpecl_inst(l_torrwnum).no_mn_comp_flag := objinst.no_mn_comp_flag;
5760     g_cache_elpecl_inst(l_torrwnum).no_mx_comp_flag := objinst.no_mx_comp_flag;
5761     g_cache_elpecl_inst(l_torrwnum).comp_src_cd := objinst.comp_src_cd;
5762     g_cache_elpecl_inst(l_torrwnum).comp_lvl_fctr_id := objinst.comp_lvl_fctr_id;
5763     --
5764     l_torrwnum := l_torrwnum+1;
5765     l_prev_id := l_id;
5766     --
5767   end loop;
5768   --
5769   g_cache_elpecl_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
5770   --
5771 end elpecl_writecache;
5772 --
5773 procedure elpecl_getcacdets
5774   (p_effective_date    in  date,
5775    p_business_group_id in  number,
5776    p_eligy_prfl_id     in  number,
5777    p_comp_src_cd       in  varchar2 default null,
5778    p_refresh_cache     in  boolean default FALSE,
5779    p_inst_set          out nocopy ben_elp_cache.g_cache_elpecl_instor,
5780    p_inst_count        out nocopy number) is
5781   --
5782   l_proc varchar2(72) :=  'elpecl_getcacdets';
5783   l_torrwnum pls_integer;
5784   l_insttorrw_num pls_integer;
5785   l_index         pls_integer;
5786   --
5787   l_not_hash_found boolean;
5788   --
5789 begin
5790   --
5791   -- Flush the cache
5792   --
5793   if p_refresh_cache then
5794     --
5795     g_cache_elpecl_lookup.delete;
5796     g_cache_elpecl_inst.delete;
5797     --
5798   end if;
5799   --
5800   -- Populate the global cache
5801   --
5802   if g_cache_elpecl_lookup.count = 0 then
5803     --
5804     -- Build the cache
5805     --
5806     ben_elp_cache.elpecl_writecache
5807       (p_effective_date => p_effective_date,
5808        p_refresh_cache  => p_refresh_cache);
5809     --
5810   end if;
5811   --
5812   -- Get the instance details
5813   --
5814   l_torrwnum := 0;
5815   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
5816   --
5817   -- Check if hashed value is already allocated
5818   --
5819   if g_cache_elpecl_lookup.exists(l_index) then
5820     --
5821     -- If it does exist make sure its the right one
5822     --
5823     if g_cache_elpecl_lookup(l_index).id <> p_eligy_prfl_id then
5824       --
5825       l_not_hash_found := false;
5826       --
5827       -- Loop until un-allocated has value is derived
5828       --
5829       while not l_not_hash_found loop
5830         --
5831         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
5832         --
5833         -- Check if the hash index exists, if not we can use it
5834         --
5835         if not g_cache_elpecl_lookup.exists(l_index) then
5836           --
5837           -- Lets store the hash value in the index
5838           --
5839           l_not_hash_found := true;
5840           exit;
5841           --
5842         else
5843           --
5844           l_not_hash_found := false;
5845           --
5846         end if;
5847         --
5848       end loop;
5849       --
5850     end if;
5851     --
5852   end if;
5853   --
5854   for l_insttorrw_num in g_cache_elpecl_lookup(l_index).starttorele_num ..
5855     g_cache_elpecl_lookup(l_index).endtorele_num loop
5856     --
5857     if nvl(g_cache_elpecl_inst(l_insttorrw_num).comp_src_cd,'ZZZZZ') = nvl(p_comp_src_cd,'XXXXX') then
5858       --
5859       p_inst_set(l_torrwnum) := g_cache_elpecl_inst(l_insttorrw_num);
5860       l_torrwnum := l_torrwnum+1;
5861       --
5862     end if;
5863     --
5864   end loop;
5865   --
5866   p_inst_count := l_torrwnum;
5867   --
5868 exception
5869   --
5870   when no_data_found then
5871     --
5872     p_inst_count := 0;
5873     --
5874 end elpecl_getcacdets;
5875 --
5876 procedure elpepf_writecache
5877   (p_effective_date in date,
5878    p_refresh_cache  in boolean default FALSE) is
5879   --
5880   l_proc varchar2(72) :=  'elpepf_writecache';
5881   l_torrwnum pls_integer;
5882   l_prev_id number;
5883   l_id number;
5884   --
5885   cursor c_elpepf_look is
5886     select epl.eligy_prfl_id,
5887            epl.business_group_id
5888     from   ben_eligy_prfl_f epl
5889     where  p_effective_date
5890            between epl.effective_start_date
5891            and     epl.effective_end_date
5892     and    exists(select null
5893                   from   ben_elig_pct_fl_tm_prte_f epf,
5894                          ben_pct_fl_tm_fctr pff
5895                   where  epf.pct_fl_tm_fctr_id = pff.pct_fl_tm_fctr_id
5896                   and    epf.business_group_id = pff.business_group_id
5897                   and    p_effective_date
5898                          between epf.effective_start_date
5899                          and     epf.effective_end_date
5900                   and epf.eligy_prfl_id = epl.eligy_prfl_id)
5901     order  by epl.eligy_prfl_id;
5902   --
5903   cursor c_elpepf_inst is
5904     select epf.eligy_prfl_id,
5905            epf.elig_pct_fl_tm_prte_id pk_id,
5906            'EPF' short_code,
5907            epf.pct_fl_tm_fctr_id,
5908            epf.excld_flag,
5909            epf.criteria_score,
5910            epf.criteria_weight,
5911            pff.mx_pct_val,
5912            pff.mn_pct_val,
5913            pff.no_mn_pct_val_flag,
5914            pff.no_mx_pct_val_flag
5915     from   ben_elig_pct_fl_tm_prte_f epf,
5916            ben_pct_fl_tm_fctr pff
5917     where  epf.pct_fl_tm_fctr_id = pff.pct_fl_tm_fctr_id
5918     and    epf.business_group_id = pff.business_group_id
5919     and    p_effective_date
5920            between epf.effective_start_date
5921            and     epf.effective_end_date
5922     order  by epf.eligy_prfl_id,
5923            decode(epf.excld_flag,'Y',1,2),
5924            epf.ordr_num;
5925   --
5926   l_not_hash_found boolean;
5927   --
5928 begin
5929   --
5930   for objlook in c_elpepf_look loop
5931     --
5932     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
5933     --
5934     -- Check if hashed value is already allocated
5935     --
5936     if g_cache_elpepf_lookup.exists(l_id) then
5937       --
5938       l_not_hash_found := false;
5939       --
5940       -- Loop until un-allocated has value is derived
5941       --
5942       while not l_not_hash_found loop
5943         --
5944         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5945         --
5946         -- Check if the hash index exists, if not we can use it
5947         --
5948         if not g_cache_elpepf_lookup.exists(l_id) then
5949           --
5950           -- Lets store the hash value in the index
5951           --
5952           l_not_hash_found := true;
5953           exit;
5954           --
5955         else
5956           --
5957           l_not_hash_found := false;
5958           --
5959         end if;
5960         --
5961       end loop;
5962       --
5963     end if;
5964     --
5965     g_cache_elpepf_lookup(l_id).id := objlook.eligy_prfl_id;
5966     g_cache_elpepf_lookup(l_id).fk_id := objlook.business_group_id;
5967     --
5968   end loop;
5969   --
5970   l_torrwnum := 0;
5971   l_prev_id := -1;
5972   --
5973   for objinst in c_elpepf_inst loop
5974     --
5975     -- Populate the cache lookup details
5976     --
5977     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
5978     --
5979     -- Check if hashed value is already allocated
5980     --
5981     if g_cache_elpepf_lookup(l_id).id = objinst.eligy_prfl_id then
5982       --
5983       null;
5984       --
5985     else
5986       --
5987       loop
5988         --
5989         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
5990         --
5991         if g_cache_elpepf_lookup(l_id).id = objinst.eligy_prfl_id then
5992           --
5993           exit;
5994           --
5995         end if;
5996         --
5997       end loop;
5998       --
5999     end if;
6000     --
6001     -- Check for first row
6002     --
6003     if l_prev_id = -1 then
6004       --
6005       g_cache_elpepf_lookup(l_id).starttorele_num := l_torrwnum;
6006       --
6007     elsif l_id <> l_prev_id then
6008       --
6009       g_cache_elpepf_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6010       g_cache_elpepf_lookup(l_id).starttorele_num := l_torrwnum;
6011       --
6012     end if;
6013     --
6014     -- Populate the cache instance details
6015     --
6016     g_cache_elpepf_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
6017     g_cache_elpepf_inst(l_torrwnum).pk_id := objinst.pk_id;
6018     g_cache_elpepf_inst(l_torrwnum).short_code := objinst.short_code;
6019     g_cache_elpepf_inst(l_torrwnum).criteria_score := objinst.criteria_score;
6020     g_cache_elpepf_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
6021     g_cache_elpepf_inst(l_torrwnum).excld_flag := objinst.excld_flag;
6022     g_cache_elpepf_inst(l_torrwnum).mx_pct_val := objinst.mx_pct_val;
6023     g_cache_elpepf_inst(l_torrwnum).mn_pct_val := objinst.mn_pct_val;
6024     g_cache_elpepf_inst(l_torrwnum).no_mn_pct_val_flag := objinst.no_mn_pct_val_flag;
6025     g_cache_elpepf_inst(l_torrwnum).no_mx_pct_val_flag := objinst.no_mx_pct_val_flag;
6026     --
6027     l_torrwnum := l_torrwnum+1;
6028     l_prev_id := l_id;
6029     --
6030   end loop;
6031   --
6032   g_cache_elpepf_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6033   --
6034 end elpepf_writecache;
6035 --
6036 procedure elpepf_getcacdets
6037   (p_effective_date    in  date,
6038    p_business_group_id in  number,
6039    p_eligy_prfl_id     in  number,
6040    p_refresh_cache     in  boolean default FALSE,
6041    p_inst_set          out nocopy ben_elp_cache.g_cache_elpepf_instor,
6042    p_inst_count        out nocopy number) is
6043   --
6044   l_proc varchar2(72) :=  'elpepf_getcacdets';
6045   l_torrwnum pls_integer;
6046   l_insttorrw_num pls_integer;
6047   l_index         pls_integer;
6048   --
6049   l_not_hash_found boolean;
6050   --
6051 begin
6052   --
6053   -- Flush the cache
6054   --
6055   if p_refresh_cache then
6056     --
6057     g_cache_elpepf_lookup.delete;
6058     g_cache_elpepf_inst.delete;
6059     --
6060   end if;
6061   --
6062   -- Populate the global cache
6063   --
6064   if g_cache_elpepf_lookup.count = 0 then
6065     --
6066     -- Build the cache
6067     --
6068     ben_elp_cache.elpepf_writecache
6069       (p_effective_date => p_effective_date,
6070        p_refresh_cache  => p_refresh_cache);
6071     --
6072   end if;
6073   --
6074   -- Get the instance details
6075   --
6076   l_torrwnum := 0;
6077   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
6078   --
6079   -- Check if hashed value is already allocated
6080   --
6081   if g_cache_elpepf_lookup.exists(l_index) then
6082     --
6083     -- If it does exist make sure its the right one
6084     --
6085     if g_cache_elpepf_lookup(l_index).id <> p_eligy_prfl_id then
6086       --
6087       l_not_hash_found := false;
6088       --
6089       -- Loop until un-allocated has value is derived
6090       --
6091       while not l_not_hash_found loop
6092         --
6093         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
6094         --
6095         -- Check if the hash index exists, if not we can use it
6096         --
6097         if not g_cache_elpepf_lookup.exists(l_index) then
6098           --
6099           -- Lets store the hash value in the index
6100           --
6101           l_not_hash_found := true;
6102           exit;
6103           --
6104         else
6105           --
6106           l_not_hash_found := false;
6107           --
6108         end if;
6109         --
6110       end loop;
6111       --
6112     end if;
6113     --
6114   end if;
6115   --
6116   for l_insttorrw_num in g_cache_elpepf_lookup(l_index).starttorele_num ..
6117     g_cache_elpepf_lookup(l_index).endtorele_num loop
6118     --
6119     p_inst_set(l_torrwnum) := g_cache_elpepf_inst(l_insttorrw_num);
6120     l_torrwnum := l_torrwnum+1;
6121     --
6122   end loop;
6123   --
6124   p_inst_count := l_torrwnum;
6125   --
6126 exception
6127   --
6128   when no_data_found then
6129     --
6130     p_inst_count := 0;
6131     --
6132 end elpepf_getcacdets;
6133 --
6134 procedure elpegr_writecache
6135   (p_effective_date in date,
6136    p_refresh_cache  in boolean default FALSE) is
6137   --
6138   l_proc varchar2(72) :=  'elpegr_writecache';
6139   l_torrwnum pls_integer;
6140   l_prev_id number;
6141   l_id number;
6142   --
6143   cursor c_elpegr_look is
6144     select elp.eligy_prfl_id,
6145            elp.business_group_id
6146     from   ben_eligy_prfl_f elp
6147     where  p_effective_date
6148            between elp.effective_start_date
6149            and     elp.effective_end_date
6150     and    exists(select null
6151                   from   ben_elig_grd_prte_f egr
6152                   where  p_effective_date
6153                          between egr.effective_start_date
6154                          and     egr.effective_end_date
6155                   and    egr.eligy_prfl_id = elp.eligy_prfl_id)
6156     order  by elp.eligy_prfl_id;
6157   --
6158   cursor c_elpegr_inst is
6159     select egr.eligy_prfl_id,
6160            egr.elig_grd_prte_id pk_id,
6161            'EGR' short_code,
6162            egr.grade_id,
6163            egr.excld_flag,
6164            egr.criteria_score,
6165            egr.criteria_weight
6166     from   ben_elig_grd_prte_f egr
6167     where  p_effective_date
6168            between egr.effective_start_date
6169            and     egr.effective_end_date
6170     order  by egr.eligy_prfl_id,
6171            decode(egr.excld_flag,'Y',1,2),
6172            egr.ordr_num;
6173   --
6174   l_not_hash_found boolean;
6175   --
6176 begin
6177   --
6178   for objlook in c_elpegr_look loop
6179     --
6180     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
6181     --
6182     -- Check if hashed value is already allocated
6183     --
6184     if g_cache_elpegr_lookup.exists(l_id) then
6185       --
6186       l_not_hash_found := false;
6187       --
6188       -- Loop until un-allocated has value is derived
6189       --
6190       while not l_not_hash_found loop
6191         --
6192         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6193         --
6194         -- Check if the hash index exists, if not we can use it
6195         --
6196         if not g_cache_elpegr_lookup.exists(l_id) then
6197           --
6198           -- Lets store the hash value in the index
6199           --
6200           l_not_hash_found := true;
6201           exit;
6202           --
6203         else
6204           --
6205           l_not_hash_found := false;
6206           --
6207         end if;
6208         --
6209       end loop;
6210       --
6211     end if;
6212     --
6213     g_cache_elpegr_lookup(l_id).id := objlook.eligy_prfl_id;
6214     g_cache_elpegr_lookup(l_id).fk_id := objlook.business_group_id;
6215     --
6216   end loop;
6217   --
6218   l_torrwnum := 0;
6219   l_prev_id := -1;
6220   --
6221   for objinst in c_elpegr_inst loop
6222     --
6223     -- Populate the cache lookup details
6224     --
6225     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
6226     --
6227     -- Check if hashed value is already allocated
6228     --
6229     if g_cache_elpegr_lookup(l_id).id = objinst.eligy_prfl_id then
6230       --
6231       null;
6232       --
6233     else
6234       --
6235       loop
6236         --
6237         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6238         --
6239         if g_cache_elpegr_lookup(l_id).id = objinst.eligy_prfl_id then
6240           --
6241           exit;
6242           --
6243         end if;
6244         --
6245       end loop;
6246       --
6247     end if;
6248     --
6249     -- Check for first row
6250     --
6251     if l_prev_id = -1 then
6252       --
6253       g_cache_elpegr_lookup(l_id).starttorele_num := l_torrwnum;
6254       --
6255     elsif l_id <> l_prev_id then
6256       --
6257       g_cache_elpegr_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6258       g_cache_elpegr_lookup(l_id).starttorele_num := l_torrwnum;
6259       --
6260     end if;
6261     --
6262     -- Populate the cache instance details
6263     --
6264     g_cache_elpegr_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
6265     g_cache_elpegr_inst(l_torrwnum).pk_id := objinst.pk_id;
6266     g_cache_elpegr_inst(l_torrwnum).short_code := objinst.short_code;
6267     g_cache_elpegr_inst(l_torrwnum).criteria_score := objinst.criteria_score;
6268     g_cache_elpegr_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
6269     g_cache_elpegr_inst(l_torrwnum).grade_id := objinst.grade_id;
6270     g_cache_elpegr_inst(l_torrwnum).excld_flag := objinst.excld_flag;
6271     --
6272     l_torrwnum := l_torrwnum+1;
6273     l_prev_id := l_id;
6274     --
6275   end loop;
6276   --
6277   g_cache_elpegr_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6278   --
6279 end elpegr_writecache;
6280 --
6281 procedure elpegr_getcacdets
6282   (p_effective_date    in  date,
6283    p_business_group_id in  number,
6284    p_eligy_prfl_id     in  number,
6285    p_refresh_cache     in  boolean default FALSE,
6286    p_inst_set          out nocopy ben_elp_cache.g_cache_elpegr_instor,
6287    p_inst_count        out nocopy number) is
6288   --
6289   l_proc varchar2(72) :=  'elpegr_getcacdets';
6290   l_torrwnum pls_integer;
6291   l_insttorrw_num pls_integer;
6292   l_index         pls_integer;
6293   --
6294   l_not_hash_found boolean;
6295   --
6296 begin
6297   --
6298   -- Flush the cache
6299   --
6300   if p_refresh_cache then
6301     --
6302     g_cache_elpegr_lookup.delete;
6303     g_cache_elpegr_inst.delete;
6304     --
6305   end if;
6306   --
6307   -- Populate the global cache
6308   --
6309   if g_cache_elpegr_lookup.count = 0 then
6310     --
6311     -- Build the cache
6312     --
6313     ben_elp_cache.elpegr_writecache
6314       (p_effective_date => p_effective_date,
6315        p_refresh_cache  => p_refresh_cache);
6316     --
6317   end if;
6318   --
6319   -- Get the instance details
6320   --
6321   l_torrwnum := 0;
6322   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
6323   --
6324   -- Check if hashed value is already allocated
6325   --
6326   if g_cache_elpegr_lookup.exists(l_index) then
6327     --
6328     -- If it does exist make sure its the right one
6329     --
6330     if g_cache_elpegr_lookup(l_index).id <> p_eligy_prfl_id then
6331       --
6332       l_not_hash_found := false;
6333       --
6334       -- Loop until un-allocated has value is derived
6335       --
6336       while not l_not_hash_found loop
6337         --
6338         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
6339         --
6340         -- Check if the hash index exists, if not we can use it
6341         --
6342         if not g_cache_elpegr_lookup.exists(l_index) then
6343           --
6344           -- Lets store the hash value in the index
6345           --
6346           l_not_hash_found := true;
6347           exit;
6348           --
6349         else
6350           --
6351           l_not_hash_found := false;
6352           --
6353         end if;
6354         --
6355       end loop;
6356       --
6357     end if;
6358     --
6359   end if;
6360   --
6361   for l_insttorrw_num in g_cache_elpegr_lookup(l_index).starttorele_num ..
6362     g_cache_elpegr_lookup(l_index).endtorele_num loop
6363     --
6364     p_inst_set(l_torrwnum) := g_cache_elpegr_inst(l_insttorrw_num);
6365     l_torrwnum := l_torrwnum+1;
6366     --
6367   end loop;
6368   --
6369   p_inst_count := l_torrwnum;
6370   --
6371 exception
6372   --
6373   when no_data_found then
6374     --
6375     p_inst_count := 0;
6376     --
6377 end elpegr_getcacdets;
6378 --
6379 procedure elpegn_writecache
6380   (p_effective_date in date,
6381    p_refresh_cache  in boolean default FALSE) is
6382   --
6383   l_proc varchar2(72) :=  'elpegn_writecache';
6384   l_torrwnum pls_integer;
6385   l_prev_id number;
6386   l_id number;
6387   --
6388   cursor c_elpegn_look is
6389     select elp.eligy_prfl_id,
6390            elp.business_group_id
6391     from   ben_eligy_prfl_f elp
6392     where  p_effective_date
6393            between elp.effective_start_date
6394            and     elp.effective_end_date
6395     and    exists(select null
6396                   from   ben_elig_grd_prte_f egn
6397                   where  p_effective_date
6398                          between egn.effective_start_date
6399                          and     egn.effective_end_date
6400                   and    egn.eligy_prfl_id = elp.eligy_prfl_id)
6401     order  by elp.eligy_prfl_id;
6402   --
6403   cursor c_elpegn_inst is
6404     select egn.eligy_prfl_id,
6405            egn.elig_gndr_prte_id pk_id,
6406            'EGN' short_code,
6407            egn.sex,
6408            egn.excld_flag,
6409            egn.criteria_score,
6410            egn.criteria_weight
6411     from   ben_elig_gndr_prte_f egn
6412     where  p_effective_date
6413            between egn.effective_start_date
6414            and     egn.effective_end_date
6415     order  by egn.eligy_prfl_id,
6416            decode(egn.excld_flag,'Y',1,2),
6417            egn.ordr_num;
6418   --
6419   l_not_hash_found boolean;
6420   --
6421 begin
6422   --
6423   for objlook in c_elpegn_look loop
6424     --
6425     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
6426     --
6427     -- Check if hashed value is already allocated
6428     --
6429     if g_cache_elpegn_lookup.exists(l_id) then
6430       --
6431       l_not_hash_found := false;
6432       --
6433       -- Loop until un-allocated has value is derived
6434       --
6435       while not l_not_hash_found loop
6436         --
6437         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6438         --
6439         -- Check if the hash index exists, if not we can use it
6440         --
6441         if not g_cache_elpegn_lookup.exists(l_id) then
6442           --
6443           -- Lets store the hash value in the index
6444           --
6445           l_not_hash_found := true;
6446           exit;
6447           --
6448         else
6449           --
6450           l_not_hash_found := false;
6451           --
6452         end if;
6453         --
6454       end loop;
6455       --
6456     end if;
6457     --
6458     g_cache_elpegn_lookup(l_id).id := objlook.eligy_prfl_id;
6459     g_cache_elpegn_lookup(l_id).fk_id := objlook.business_group_id;
6460     --
6461   end loop;
6462   --
6463   l_torrwnum := 0;
6464   l_prev_id := -1;
6465   --
6466   for objinst in c_elpegn_inst loop
6467     --
6468     -- Populate the cache lookup details
6469     --
6470     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
6471     --
6472     -- Check if hashed value is already allocated
6473     --
6474     if g_cache_elpegn_lookup(l_id).id = objinst.eligy_prfl_id then
6475       --
6476       null;
6477       --
6478     else
6479       --
6480       loop
6481         --
6482         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6483         --
6484         if g_cache_elpegn_lookup(l_id).id = objinst.eligy_prfl_id then
6485           --
6486           exit;
6487           --
6488         end if;
6489         --
6490       end loop;
6491       --
6492     end if;
6493     --
6494     -- Check for first row
6495     --
6496     if l_prev_id = -1 then
6497       --
6498       g_cache_elpegn_lookup(l_id).starttorele_num := l_torrwnum;
6499       --
6500     elsif l_id <> l_prev_id then
6501       --
6502       g_cache_elpegn_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6503       g_cache_elpegn_lookup(l_id).starttorele_num := l_torrwnum;
6504       --
6505     end if;
6506     --
6507     -- Populate the cache instance details
6508     --
6509     g_cache_elpegn_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
6510     g_cache_elpegn_inst(l_torrwnum).pk_id := objinst.pk_id;
6511     g_cache_elpegn_inst(l_torrwnum).short_code := objinst.short_code;
6512     g_cache_elpegn_inst(l_torrwnum).criteria_score := objinst.criteria_score;
6513     g_cache_elpegn_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
6514     g_cache_elpegn_inst(l_torrwnum).sex := objinst.sex;
6515     g_cache_elpegn_inst(l_torrwnum).excld_flag := objinst.excld_flag;
6516     --
6517     l_torrwnum := l_torrwnum+1;
6518     l_prev_id := l_id;
6519     --
6520   end loop;
6521   --
6522   g_cache_elpegn_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6523   --
6524 end elpegn_writecache;
6525 --
6526 procedure elpegn_getcacdets
6527   (p_effective_date    in  date,
6528    p_business_group_id in  number,
6529    p_eligy_prfl_id     in  number,
6530    p_refresh_cache     in  boolean default FALSE,
6531    p_inst_set          out nocopy ben_elp_cache.g_cache_elpegn_instor,
6532    p_inst_count        out nocopy number) is
6533   --
6534   l_proc varchar2(72) :=  'elpegn_getcacdets';
6535   l_torrwnum pls_integer;
6536   l_insttorrw_num pls_integer;
6537   l_index         pls_integer;
6538   --
6539   l_not_hash_found boolean;
6540   --
6541 begin
6542   --
6543   -- Flush the cache
6544   --
6545   if p_refresh_cache then
6546     --
6547     g_cache_elpegn_lookup.delete;
6548     g_cache_elpegn_inst.delete;
6549     --
6550   end if;
6551   --
6552   -- Populate the global cache
6553   --
6554   if g_cache_elpegn_lookup.count = 0 then
6555     --
6556     -- Build the cache
6557     --
6558     ben_elp_cache.elpegn_writecache
6559       (p_effective_date => p_effective_date,
6560        p_refresh_cache  => p_refresh_cache);
6561     --
6562   end if;
6563   --
6564   -- Get the instance details
6565   --
6566   l_torrwnum := 0;
6567   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
6568   --
6569   -- Check if hashed value is already allocated
6570   --
6571   if g_cache_elpegn_lookup.exists(l_index) then
6572     --
6573     -- If it does exist make sure its the right one
6574     --
6575     if g_cache_elpegn_lookup(l_index).id <> p_eligy_prfl_id then
6576       --
6577       l_not_hash_found := false;
6578       --
6579       -- Loop until un-allocated has value is derived
6580       --
6581       while not l_not_hash_found loop
6582         --
6583         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
6584         --
6585         -- Check if the hash index exists, if not we can use it
6586         --
6587         if not g_cache_elpegn_lookup.exists(l_index) then
6588           --
6589           -- Lets store the hash value in the index
6590           --
6591           l_not_hash_found := true;
6592           exit;
6593           --
6594         else
6595           --
6596           l_not_hash_found := false;
6597           --
6598         end if;
6599         --
6600       end loop;
6601       --
6602     end if;
6603     --
6604   end if;
6605   --
6606   for l_insttorrw_num in g_cache_elpegn_lookup(l_index).starttorele_num ..
6607     g_cache_elpegn_lookup(l_index).endtorele_num loop
6608     --
6609     p_inst_set(l_torrwnum) := g_cache_elpegn_inst(l_insttorrw_num);
6610     l_torrwnum := l_torrwnum+1;
6611     --
6612   end loop;
6613   --
6614   p_inst_count := l_torrwnum;
6615   --
6616 exception
6617   --
6618   when no_data_found then
6619     --
6620     p_inst_count := 0;
6621     --
6622 end elpegn_getcacdets;
6623 --
6624 procedure elpejp_writecache
6625   (p_effective_date in date,
6626    p_refresh_cache  in boolean default FALSE) is
6627   --
6628   l_proc varchar2(72) :=  'elpejp_writecache';
6629   l_torrwnum pls_integer;
6630   l_prev_id number;
6631   l_id number;
6632   --
6633   cursor c_elpejp_look is
6634     select elp.eligy_prfl_id, elp.business_group_id
6635     from   ben_eligy_prfl_f elp
6636     where  p_effective_date
6637            between elp.effective_start_date
6638            and     elp.effective_end_date
6639     and    exists(select null
6640                   from   ben_elig_job_prte_f ejp
6641                   where  p_effective_date
6642                          between ejp.effective_start_date
6643                          and     ejp.effective_end_date
6644                   and ejp.eligy_prfl_id = elp.eligy_prfl_id)
6645     order  by elp.eligy_prfl_id;
6646   --
6647   cursor c_elpejp_inst is
6648     select ejp.eligy_prfl_id,
6649            ejp.elig_job_prte_id pk_id,
6650            'EJP' short_code,
6651            ejp.job_id,
6652            ejp.excld_flag,
6653            ejp.criteria_score,
6654            ejp.criteria_weight
6655     from   ben_elig_job_prte_f ejp
6656     where  p_effective_date
6657            between ejp.effective_start_date
6658            and ejp.effective_end_date
6659     order  by ejp.eligy_prfl_id,
6660            decode(ejp.excld_flag,'Y',1,2),
6661            ejp.ordr_num;
6662   --
6663   l_not_hash_found boolean;
6664   --
6665 begin
6666   --
6667   for objlook in c_elpejp_look loop
6668     --
6669     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
6670     --
6671     -- Check if hashed value is already allocated
6672     --
6673     if g_cache_elpejp_lookup.exists(l_id) then
6674       --
6675       l_not_hash_found := false;
6676       --
6677       -- Loop until un-allocated has value is derived
6678       --
6679       while not l_not_hash_found loop
6680         --
6681         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6682         --
6683         -- Check if the hash index exists, if not we can use it
6684         --
6685         if not g_cache_elpejp_lookup.exists(l_id) then
6686           --
6687           -- Lets store the hash value in the index
6688           --
6689           l_not_hash_found := true;
6690           exit;
6691           --
6692         else
6693           --
6694           l_not_hash_found := false;
6695           --
6696         end if;
6697       --
6698       end loop;
6699       --
6700     end if;
6701     --
6702     g_cache_elpejp_lookup(l_id).id := objlook.eligy_prfl_id;
6703     g_cache_elpejp_lookup(l_id).fk_id := objlook.business_group_id;
6704     --
6705   end loop;
6706   --
6707   l_torrwnum := 0;
6708   l_prev_id := -1;
6709   --
6710   for objinst in c_elpejp_inst loop
6711     --
6712     -- Populate the cache lookup details
6713     --
6714     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
6715     --
6716     -- Check if hashed value is already allocated
6717     --
6718     if g_cache_elpejp_lookup(l_id).id = objinst.eligy_prfl_id then
6719       --
6720       null;
6721       --
6722     else
6723       --
6724       loop
6725         --
6726         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6727         --
6728         if g_cache_elpejp_lookup(l_id).id = objinst.eligy_prfl_id then
6729           --
6730           exit;
6731           --
6732         end if;
6733         --
6734       end loop;
6735       --
6736     end if;
6737     --
6738     if l_prev_id = -1 then
6739       --
6740       g_cache_elpejp_lookup(l_id).starttorele_num := l_torrwnum;
6741       --
6742     elsif l_id <> l_prev_id then
6743       --
6744       g_cache_elpejp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6745       g_cache_elpejp_lookup(l_id).starttorele_num := l_torrwnum;
6746       --
6747     end if;
6748     --
6749     -- Populate the cache instance details
6750     --
6751     g_cache_elpejp_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
6752     g_cache_elpejp_inst(l_torrwnum).pk_id := objinst.pk_id;
6753     g_cache_elpejp_inst(l_torrwnum).short_code := objinst.short_code;
6754     g_cache_elpejp_inst(l_torrwnum).criteria_score := objinst.criteria_score;
6755     g_cache_elpejp_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
6756     g_cache_elpejp_inst(l_torrwnum).job_id := objinst.job_id;
6757     g_cache_elpejp_inst(l_torrwnum).excld_flag := objinst.excld_flag;
6758     --
6759     l_torrwnum := l_torrwnum+1;
6760     l_prev_id := l_id;
6761     --
6762   end loop;
6763   --
6764   g_cache_elpejp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6765   --
6766 end elpejp_writecache;
6767 --
6768 procedure elpejp_getcacdets
6769   (p_effective_date    in  date,
6770    p_business_group_id in  number,
6771    p_eligy_prfl_id     in  number,
6772    p_refresh_cache     in  boolean default FALSE,
6773    p_inst_set          out nocopy ben_elp_cache.g_cache_elpejp_instor,
6774    p_inst_count        out nocopy number) is
6775   --
6776   l_proc varchar2(72) :=  'elpejp_getcacdets';
6777   l_torrwnum pls_integer;
6778   l_insttorrw_num pls_integer;
6779   l_index         pls_integer;
6780   --
6781   l_not_hash_found boolean;
6782   --
6783 begin
6784   --
6785   -- Flush the cache
6786   --
6787   if p_refresh_cache then
6788     --
6789     g_cache_elpejp_lookup.delete;
6790     g_cache_elpejp_inst.delete;
6791     --
6792   end if;
6793   --
6794   -- Populate the global cache
6795   --
6796   if g_cache_elpejp_lookup.count = 0 then
6797     --
6798     -- Build the cache
6799     --
6800     ben_elp_cache.elpejp_writecache
6801       (p_effective_date => p_effective_date,
6802        p_refresh_cache  => p_refresh_cache);
6803     --
6804   end if;
6805   --
6806   -- Get the instance details
6807   --
6808   l_torrwnum := 0;
6809   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
6810   --
6811   -- Check if hashed value is already allocated
6812   --
6813   if g_cache_elpejp_lookup.exists(l_index) then
6814     --
6815     -- If it does exist make sure its the right one
6816     --
6817     if g_cache_elpejp_lookup(l_index).id <> p_eligy_prfl_id then
6818       --
6819       l_not_hash_found := false;
6820       --
6821       -- Loop until un-allocated has value is derived
6822       --
6823       while not l_not_hash_found loop
6824         --
6825         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
6826         --
6827         -- Check if the hash index exists, if not we can use it
6828         --
6829         if not g_cache_elpejp_lookup.exists(l_index) then
6830           --
6831           -- Lets store the hash value in the index
6832           --
6833           l_not_hash_found := true;
6834           exit;
6835           --
6836         else
6837           --
6838           l_not_hash_found := false;
6839           --
6840         end if;
6841         --
6842       end loop;
6843       --
6844     end if;
6845     --
6846   end if;
6847   --
6848   for l_insttorrw_num in g_cache_elpejp_lookup(l_index).starttorele_num ..
6849     g_cache_elpejp_lookup(l_index).endtorele_num loop
6850     --
6851     p_inst_set(l_torrwnum) := g_cache_elpejp_inst(l_insttorrw_num);
6852     l_torrwnum := l_torrwnum+1;
6853     --
6854   end loop;
6855   --
6856   p_inst_count := l_torrwnum;
6857   --
6858 exception
6859   --
6860   when no_data_found then
6861     --
6862     p_inst_count := 0;
6863     --
6864 end elpejp_getcacdets;
6865 --
6866 procedure elpepb_writecache
6867   (p_effective_date in date,
6868    p_refresh_cache  in boolean default FALSE) is
6869   --
6870   l_proc varchar2(72) :=  'elpepb_writecache';
6871   l_torrwnum pls_integer;
6872   l_prev_id number;
6873   l_id number;
6874   --
6875   cursor c_elpepb_look is
6876     select elp.eligy_prfl_id,
6877            elp.business_group_id
6878     from   ben_eligy_prfl_f elp
6879     where  p_effective_date
6880            between elp.effective_start_date
6881            and     elp.effective_end_date
6882     and    exists(select null
6883                   from   ben_elig_py_bss_prte_f epb
6884                   where  p_effective_date
6885                          between epb.effective_start_date
6886                          and     epb.effective_end_date
6887                   and    epb.eligy_prfl_id = elp.eligy_prfl_id)
6888     order  by elp.eligy_prfl_id;
6889   --
6890   cursor c_elpepb_inst is
6891     select epb.eligy_prfl_id,
6892            epb.elig_py_bss_prte_id pk_id,
6893            'EPB' short_code,
6894            epb.pay_basis_id,
6895            epb.excld_flag,
6896            epb.criteria_score,
6897            epb.criteria_weight
6898     from   ben_elig_py_bss_prte_f epb
6899     where  p_effective_date
6900            between epb.effective_start_date
6901            and     epb.effective_end_date
6902     order  by epb.eligy_prfl_id,
6903            decode(epb.excld_flag,'Y',1,2),
6904            epb.ordr_num;
6905   --
6906   l_not_hash_found boolean;
6907   --
6908 begin
6909   --
6910   for objlook in c_elpepb_look loop
6911     --
6912     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
6913     --
6914     -- Check if hashed value is already allocated
6915     --
6916     if g_cache_elpepb_lookup.exists(l_id) then
6917       --
6918       l_not_hash_found := false;
6919       --
6920       -- Loop until un-allocated has value is derived
6921       --
6922       while not l_not_hash_found loop
6923         --
6924         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6925         --
6926         -- Check if the hash index exists, if not we can use it
6927         --
6928         if not g_cache_elpepb_lookup.exists(l_id) then
6929           --
6930           -- Lets store the hash value in the index
6931           --
6932           l_not_hash_found := true;
6933           exit;
6934           --
6935         else
6936           --
6937           l_not_hash_found := false;
6938           --
6939         end if;
6940         --
6941       end loop;
6942       --
6943     end if;
6944     --
6945     g_cache_elpepb_lookup(l_id).id := objlook.eligy_prfl_id;
6946     g_cache_elpepb_lookup(l_id).fk_id := objlook.business_group_id;
6947     --
6948   end loop;
6949   --
6950   l_torrwnum := 0;
6951   l_prev_id := -1;
6952   --
6953   for objinst in c_elpepb_inst loop
6954     --
6955     -- Populate the cache lookup details
6956     --
6957     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
6958     --
6959     -- Check if hashed value is already allocated
6960     --
6961     if g_cache_elpepb_lookup(l_id).id = objinst.eligy_prfl_id then
6962       --
6963       null;
6964       --
6965     else
6966       --
6967       loop
6968         --
6969         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
6970         --
6971         if g_cache_elpepb_lookup(l_id).id = objinst.eligy_prfl_id then
6972           --
6973           exit;
6974           --
6975         end if;
6976         --
6977       end loop;
6978       --
6979     end if;
6980     --
6981     -- Check for first row
6982     --
6983     if l_prev_id = -1 then
6984       --
6985       g_cache_elpepb_lookup(l_id).starttorele_num := l_torrwnum;
6986       --
6987     elsif l_id <> l_prev_id then
6988       --
6989       g_cache_elpepb_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
6990       g_cache_elpepb_lookup(l_id).starttorele_num := l_torrwnum;
6991       --
6992     end if;
6993     --
6994     -- Populate the cache instance details
6995     --
6996     g_cache_elpepb_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
6997     g_cache_elpepb_inst(l_torrwnum).pk_id := objinst.pk_id;
6998     g_cache_elpepb_inst(l_torrwnum).short_code := objinst.short_code;
6999     g_cache_elpepb_inst(l_torrwnum).criteria_score := objinst.criteria_score;
7000     g_cache_elpepb_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
7001     g_cache_elpepb_inst(l_torrwnum).pay_basis_id := objinst.pay_basis_id;
7002     g_cache_elpepb_inst(l_torrwnum).excld_flag := objinst.excld_flag;
7003     --
7004     l_torrwnum := l_torrwnum+1;
7005     l_prev_id := l_id;
7006     --
7007   end loop;
7008   --
7009   g_cache_elpepb_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7010   --
7011 end elpepb_writecache;
7012 --
7013 procedure elpepb_getcacdets
7014   (p_effective_date    in  date,
7015    p_business_group_id in  number,
7016    p_eligy_prfl_id     in  number,
7017    p_refresh_cache     in  boolean default FALSE,
7018    p_inst_set          out nocopy ben_elp_cache.g_cache_elpepb_instor,
7019    p_inst_count        out nocopy number) is
7020   --
7021   l_proc varchar2(72) :=  'elpepb_getcacdets';
7022   l_torrwnum pls_integer;
7023   l_insttorrw_num pls_integer;
7024   l_index         pls_integer;
7025   --
7026   l_not_hash_found boolean;
7027   --
7028 begin
7029   --
7030   -- Flush the cache
7031   --
7032   if p_refresh_cache then
7033     --
7034     g_cache_elpepb_lookup.delete;
7035     g_cache_elpepb_inst.delete;
7036     --
7037   end if;
7038   --
7039   -- Populate the global cache
7040   --
7041   if g_cache_elpepb_lookup.count = 0 then
7042     --
7043     -- Build the cache
7044     --
7045     ben_elp_cache.elpepb_writecache
7046       (p_effective_date => p_effective_date,
7047        p_refresh_cache  => p_refresh_cache);
7048     --
7049   end if;
7050   --
7051   -- Get the instance details
7052   --
7053   l_torrwnum := 0;
7054   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
7055   --
7056   -- Check if hashed value is already allocated
7057   --
7058   if g_cache_elpepb_lookup.exists(l_index) then
7059     --
7060     -- If it does exist make sure its the right one
7061     --
7062     if g_cache_elpepb_lookup(l_index).id <> p_eligy_prfl_id then
7063       --
7064       l_not_hash_found := false;
7065       --
7066       -- Loop until un-allocated has value is derived
7067       --
7068       while not l_not_hash_found loop
7069         --
7070         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
7071         --
7072         -- Check if the hash index exists, if not we can use it
7073         --
7074         if not g_cache_elpepb_lookup.exists(l_index) then
7075           --
7076           -- Lets store the hash value in the index
7077           --
7078           l_not_hash_found := true;
7079           exit;
7080           --
7081         else
7082           --
7083           l_not_hash_found := false;
7084           --
7085         end if;
7086         --
7087       end loop;
7088       --
7089     end if;
7090     --
7091   end if;
7092   --
7093   for l_insttorrw_num in g_cache_elpepb_lookup(l_index).starttorele_num ..
7094     g_cache_elpepb_lookup(l_index).endtorele_num loop
7095     --
7096     p_inst_set(l_torrwnum) := g_cache_elpepb_inst(l_insttorrw_num);
7097     l_torrwnum := l_torrwnum+1;
7098     --
7099   end loop;
7100   --
7101   p_inst_count := l_torrwnum;
7102   --
7103 exception
7104   --
7105   when no_data_found then
7106     --
7107     p_inst_count := 0;
7108     --
7109 end elpepb_getcacdets;
7110 --
7111 procedure elpepy_writecache
7112   (p_effective_date in date,
7113    p_refresh_cache  in boolean default FALSE) is
7114   --
7115   l_proc varchar2(72) :=  'elpepy_writecache';
7116   l_torrwnum pls_integer;
7117   l_prev_id number;
7118   l_id number;
7119   --
7120   cursor c_elpepy_look is
7121     select elp.eligy_prfl_id, elp.business_group_id
7122     from   ben_eligy_prfl_f elp
7123     where  p_effective_date
7124            between elp.effective_start_date
7125            and elp.effective_end_date
7126     and    exists(select null
7127                   from   ben_elig_pyrl_prte_f epy
7128                   where  p_effective_date
7129                          between epy.effective_start_date
7130                          and     epy.effective_end_date
7131                   and    epy.eligy_prfl_id = elp.eligy_prfl_id)
7132     order  by elp.eligy_prfl_id;
7133   --
7134   cursor c_elpepy_inst is
7135     select epy.eligy_prfl_id,
7136            epy.elig_pyrl_prte_id pk_id,
7137            'EPY' short_code,
7138            epy.payroll_id,
7139            epy.excld_flag,
7140            epy.criteria_score,
7141            epy.criteria_weight
7142     from   ben_elig_pyrl_prte_f epy
7143     where  p_effective_date
7144            between epy.effective_start_date
7145            and     epy.effective_end_date
7146     order  by epy.eligy_prfl_id,
7147            decode(epy.excld_flag,'Y',1,2),
7148            epy.ordr_num;
7149   --
7150   l_not_hash_found boolean;
7151   --
7152 begin
7153   --
7154   for objlook in c_elpepy_look loop
7155     --
7156     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
7157     --
7158     -- Check if hashed value is already allocated
7159     --
7160     if g_cache_elpepy_lookup.exists(l_id) then
7161       --
7162       l_not_hash_found := false;
7163       --
7164       -- Loop until un-allocated has value is derived
7165       --
7166       while not l_not_hash_found loop
7167         --
7168         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7169         --
7170         -- Check if the hash index exists, if not we can use it
7171         --
7172         if not g_cache_elpepy_lookup.exists(l_id) then
7173           --
7174           -- Lets store the hash value in the index
7175           --
7176           l_not_hash_found := true;
7177           exit;
7178           --
7179         else
7180           --
7181           l_not_hash_found := false;
7182           --
7183         end if;
7184         --
7185       end loop;
7186       --
7187     end if;
7188     --
7189     g_cache_elpepy_lookup(l_id).id := objlook.eligy_prfl_id;
7190     g_cache_elpepy_lookup(l_id).fk_id := objlook.business_group_id;
7191     --
7192   end loop;
7193   --
7194   l_torrwnum := 0;
7195   l_prev_id := -1;
7196   --
7197   for objinst in c_elpepy_inst loop
7198     --
7199     -- Populate the cache lookup details
7200     --
7201     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
7202     --
7203     -- Check if hashed value is already allocated
7204     --
7205     if g_cache_elpepy_lookup(l_id).id = objinst.eligy_prfl_id then
7206       --
7207       null;
7208       --
7209     else
7210       --
7211       loop
7212         --
7213         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7214         --
7215         if g_cache_elpepy_lookup(l_id).id = objinst.eligy_prfl_id then
7216           --
7217           exit;
7218           --
7219         end if;
7220         --
7221       end loop;
7222       --
7223     end if;
7224     --
7225     -- Check for first row
7226     --
7227     if l_prev_id = -1 then
7228       --
7229       g_cache_elpepy_lookup(l_id).starttorele_num := l_torrwnum;
7230       --
7231     elsif l_id <> l_prev_id then
7232       --
7233       g_cache_elpepy_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7234       g_cache_elpepy_lookup(l_id).starttorele_num := l_torrwnum;
7235       --
7236     end if;
7237     --
7238     -- Populate the cache instance details
7239     --
7240     g_cache_elpepy_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
7241     g_cache_elpepy_inst(l_torrwnum).pk_id := objinst.pk_id;
7242     g_cache_elpepy_inst(l_torrwnum).short_code := objinst.short_code;
7243     g_cache_elpepy_inst(l_torrwnum).criteria_score := objinst.criteria_score;
7244     g_cache_elpepy_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
7245     g_cache_elpepy_inst(l_torrwnum).payroll_id := objinst.payroll_id;
7246     g_cache_elpepy_inst(l_torrwnum).excld_flag := objinst.excld_flag;
7247     --
7248     l_torrwnum := l_torrwnum+1;
7249     l_prev_id := l_id;
7250     --
7251   end loop;
7252   --
7253   g_cache_elpepy_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7254   --
7255 end elpepy_writecache;
7256 --
7257 procedure elpepy_getcacdets
7258   (p_effective_date    in  date,
7259    p_business_group_id in  number,
7260    p_eligy_prfl_id     in  number,
7261    p_refresh_cache     in  boolean default FALSE,
7262    p_inst_set          out nocopy ben_elp_cache.g_cache_elpepy_instor,
7263    p_inst_count        out nocopy number) is
7264   --
7265   l_proc varchar2(72) :=  'elpepy_getcacdets';
7266   l_torrwnum pls_integer;
7267   l_insttorrw_num pls_integer;
7268   l_index         pls_integer;
7269   --
7270   l_not_hash_found boolean;
7271   --
7272 begin
7273   --
7274   -- Flush the cache
7275   --
7276   if p_refresh_cache then
7277     --
7278     g_cache_elpepy_lookup.delete;
7279     g_cache_elpepy_inst.delete;
7280     --
7281   end if;
7282   --
7283   -- Populate the global cache
7284   --
7285   if g_cache_elpepy_lookup.count = 0 then
7286     --
7287     -- Build the cache
7288     --
7289     ben_elp_cache.elpepy_writecache
7290       (p_effective_date => p_effective_date,
7291        p_refresh_cache  => p_refresh_cache);
7292     --
7293   end if;
7294   --
7295   -- Get the instance details
7296   --
7297   l_torrwnum := 0;
7298   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
7299   --
7300   -- Check if hashed value is already allocated
7301   --
7302   if g_cache_elpepy_lookup.exists(l_index) then
7303     --
7304     -- If it does exist make sure its the right one
7305     --
7306     if g_cache_elpepy_lookup(l_index).id <> p_eligy_prfl_id then
7307       --
7308       l_not_hash_found := false;
7309       --
7310       -- Loop until un-allocated has value is derived
7311       --
7312       while not l_not_hash_found loop
7313         --
7314         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
7315         --
7316         -- Check if the hash index exists, if not we can use it
7317         --
7318         if not g_cache_elpepy_lookup.exists(l_index) then
7319           --
7320           -- Lets store the hash value in the index
7321           --
7322           l_not_hash_found := true;
7323           exit;
7324           --
7325         else
7326           --
7327           l_not_hash_found := false;
7328           --
7329         end if;
7330         --
7331       end loop;
7332       --
7333     end if;
7334     --
7335   end if;
7336   --
7337   for l_insttorrw_num in g_cache_elpepy_lookup(l_index).starttorele_num ..
7338     g_cache_elpepy_lookup(l_index).endtorele_num loop
7339     --
7340     p_inst_set(l_torrwnum) := g_cache_elpepy_inst(l_insttorrw_num);
7341     l_torrwnum := l_torrwnum+1;
7342     --
7343   end loop;
7344   --
7345   p_inst_count := l_torrwnum;
7346   --
7347 exception
7348   --
7349   when no_data_found then
7350     --
7351     p_inst_count := 0;
7352     --
7353 end elpepy_getcacdets;
7354 --
7355 procedure elpebu_writecache
7356   (p_effective_date in date,
7357    p_refresh_cache  in boolean default false) is
7358   --
7359   l_proc varchar2(72) :=  'elpebu_writecache';
7360   l_torrwnum pls_integer;
7361   l_prev_id number;
7362   l_id number;
7363   --
7364   cursor c_elpebu_look is
7365     select elp.eligy_prfl_id,
7366            elp.business_group_id
7367     from   ben_eligy_prfl_f elp
7368     where  p_effective_date
7369            between elp.effective_start_date
7370            and     elp.effective_end_date
7371     and    exists(select null
7372                   from   ben_elig_brgng_unit_prte_f ebu
7373                   where  p_effective_date
7374                          between ebu.effective_start_date
7375                          and     ebu.effective_end_date
7376                   and    ebu.eligy_prfl_id = elp.eligy_prfl_id)
7377     order  by elp.eligy_prfl_id;
7378   --
7379   cursor c_elpebu_inst is
7380     select ebu.eligy_prfl_id,
7381            ebu.elig_brgng_unit_prte_id pk_id,
7382            'EBU' short_code,
7383            ebu.brgng_unit_cd,
7384            ebu.excld_flag,
7385            ebu.criteria_score,
7386            ebu.criteria_weight
7387     from   ben_elig_brgng_unit_prte_f ebu
7388     where  p_effective_date
7389            between ebu.effective_start_date
7390            and     ebu.effective_end_date
7391     order  by ebu.eligy_prfl_id,
7392            decode(ebu.excld_flag,'Y',1,2),
7393            ebu.ordr_num;
7394   --
7395   l_not_hash_found boolean;
7396   --
7397 begin
7398   --
7399   for objlook in c_elpebu_look loop
7400     --
7401     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
7402     --
7403     -- Check if hashed value is already allocated
7404     --
7405     if g_cache_elpebu_lookup.exists(l_id) then
7406       --
7407       l_not_hash_found := false;
7408       --
7409       -- Loop until un-allocated has value is derived
7410       --
7411       while not l_not_hash_found loop
7412         --
7413         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7414         --
7415         -- Check if the hash index exists, if not we can use it
7416         --
7417         if not g_cache_elpebu_lookup.exists(l_id) then
7418           --
7419           -- Lets store the hash value in the index
7420           --
7421           l_not_hash_found := true;
7422           exit;
7423           --
7424         else
7425           --
7426           l_not_hash_found := false;
7427           --
7428         end if;
7429         --
7430       end loop;
7431       --
7432     end if;
7433     --
7434     g_cache_elpebu_lookup(l_id).id := objlook.eligy_prfl_id;
7435     g_cache_elpebu_lookup(l_id).fk_id := objlook.business_group_id;
7436     --
7437   end loop;
7438   --
7439   l_torrwnum := 0;
7440   l_prev_id := -1;
7441   --
7442   for objinst in c_elpebu_inst loop
7443     --
7444     -- Populate the cache lookup details
7445     --
7446     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
7447     --
7448     -- Check if hashed value is already allocated
7449     --
7450     if g_cache_elpebu_lookup(l_id).id = objinst.eligy_prfl_id then
7451       --
7452       null;
7453       --
7454     else
7455       --
7456       loop
7457         --
7458         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7459         --
7460         if g_cache_elpebu_lookup(l_id).id = objinst.eligy_prfl_id then
7461           --
7462           exit;
7463           --
7464         end if;
7465         --
7466       end loop;
7467       --
7468     end if;
7469     --
7470     -- Check for first row
7471     --
7472     if l_prev_id = -1 then
7473       --
7474       g_cache_elpebu_lookup(l_id).starttorele_num := l_torrwnum;
7475       --
7476     elsif l_id <> l_prev_id then
7477       --
7478       g_cache_elpebu_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7479       g_cache_elpebu_lookup(l_id).starttorele_num := l_torrwnum;
7480       --
7481     end if;
7482     --
7483     -- Populate the cache instance details
7484     --
7485     g_cache_elpebu_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
7486     g_cache_elpebu_inst(l_torrwnum).pk_id := objinst.pk_id;
7487     g_cache_elpebu_inst(l_torrwnum).short_code := objinst.short_code;
7488     g_cache_elpebu_inst(l_torrwnum).criteria_score := objinst.criteria_score;
7489     g_cache_elpebu_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
7490     g_cache_elpebu_inst(l_torrwnum).brgng_unit_cd := objinst.brgng_unit_cd;
7491     g_cache_elpebu_inst(l_torrwnum).excld_flag := objinst.excld_flag;
7492     --
7493     l_torrwnum := l_torrwnum+1;
7494     l_prev_id := l_id;
7495     --
7496   end loop;
7497   --
7498   g_cache_elpebu_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7499   --
7500 end elpebu_writecache;
7501 --
7502 procedure elpebu_getcacdets
7503   (p_effective_date    in  date,
7504    p_business_group_id in  number,
7505    p_eligy_prfl_id     in  number,
7506    p_refresh_cache     in  boolean default FALSE,
7507    p_inst_set          out nocopy ben_elp_cache.g_cache_elpebu_instor,
7508    p_inst_count        out nocopy number) is
7509   --
7510   l_proc varchar2(72) :=  'elpebu_getcacdets';
7511   l_torrwnum pls_integer;
7512   l_insttorrw_num pls_integer;
7513   l_index         pls_integer;
7514   --
7515   l_not_hash_found boolean;
7516   --
7517 begin
7518   --
7519   -- Flush the cache
7520   --
7521   if p_refresh_cache then
7522     --
7523     g_cache_elpebu_lookup.delete;
7524     g_cache_elpebu_inst.delete;
7525     --
7526   end if;
7527   --
7528   -- Populate the global cache
7529   --
7530   if g_cache_elpebu_lookup.count = 0 then
7531     --
7532     -- Build the cache
7533     --
7534     ben_elp_cache.elpebu_writecache
7535       (p_effective_date => p_effective_date,
7536        p_refresh_cache  => p_refresh_cache);
7537     --
7538   end if;
7539   --
7540   -- Get the instance details
7541   --
7542   l_torrwnum := 0;
7543   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
7544   --
7545   -- Check if hashed value is already allocated
7546   --
7547   if g_cache_elpebu_lookup.exists(l_index) then
7548     --
7549     -- If it does exist make sure its the right one
7550     --
7551     if g_cache_elpebu_lookup(l_index).id <> p_eligy_prfl_id then
7552       --
7553       l_not_hash_found := false;
7554       --
7555       -- Loop until un-allocated has value is derived
7556       --
7557       while not l_not_hash_found loop
7558         --
7559         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
7560         --
7561         -- Check if the hash index exists, if not we can use it
7562         --
7563         if not g_cache_elpebu_lookup.exists(l_index) then
7564           --
7565           -- Lets store the hash value in the index
7566           --
7567           l_not_hash_found := true;
7568           exit;
7569           --
7570         else
7571           --
7572           l_not_hash_found := false;
7573           --
7574         end if;
7575         --
7576       end loop;
7577       --
7578     end if;
7579     --
7580   end if;
7581   --
7582   for l_insttorrw_num in g_cache_elpebu_lookup(l_index).starttorele_num ..
7583     g_cache_elpebu_lookup(l_index).endtorele_num loop
7584     --
7585     p_inst_set(l_torrwnum) := g_cache_elpebu_inst(l_insttorrw_num);
7586     l_torrwnum := l_torrwnum+1;
7587     --
7588   end loop;
7589   --
7590   p_inst_count := l_torrwnum;
7591   --
7592 exception
7593   --
7594   when no_data_found then
7595     --
7596     p_inst_count := 0;
7597     --
7598 end elpebu_getcacdets;
7599 --
7600 procedure elpelu_writecache
7601   (p_effective_date in date,
7602    p_refresh_cache  in boolean default FALSE) is
7603   --
7604   l_proc varchar2(72) :=  'elpelu_writecache';
7605   l_torrwnum pls_integer;
7606   l_prev_id number;
7607   l_id number;
7608   --
7609   cursor c_elpelu_look is
7610     select elp.eligy_prfl_id,
7611            elp.business_group_id
7612     from   ben_eligy_prfl_f elp
7613     where  p_effective_date
7614            between elp.effective_start_date
7615            and     elp.effective_end_date
7616     and    exists(select null
7617                   from   ben_elig_lbr_mmbr_prte_f elu
7618                   where  p_effective_date
7619                          between elu.effective_start_date
7620                          and     elu.effective_end_date
7621                   and    elu.eligy_prfl_id = elp.eligy_prfl_id)
7622     order  by elp.eligy_prfl_id;
7623   --
7624   cursor c_elpelu_inst is
7625     select elu.eligy_prfl_id,
7626            elu.elig_lbr_mmbr_prte_id pk_id,
7627            'ELU' short_code,
7628            elu.lbr_mmbr_flag,
7629            elu.excld_flag,
7630            elu.criteria_score,
7631            elu.criteria_weight
7632     from   ben_elig_lbr_mmbr_prte_f elu
7633     where  p_effective_date
7634            between elu.effective_start_date
7635            and elu.effective_end_date
7636     order  by elu.eligy_prfl_id,
7637            decode(elu.excld_flag,'Y',1,2),
7638            elu.ordr_num;
7639   --
7640   l_not_hash_found boolean;
7641   --
7642 begin
7643   --
7644   for objlook in c_elpelu_look loop
7645     --
7646     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
7647     --
7648     -- Check if hashed value is already allocated
7649     --
7650     if g_cache_elpelu_lookup.exists(l_id) then
7651       --
7652       l_not_hash_found := false;
7653       --
7654       -- Loop until un-allocated has value is derived
7655       --
7656       while not l_not_hash_found loop
7657         --
7658         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7659         --
7660         -- Check if the hash index exists, if not we can use it
7661         --
7662         if not g_cache_elpelu_lookup.exists(l_id) then
7663           --
7664           -- Lets store the hash value in the index
7665           --
7666           l_not_hash_found := true;
7667           exit;
7668           --
7669         else
7670           --
7671           l_not_hash_found := false;
7672           --
7673         end if;
7674       --
7675       end loop;
7676       --
7677     end if;
7678     --
7679     g_cache_elpelu_lookup(l_id).id := objlook.eligy_prfl_id;
7680     g_cache_elpelu_lookup(l_id).fk_id := objlook.business_group_id;
7681     --
7682   end loop;
7683   --
7684   l_torrwnum := 0;
7685   l_prev_id := -1;
7686   --
7687   for objinst in c_elpelu_inst loop
7688     --
7689     -- Populate the cache lookup details
7690     --
7691     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
7692     --
7693     -- Check if hashed value is already allocated
7694     --
7695     if g_cache_elpelu_lookup(l_id).id = objinst.eligy_prfl_id then
7696       --
7697       null;
7698       --
7699     else
7700       --
7701       loop
7702         --
7703         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7704         --
7705         if g_cache_elpelu_lookup(l_id).id = objinst.eligy_prfl_id then
7706           --
7707           exit;
7708           --
7709         end if;
7710         --
7711       end loop;
7712       --
7713     end if;
7714     --
7715     -- Check for first row
7716     --
7717     if l_prev_id = -1 then
7718       --
7719       g_cache_elpelu_lookup(l_id).starttorele_num := l_torrwnum;
7720       --
7721     elsif l_id <> l_prev_id then
7722       --
7723       g_cache_elpelu_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7724       g_cache_elpelu_lookup(l_id).starttorele_num := l_torrwnum;
7725       --
7726     end if;
7727     --
7728     -- Populate the cache instance details
7729     --
7730     g_cache_elpelu_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
7731     g_cache_elpelu_inst(l_torrwnum).pk_id := objinst.pk_id;
7732     g_cache_elpelu_inst(l_torrwnum).short_code := objinst.short_code;
7733     g_cache_elpelu_inst(l_torrwnum).criteria_score := objinst.criteria_score;
7734     g_cache_elpelu_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
7735     g_cache_elpelu_inst(l_torrwnum).lbr_mmbr_flag := objinst.lbr_mmbr_flag;
7736     g_cache_elpelu_inst(l_torrwnum).excld_flag := objinst.excld_flag;
7737     --
7738     l_torrwnum := l_torrwnum+1;
7739     l_prev_id := l_id;
7740     --
7741   end loop;
7742   --
7743   g_cache_elpelu_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7744   --
7745 end elpelu_writecache;
7746 --
7747 procedure elpelu_getcacdets
7748   (p_effective_date    in date,
7749    p_business_group_id in number,
7750    p_eligy_prfl_id     in number,
7751    p_refresh_cache     in boolean default FALSE,
7752    p_inst_set          out nocopy ben_elp_cache.g_cache_elpelu_instor,
7753    p_inst_count        out nocopy number) is
7754   --
7755   l_proc varchar2(72) :=  'elpelu_getcacdets';
7756   l_torrwnum pls_integer;
7757   l_insttorrw_num pls_integer;
7758   l_index         pls_integer;
7759   --
7760   l_not_hash_found boolean;
7761   --
7762 begin
7763   --
7764   -- Flush the cache
7765   --
7766   if p_refresh_cache then
7767     --
7768     g_cache_elpelu_lookup.delete;
7769     g_cache_elpelu_inst.delete;
7770     --
7771   end if;
7772   --
7773   -- Populate the global cache
7774   --
7775   if g_cache_elpelu_lookup.count = 0 then
7776     --
7777     -- Build the cache
7778     --
7779     ben_elp_cache.elpelu_writecache
7780       (p_effective_date => p_effective_date,
7781        p_refresh_cache  => p_refresh_cache);
7782     --
7783   end if;
7784   --
7785   -- Get the instance details
7786   --
7787   l_torrwnum := 0;
7788   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
7789   --
7790   -- Check if hashed value is already allocated
7791   --
7792   if g_cache_elpelu_lookup.exists(l_index) then
7793     --
7794     -- If it does exist make sure its the right one
7795     --
7796     if g_cache_elpelu_lookup(l_index).id <> p_eligy_prfl_id then
7797       --
7798       l_not_hash_found := false;
7799       --
7800       -- Loop until un-allocated has value is derived
7801       --
7802       while not l_not_hash_found loop
7803         --
7804         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
7805         --
7806         -- Check if the hash index exists, if not we can use it
7807         --
7808         if not g_cache_elpelu_lookup.exists(l_index) then
7809           --
7810           -- Lets store the hash value in the index
7811           --
7812           l_not_hash_found := true;
7813           exit;
7814           --
7815         else
7816           --
7817           l_not_hash_found := false;
7818           --
7819         end if;
7820         --
7821       end loop;
7822       --
7823     end if;
7824     --
7825   end if;
7826   --
7827   for l_insttorrw_num in g_cache_elpelu_lookup(l_index).starttorele_num ..
7828     g_cache_elpelu_lookup(l_index).endtorele_num loop
7829     --
7830     p_inst_set(l_torrwnum) := g_cache_elpelu_inst(l_insttorrw_num);
7831     l_torrwnum := l_torrwnum+1;
7832     --
7833   end loop;
7834   --
7835   p_inst_count := l_torrwnum;
7836   --
7837 exception
7838   --
7839   when no_data_found then
7840     --
7841     p_inst_count := 0;
7842     --
7843 end elpelu_getcacdets;
7844 --
7845 procedure elpelr_writecache
7846   (p_effective_date in date,
7847    p_refresh_cache  in boolean default FALSE) is
7848   --
7849   l_proc varchar2(72) :=  'elpelr_writecache';
7850   l_torrwnum pls_integer;
7851   l_prev_id number;
7852   l_id number;
7853   --
7854   cursor c_elpelr_look is
7855     select elp.eligy_prfl_id,
7856            elp.business_group_id
7857     from   ben_eligy_prfl_f elp
7858     where  p_effective_date
7859            between elp.effective_start_date
7860            and     elp.effective_end_date
7861     and    exists(select null
7862                   from   ben_elig_loa_rsn_prte_f elr
7863                   where  p_effective_date
7864                          between elr.effective_start_date
7865                          and     elr.effective_end_date
7866                   and elr.eligy_prfl_id = elp.eligy_prfl_id)
7867     order by elp.eligy_prfl_id;
7868   --
7869   cursor c_elpelr_inst is
7870     select elr.eligy_prfl_id,
7871            elr.elig_loa_rsn_prte_id pk_id,
7872            'ELR' short_code,
7873            elr.absence_attendance_type_id,
7874            elr.abs_attendance_reason_id,
7875            elr.excld_flag,
7876            elr.criteria_score,
7877            elr.criteria_weight
7878     from   ben_elig_loa_rsn_prte_f elr
7879     where  p_effective_date
7880            between elr.effective_start_date
7881            and     elr.effective_end_date
7882     order  by elr.eligy_prfl_id,
7883            decode(elr.excld_flag,'Y',1,2),
7884            elr.ordr_num;
7885   --
7886   l_not_hash_found boolean;
7887   --
7888 begin
7889   --
7890   for objlook in c_elpelr_look loop
7891     --
7892     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
7893     --
7894     -- Check if hashed value is already allocated
7895     --
7896     if g_cache_elpelr_lookup.exists(l_id) then
7897       --
7898       l_not_hash_found := false;
7899       --
7900       -- Loop until un-allocated has value is derived
7901       --
7902       while not l_not_hash_found loop
7903         --
7904         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7905         --
7906         -- Check if the hash index exists, if not we can use it
7907         --
7908         if not g_cache_elpelr_lookup.exists(l_id) then
7909           --
7910           -- Lets store the hash value in the index
7911           --
7912           l_not_hash_found := true;
7913           exit;
7914           --
7915         else
7916           --
7917           l_not_hash_found := false;
7918           --
7919         end if;
7920         --
7921       end loop;
7922       --
7923     end if;
7924     --
7925     g_cache_elpelr_lookup(l_id).id := objlook.eligy_prfl_id;
7926     g_cache_elpelr_lookup(l_id).fk_id := objlook.business_group_id;
7927     --
7928   end loop;
7929   --
7930   l_torrwnum := 0;
7931   l_prev_id := -1;
7932   --
7933   for objinst in c_elpelr_inst loop
7934     --
7935     -- Populate the cache lookup details
7936     --
7937     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
7938     --
7939     -- Check if hashed value is already allocated
7940     --
7941     if g_cache_elpelr_lookup(l_id).id = objinst.eligy_prfl_id then
7942       --
7943       null;
7944       --
7945     else
7946       --
7947       loop
7948         --
7949         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
7950         --
7951         if g_cache_elpelr_lookup(l_id).id = objinst.eligy_prfl_id then
7952           --
7953           exit;
7954           --
7955         end if;
7956         --
7957       end loop;
7958       --
7959     end if;
7960     --
7961     -- Check for first row
7962     --
7963     if l_prev_id = -1 then
7964       --
7965       g_cache_elpelr_lookup(l_id).starttorele_num := l_torrwnum;
7966       --
7967     elsif l_id <> l_prev_id then
7968       --
7969       g_cache_elpelr_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7970       g_cache_elpelr_lookup(l_id).starttorele_num := l_torrwnum;
7971       --
7972     end if;
7973     --
7974     -- Populate the cache instance details
7975     --
7976     g_cache_elpelr_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
7977     g_cache_elpelr_inst(l_torrwnum).pk_id := objinst.pk_id;
7978     g_cache_elpelr_inst(l_torrwnum).short_code := objinst.short_code;
7979     g_cache_elpelr_inst(l_torrwnum).criteria_score := objinst.criteria_score;
7980     g_cache_elpelr_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
7981     g_cache_elpelr_inst(l_torrwnum).absence_attendance_type_id := objinst.absence_attendance_type_id;
7982     g_cache_elpelr_inst(l_torrwnum).abs_attendance_reason_id := objinst.abs_attendance_reason_id;
7983     g_cache_elpelr_inst(l_torrwnum).excld_flag := objinst.excld_flag;
7984     --
7985     l_torrwnum := l_torrwnum+1;
7986     l_prev_id := l_id;
7987     --
7988   end loop;
7989   --
7990   g_cache_elpelr_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
7991   --
7992 end elpelr_writecache;
7993 --
7994 procedure elpelr_getcacdets
7995   (p_effective_date    in date,
7996    p_business_group_id in number,
7997    p_eligy_prfl_id     in number,
7998    p_refresh_cache     in boolean default FALSE,
7999    p_inst_set          out nocopy ben_elp_cache.g_cache_elpelr_instor,
8000    p_inst_count        out nocopy number) is
8001   --
8002   l_proc varchar2(72) :=  'elpelr_getcacdets';
8003   l_torrwnum pls_integer;
8004   l_insttorrw_num pls_integer;
8005   l_index         pls_integer;
8006   --
8007   l_not_hash_found boolean;
8008   --
8009 begin
8010   --
8011   -- Flush the cache
8012   --
8013   if p_refresh_cache then
8014     --
8015     g_cache_elpelr_lookup.delete;
8016     g_cache_elpelr_inst.delete;
8017     --
8018   end if;
8019   --
8020   -- Populate the global cache
8021   --
8022   if g_cache_elpelr_lookup.count = 0 then
8023     --
8024     -- Build the cache
8025     --
8026     ben_elp_cache.elpelr_writecache
8027       (p_effective_date => p_effective_date,
8028        p_refresh_cache  => p_refresh_cache);
8029     --
8030   end if;
8031   --
8032   -- Get the instance details
8033   --
8034   l_torrwnum := 0;
8035   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
8036   --
8037   -- Check if hashed value is already allocated
8038   --
8039   if g_cache_elpelr_lookup.exists(l_index) then
8040     --
8041     -- If it does exist make sure its the right one
8042     --
8043     if g_cache_elpelr_lookup(l_index).id <> p_eligy_prfl_id then
8044       --
8045       l_not_hash_found := false;
8046       --
8047       -- Loop until un-allocated has value is derived
8048       --
8049       while not l_not_hash_found loop
8050         --
8051         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
8052         --
8053         -- Check if the hash index exists, if not we can use it
8054         --
8055         if not g_cache_elpelr_lookup.exists(l_index) then
8056           --
8057           -- Lets store the hash value in the index
8058           --
8059           l_not_hash_found := true;
8060           exit;
8061           --
8062         else
8063           --
8064           l_not_hash_found := false;
8065           --
8066         end if;
8067         --
8068       end loop;
8069       --
8070     end if;
8071     --
8072   end if;
8073   --
8074   for l_insttorrw_num in g_cache_elpelr_lookup(l_index).starttorele_num ..
8075     g_cache_elpelr_lookup(l_index).endtorele_num loop
8076     --
8077     p_inst_set(l_torrwnum) := g_cache_elpelr_inst(l_insttorrw_num);
8078     l_torrwnum := l_torrwnum+1;
8079     --
8080   end loop;
8081   --
8082   p_inst_count := l_torrwnum;
8083   --
8084 exception
8085   --
8086   when no_data_found then
8087     --
8088     p_inst_count := 0;
8089     --
8090 end elpelr_getcacdets;
8091 --
8092 procedure elpeap_writecache
8093   (p_effective_date in date,
8094    p_refresh_cache  in boolean default FALSE) is
8095   --
8096   l_proc varchar2(72) :=  'elpeap_writecache';
8097   l_torrwnum pls_integer;
8098   l_prev_id number;
8099   l_id number;
8100   --
8101   cursor c_elpeap_look is
8102     select elp.eligy_prfl_id, elp.business_group_id
8103     from   ben_eligy_prfl_f elp
8104     where  p_effective_date
8105            between elp.effective_start_date
8106            and elp.effective_end_date
8107     and    exists(select null
8108                   from   ben_elig_age_prte_f eap,
8109                          ben_age_fctr agf
8110                   where  eap.age_fctr_id = agf.age_fctr_id
8111                   and    eap.business_group_id = agf.business_group_id
8112                   and    p_effective_date
8113                          between eap.effective_start_date
8114                          and     eap.effective_end_date
8115                   and eap.eligy_prfl_id = elp.eligy_prfl_id)
8116     order  by elp.eligy_prfl_id;
8117   --
8118   cursor c_elpeap_inst is
8119     select eap.eligy_prfl_id,
8120            eap.elig_age_prte_id pk_id,
8121            'EAP' short_code,
8122            eap.age_fctr_id,
8123            eap.excld_flag,
8124            eap.criteria_score,
8125            eap.criteria_weight,
8126            agf.mx_age_num,
8127            agf.mn_age_num,
8128            agf.no_mn_age_flag,
8129            agf.no_mx_age_flag
8130     from   ben_elig_age_prte_f eap,
8131            ben_age_fctr agf
8132     where  eap.age_fctr_id = agf.age_fctr_id
8133     and    eap.business_group_id = agf.business_group_id
8134     and    p_effective_date
8135            between eap.effective_start_date
8136            and     eap.effective_end_date
8137     order  by eap.eligy_prfl_id,
8138            decode(eap.excld_flag,'Y',1,2),
8139            eap.ordr_num;
8140   --
8141   l_not_hash_found boolean;
8142   --
8143 begin
8144   --
8145   for objlook in c_elpeap_look loop
8146     --
8147     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
8148     --
8149     -- Check if hashed value is already allocated
8150     --
8151     if g_cache_elpeap_lookup.exists(l_id) then
8152       --
8153       l_not_hash_found := false;
8154       --
8155       -- Loop until un-allocated has value is derived
8156       --
8157       while not l_not_hash_found loop
8158         --
8159         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8160         --
8161         -- Check if the hash index exists, if not we can use it
8162         --
8163         if not g_cache_elpeap_lookup.exists(l_id) then
8164           --
8165           -- Lets store the hash value in the index
8166           --
8167           l_not_hash_found := true;
8168           exit;
8169           --
8170         else
8171           --
8172           l_not_hash_found := false;
8173           --
8174         end if;
8175         --
8176       end loop;
8177       --
8178     end if;
8179     --
8180     g_cache_elpeap_lookup(l_id).id := objlook.eligy_prfl_id;
8181     g_cache_elpeap_lookup(l_id).fk_id := objlook.business_group_id;
8182     --
8183   end loop;
8184   --
8185   l_torrwnum := 0;
8186   l_prev_id := -1;
8187   --
8188   for objinst in c_elpeap_inst loop
8189     --
8190     -- Populate the cache lookup details
8191     --
8192     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
8193     --
8194     -- Check if hashed value is already allocated
8195     --
8196     if g_cache_elpeap_lookup(l_id).id = objinst.eligy_prfl_id then
8197       --
8198       null;
8199       --
8200     else
8201       --
8202       loop
8203         --
8204         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8205         --
8206         if g_cache_elpeap_lookup(l_id).id = objinst.eligy_prfl_id then
8207           --
8208           exit;
8209           --
8210         end if;
8211         --
8212       end loop;
8213       --
8214     end if;
8215     --
8216     -- Check for first row
8217     --
8218     if l_prev_id = -1 then
8219       --
8220       g_cache_elpeap_lookup(l_id).starttorele_num := l_torrwnum;
8221       --
8222     elsif l_id <> l_prev_id then
8223       --
8224       g_cache_elpeap_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8225       g_cache_elpeap_lookup(l_id).starttorele_num := l_torrwnum;
8226       --
8227     end if;
8228     --
8229     -- Populate the cache instance details
8230     --
8231     g_cache_elpeap_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
8232     g_cache_elpeap_inst(l_torrwnum).pk_id := objinst.pk_id;
8233     g_cache_elpeap_inst(l_torrwnum).short_code := objinst.short_code;
8234     g_cache_elpeap_inst(l_torrwnum).criteria_score := objinst.criteria_score;
8235     g_cache_elpeap_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
8236     g_cache_elpeap_inst(l_torrwnum).age_fctr_id := objinst.age_fctr_id;
8237     g_cache_elpeap_inst(l_torrwnum).excld_flag := objinst.excld_flag;
8238     g_cache_elpeap_inst(l_torrwnum).mx_age_num := objinst.mx_age_num;
8239     g_cache_elpeap_inst(l_torrwnum).mn_age_num := objinst.mn_age_num;
8240     g_cache_elpeap_inst(l_torrwnum).no_mn_age_flag := objinst.no_mn_age_flag;
8241     g_cache_elpeap_inst(l_torrwnum).no_mx_age_flag := objinst.no_mx_age_flag;
8242     --
8243     l_torrwnum := l_torrwnum+1;
8244     l_prev_id := l_id;
8245     --
8246   end loop;
8247   --
8248   g_cache_elpeap_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8249   --
8250 end elpeap_writecache;
8251 --
8252 procedure elpeap_getcacdets
8253   (p_effective_date    in date,
8254    p_business_group_id in number,
8255    p_eligy_prfl_id     in number,
8256    p_refresh_cache     in boolean default FALSE,
8257    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeap_instor,
8258    p_inst_count        out nocopy number) is
8259   --
8260   l_proc varchar2(72) :=  'elpeap_getcacdets';
8261   l_torrwnum pls_integer;
8262   l_insttorrw_num pls_integer;
8263   l_index         pls_integer;
8264   --
8265   l_not_hash_found boolean;
8266   --
8267 begin
8268   --
8269   -- Flush the cache
8270   --
8271   if p_refresh_cache then
8272     --
8273     g_cache_elpeap_lookup.delete;
8274     g_cache_elpeap_inst.delete;
8275     --
8276   end if;
8277   --
8278   -- Populate the global cache
8279   --
8280   if g_cache_elpeap_lookup.count = 0 then
8281     --
8282     -- Build the cache
8283     --
8284     ben_elp_cache.elpeap_writecache
8285       (p_effective_date => p_effective_date,
8286        p_refresh_cache  => p_refresh_cache);
8287     --
8288   end if;
8289   --
8290   -- Get the instance details
8291   --
8292   l_torrwnum := 0;
8293   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
8294   --
8295   -- Check if hashed value is already allocated
8296   --
8297   if g_cache_elpeap_lookup.exists(l_index) then
8298     --
8299     -- If it does exist make sure its the right one
8300     --
8301     if g_cache_elpeap_lookup(l_index).id <> p_eligy_prfl_id then
8302       --
8303       l_not_hash_found := false;
8304       --
8305       -- Loop until un-allocated has value is derived
8306       --
8307       while not l_not_hash_found loop
8308         --
8309         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
8310         --
8311         -- Check if the hash index exists, if not we can use it
8312         --
8313         if not g_cache_elpeap_lookup.exists(l_index) then
8314           --
8315           -- Lets store the hash value in the index
8316           --
8317           l_not_hash_found := true;
8318           exit;
8319           --
8320         else
8321           --
8322           l_not_hash_found := false;
8323           --
8324         end if;
8325         --
8326       end loop;
8327       --
8328     end if;
8329     --
8330   end if;
8331   --
8332   for l_insttorrw_num in g_cache_elpeap_lookup(l_index).starttorele_num ..
8333     g_cache_elpeap_lookup(l_index).endtorele_num loop
8334     --
8335     p_inst_set(l_torrwnum) := g_cache_elpeap_inst(l_insttorrw_num);
8336     l_torrwnum := l_torrwnum+1;
8337     --
8338   end loop;
8339   --
8340   p_inst_count := l_torrwnum;
8341   --
8342 exception
8343   --
8344   when no_data_found then
8345     --
8346     p_inst_count := 0;
8347     --
8348 end elpeap_getcacdets;
8349 --
8350 procedure elpepz_writecache
8351   (p_effective_date in date,
8352    p_refresh_cache in boolean default FALSE) is
8353   --
8354   l_proc varchar2(72) :=  'elpepz_writecache';
8355   l_torrwnum pls_integer;
8356   l_prev_id number;
8357   l_id number;
8358   --
8359   cursor c_elpepz_look is
8360     select elp.eligy_prfl_id,
8361            elp.business_group_id
8362     from   ben_eligy_prfl_f elp
8363     where  p_effective_date
8364            between elp.effective_start_date
8365            and elp.effective_end_date
8366     and    exists(select null
8367                   from   ben_elig_pstl_cd_r_rng_prte_f epz,
8368                          ben_pstl_zip_rng_f rzr
8369                   where  epz.pstl_zip_rng_id = rzr.pstl_zip_rng_id
8370                   and    epz.business_group_id = rzr.business_group_id
8371                   and    p_effective_date
8372                          between rzr.effective_start_date
8373                          and     rzr.effective_end_date
8374                   and    p_effective_date
8375                          between epz.effective_start_date
8376                          and     epz.effective_end_date
8377                   and    epz.eligy_prfl_id = elp.eligy_prfl_id)
8378     order by elp.eligy_prfl_id;
8379   --
8380   cursor c_elpepz_inst is
8381     select epz.eligy_prfl_id,
8382            epz.elig_pstl_cd_r_rng_prte_id pk_id,
8383            'EPZ' short_code,
8384            epz.excld_flag,
8385            epz.criteria_score,
8386            epz.criteria_weight,
8387            rzr.from_value,
8388            rzr.to_value
8389     from   ben_elig_pstl_cd_r_rng_prte_f epz,
8390            ben_pstl_zip_rng_f rzr
8391     where  epz.pstl_zip_rng_id = rzr.pstl_zip_rng_id
8392     and    epz.business_group_id = rzr.business_group_id
8393     and    p_effective_date
8394            between rzr.effective_start_date
8395            and     rzr.effective_end_date
8396     and    p_effective_date
8397            between epz.effective_start_date
8398            and     epz.effective_end_date
8399     order  by epz.eligy_prfl_id,
8400            decode(epz.excld_flag,'Y',1,2),
8401            epz.ordr_num;
8402   --
8403   l_not_hash_found boolean;
8404   --
8405 begin
8406   --
8407   for objlook in c_elpepz_look loop
8408     --
8409     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
8410     --
8411     -- Check if hashed value is already allocated
8412     --
8413     if g_cache_elpepz_lookup.exists(l_id) then
8414       --
8415       l_not_hash_found := false;
8416       --
8417       -- Loop until un-allocated has value is derived
8418       --
8419       while not l_not_hash_found loop
8420         --
8421         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8422         --
8423         -- Check if the hash index exists, if not we can use it
8424         --
8425         if not g_cache_elpepz_lookup.exists(l_id) then
8426           --
8427           -- Lets store the hash value in the index
8428           --
8429           l_not_hash_found := true;
8430           exit;
8431           --
8432         else
8433           --
8434           l_not_hash_found := false;
8435           --
8436         end if;
8437         --
8438       end loop;
8439       --
8440     end if;
8441     --
8442     g_cache_elpepz_lookup(l_id).id := objlook.eligy_prfl_id;
8443     g_cache_elpepz_lookup(l_id).fk_id := objlook.business_group_id;
8444     --
8445   end loop;
8446   --
8447   l_torrwnum := 0;
8448   l_prev_id := -1;
8449   --
8450   for objinst in c_elpepz_inst loop
8451     --
8452     -- Populate the cache lookup details
8453     --
8454     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
8455     --
8456     -- Check if hashed value is already allocated
8457     --
8458     if g_cache_elpepz_lookup(l_id).id = objinst.eligy_prfl_id then
8459       --
8460       null;
8461       --
8462     else
8463       --
8464       loop
8465         --
8466         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8467         --
8468         if g_cache_elpepz_lookup(l_id).id = objinst.eligy_prfl_id then
8469           --
8470           exit;
8471           --
8472         end if;
8473         --
8474       end loop;
8475       --
8476     end if;
8477     --
8478     -- Check for first row
8479     --
8480     if l_prev_id = -1 then
8481       --
8482       g_cache_elpepz_lookup(l_id).starttorele_num := l_torrwnum;
8483       --
8484     elsif l_id <> l_prev_id then
8485       --
8486       g_cache_elpepz_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8487       g_cache_elpepz_lookup(l_id).starttorele_num := l_torrwnum;
8488       --
8489     end if;
8490     --
8491     -- Populate the cache instance details
8492     --
8493     g_cache_elpepz_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
8494     g_cache_elpepz_inst(l_torrwnum).pk_id := objinst.pk_id;
8495     g_cache_elpepz_inst(l_torrwnum).short_code := objinst.short_code;
8496     g_cache_elpepz_inst(l_torrwnum).criteria_score := objinst.criteria_score;
8497     g_cache_elpepz_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
8498     g_cache_elpepz_inst(l_torrwnum).excld_flag := objinst.excld_flag;
8499     g_cache_elpepz_inst(l_torrwnum).from_value := objinst.from_value;
8500     g_cache_elpepz_inst(l_torrwnum).to_value := objinst.to_value;
8501     --
8502     l_torrwnum := l_torrwnum+1;
8503     l_prev_id := l_id;
8504     --
8505   end loop;
8506   --
8507   g_cache_elpepz_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8508   --
8509 end elpepz_writecache;
8510 --
8511 procedure elpepz_getcacdets
8512   (p_effective_date    in  date,
8513    p_business_group_id in  number,
8514    p_eligy_prfl_id     in  number,
8515    p_refresh_cache     in  boolean default FALSE,
8516    p_inst_set          out nocopy ben_elp_cache.g_cache_elpepz_instor,
8517    p_inst_count        out nocopy number) is
8518   --
8519   l_proc varchar2(72) :=  'elpepz_getcacdets';
8520   l_torrwnum pls_integer;
8521   l_insttorrw_num pls_integer;
8522   l_index         pls_integer;
8523   --
8524   l_not_hash_found boolean;
8525   --
8526 begin
8527   --
8528   -- Flush the cache
8529   --
8530   if p_refresh_cache then
8531     --
8532     g_cache_elpepz_lookup.delete;
8533     g_cache_elpepz_inst.delete;
8534     --
8535   end if;
8536   --
8537   -- Populate the global cache
8538   --
8539   if g_cache_elpepz_lookup.count = 0 then
8540     --
8541     -- Build the cache
8542     --
8543     ben_elp_cache.elpepz_writecache
8544       (p_effective_date => p_effective_date,
8545        p_refresh_cache  => p_refresh_cache);
8546     --
8547   end if;
8548   --
8549   -- Get the instance details
8550   --
8551   l_torrwnum := 0;
8552   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
8553   --
8554   -- Check if hashed value is already allocated
8555   --
8556   if g_cache_elpepz_lookup.exists(l_index) then
8557     --
8558     -- If it does exist make sure its the right one
8559     --
8560     if g_cache_elpepz_lookup(l_index).id <> p_eligy_prfl_id then
8561       --
8562       l_not_hash_found := false;
8563       --
8564       -- Loop until un-allocated has value is derived
8565       --
8566       while not l_not_hash_found loop
8567         --
8568         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
8569         --
8570         -- Check if the hash index exists, if not we can use it
8571         --
8572         if not g_cache_elpepz_lookup.exists(l_index) then
8573           --
8574           -- Lets store the hash value in the index
8575           --
8576           l_not_hash_found := true;
8577           exit;
8578           --
8579         else
8580           --
8581           l_not_hash_found := false;
8582           --
8583         end if;
8584         --
8585       end loop;
8586       --
8587     end if;
8588     --
8589   end if;
8590   --
8591   for l_insttorrw_num in g_cache_elpepz_lookup(l_index).starttorele_num ..
8592     g_cache_elpepz_lookup(l_index).endtorele_num loop
8593     --
8594     p_inst_set(l_torrwnum) := g_cache_elpepz_inst(l_insttorrw_num);
8595     l_torrwnum := l_torrwnum+1;
8596     --
8597   end loop;
8598   --
8599   p_inst_count := l_torrwnum;
8600   --
8601 exception
8602   --
8603   when no_data_found then
8604     --
8605     p_inst_count := 0;
8606     --
8607 end elpepz_getcacdets;
8608 --
8609 procedure elpebn_writecache
8610   (p_effective_date in date,
8611    p_refresh_cache  in boolean default FALSE) is
8612   --
8613   l_proc varchar2(72) :=  'elpebn_writecache';
8614   l_torrwnum pls_integer;
8615   l_prev_id number;
8616   l_id number;
8617   --
8618   cursor c_elpebn_look is
8619     select elp.eligy_prfl_id,
8620            elp.business_group_id
8621     from   ben_eligy_prfl_f elp
8622     where  p_effective_date
8623            between elp.effective_start_date
8624            and     elp.effective_end_date
8625     and    exists(select null
8626                   from   ben_elig_benfts_grp_prte_f ebn
8627                   where  p_effective_date
8628                          between ebn.effective_start_date
8629                          and     ebn.effective_end_date
8630                   and    ebn.eligy_prfl_id = elp.eligy_prfl_id)
8631     order  by elp.eligy_prfl_id;
8632   --
8633   cursor c_elpebn_inst is
8634     select ebn.eligy_prfl_id,
8635            ebn.elig_benfts_grp_prte_id pk_id,
8636            'EBN' short_code,
8637            ebn.benfts_grp_id,
8638            ebn.excld_flag,
8639            ebn.criteria_score,
8640            ebn.criteria_weight
8641     from   ben_elig_benfts_grp_prte_f ebn
8642     where  p_effective_date
8643            between ebn.effective_start_date
8644            and     ebn.effective_end_date
8645     order  by ebn.eligy_prfl_id,
8646            decode(ebn.excld_flag,'Y',1,2),
8647            ebn.ordr_num;
8648   --
8649   l_not_hash_found boolean;
8650   --
8651 begin
8652   --
8653   for objlook in c_elpebn_look loop
8654     --
8655     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
8656     --
8657     -- Check if hashed value is already allocated
8658     --
8659     if g_cache_elpebn_lookup.exists(l_id) then
8660       --
8661       l_not_hash_found := false;
8662       --
8663       -- Loop until un-allocated has value is derived
8664       --
8665       while not l_not_hash_found loop
8666         --
8667         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8668         --
8669         -- Check if the hash index exists, if not we can use it
8670         --
8671         if not g_cache_elpebn_lookup.exists(l_id) then
8672           --
8673           -- Lets store the hash value in the index
8674           --
8675           l_not_hash_found := true;
8676           exit;
8677           --
8678         else
8679           --
8680           l_not_hash_found := false;
8681           --
8682         end if;
8683         --
8684       end loop;
8685       --
8686     end if;
8687     --
8688     g_cache_elpebn_lookup(l_id).id := objlook.eligy_prfl_id;
8689     g_cache_elpebn_lookup(l_id).fk_id := objlook.business_group_id;
8690     --
8691   end loop;
8692   --
8693   l_torrwnum := 0;
8694   l_prev_id := -1;
8695   --
8696   for objinst in c_elpebn_inst loop
8697     --
8698     -- Populate the cache lookup details
8699     --
8700     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
8701     --
8702     -- Check if hashed value is already allocated
8703     --
8704     if g_cache_elpebn_lookup(l_id).id = objinst.eligy_prfl_id then
8705       --
8706       null;
8707       --
8708     else
8709       --
8710       loop
8711         --
8712         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8713         --
8714         if g_cache_elpebn_lookup(l_id).id = objinst.eligy_prfl_id then
8715           --
8716           exit;
8717           --
8718         end if;
8719         --
8720       end loop;
8721       --
8722     end if;
8723     --
8724     -- Check for first row
8725     --
8726     if l_prev_id = -1 then
8727       --
8728       g_cache_elpebn_lookup(l_id).starttorele_num := l_torrwnum;
8729       --
8730     elsif l_id <> l_prev_id then
8731       --
8732       g_cache_elpebn_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8733       g_cache_elpebn_lookup(l_id).starttorele_num := l_torrwnum;
8734       --
8735     end if;
8736     --
8737     -- Populate the cache instance details
8738     --
8739     g_cache_elpebn_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
8740     g_cache_elpebn_inst(l_torrwnum).pk_id := objinst.pk_id;
8741     g_cache_elpebn_inst(l_torrwnum).short_code := objinst.short_code;
8742     g_cache_elpebn_inst(l_torrwnum).criteria_score := objinst.criteria_score;
8743     g_cache_elpebn_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
8744     g_cache_elpebn_inst(l_torrwnum).benfts_grp_id := objinst.benfts_grp_id;
8745     g_cache_elpebn_inst(l_torrwnum).excld_flag := objinst.excld_flag;
8746     --
8747     l_torrwnum := l_torrwnum+1;
8748     l_prev_id := l_id;
8749     --
8750   end loop;
8751   --
8752   g_cache_elpebn_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8753   --
8754 end elpebn_writecache;
8755 --
8756 procedure elpebn_getcacdets
8757   (p_effective_date    in date,
8758    p_business_group_id in number,
8759    p_eligy_prfl_id     in number,
8760    p_refresh_cache     in boolean default FALSE,
8761    p_inst_set          out nocopy ben_elp_cache.g_cache_elpebn_instor,
8762    p_inst_count        out nocopy number) is
8763   --
8764   l_proc varchar2(72) :=  'elpebn_getcacdets';
8765   l_torrwnum pls_integer;
8766   l_insttorrw_num pls_integer;
8767   l_index         pls_integer;
8768   --
8769   l_not_hash_found boolean;
8770   --
8771 begin
8772   --
8773   -- Flush the cache
8774   --
8775   if p_refresh_cache then
8776     --
8777     g_cache_elpebn_lookup.delete;
8778     g_cache_elpebn_inst.delete;
8779     --
8780   end if;
8781   --
8782   -- Populate the global cache
8783   --
8784   if g_cache_elpebn_lookup.count = 0 then
8785     --
8786     -- Build the cache
8787     --
8788     ben_elp_cache.elpebn_writecache
8789       (p_effective_date => p_effective_date,
8790        p_refresh_cache  => p_refresh_cache);
8791     --
8792   end if;
8793   --
8794   -- Get the instance details
8795   --
8796   l_torrwnum := 0;
8797   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
8798   --
8799   -- Check if hashed value is already allocated
8800   --
8801   if g_cache_elpebn_lookup.exists(l_index) then
8802     --
8803     -- If it does exist make sure its the right one
8804     --
8805     if g_cache_elpebn_lookup(l_index).id <> p_eligy_prfl_id then
8806       --
8807       l_not_hash_found := false;
8808       --
8809       -- Loop until un-allocated has value is derived
8810       --
8811       while not l_not_hash_found loop
8812         --
8813         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
8814         --
8815         -- Check if the hash index exists, if not we can use it
8816         --
8817         if not g_cache_elpebn_lookup.exists(l_index) then
8818           --
8819           -- Lets store the hash value in the index
8820           --
8821           l_not_hash_found := true;
8822           exit;
8823           --
8824         else
8825           --
8826           l_not_hash_found := false;
8827           --
8828         end if;
8829         --
8830       end loop;
8831       --
8832     end if;
8833     --
8834   end if;
8835   --
8836   for l_insttorrw_num in g_cache_elpebn_lookup(l_index).starttorele_num ..
8837     g_cache_elpebn_lookup(l_index).endtorele_num loop
8838     --
8839     p_inst_set(l_torrwnum) := g_cache_elpebn_inst(l_insttorrw_num);
8840     l_torrwnum := l_torrwnum+1;
8841     --
8842   end loop;
8843   --
8844   p_inst_count := l_torrwnum;
8845   --
8846 exception
8847   --
8848   when no_data_found then
8849     --
8850     p_inst_count := 0;
8851     --
8852 end elpebn_getcacdets;
8853 --
8854 procedure elpeln_writecache
8855   (p_effective_date in date,
8856    p_refresh_cache  in boolean default FALSE) is
8857   --
8858   l_proc varchar2(72) :=  'elpeln_writecache';
8859   l_torrwnum pls_integer;
8860   l_prev_id number;
8861   l_id number;
8862   --
8863   cursor c_elpeln_look is
8864     select elp.eligy_prfl_id,
8865            elp.business_group_id
8866     from   ben_eligy_prfl_f elp
8867     where  p_effective_date
8868            between elp.effective_start_date
8869            and     elp.effective_end_date
8870     and exists(select null
8871                from   ben_elig_lgl_enty_prte_f eln,
8872                       hr_all_organization_units hao
8873                where  eln.organization_id = hao.organization_id
8874                and    eln.business_group_id = hao.business_group_id
8875                and    p_effective_date
8876                       between eln.effective_start_date
8877                       and     eln.effective_end_date
8878                and eln.eligy_prfl_id = elp.eligy_prfl_id)
8879     order  by elp.eligy_prfl_id;
8880   --
8881   cursor c_elpeln_inst is
8882     select eln.eligy_prfl_id,
8883            eln.elig_lgl_enty_prte_id pk_id,
8884            'ELN' short_code,
8885            eln.excld_flag,
8886            eln.criteria_score,
8887            eln.criteria_weight,
8888            hao.name
8889     from   ben_elig_lgl_enty_prte_f eln,
8890            hr_all_organization_units hao
8891     where  eln.organization_id = hao.organization_id
8892     and    eln.business_group_id = hao.business_group_id
8893     and    p_effective_date
8894            between eln.effective_start_date
8895            and     eln.effective_end_date
8896     order  by eln.eligy_prfl_id,
8897            decode(eln.excld_flag,'Y',1,2),
8898            eln.ordr_num;
8899   --
8900   l_not_hash_found boolean;
8901   --
8902 begin
8903   --
8904   for objlook in c_elpeln_look loop
8905     --
8906     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
8907     --
8908     -- Check if hashed value is already allocated
8909     --
8910     if g_cache_elpeln_lookup.exists(l_id) then
8911       --
8912       l_not_hash_found := false;
8913       --
8914       -- Loop until un-allocated has value is derived
8915       --
8916       while not l_not_hash_found loop
8917         --
8918         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8919         --
8920         -- Check if the hash index exists, if not we can use it
8921         --
8922         if not g_cache_elpeln_lookup.exists(l_id) then
8923           --
8924           -- Lets store the hash value in the index
8925           --
8926           l_not_hash_found := true;
8927           exit;
8928           --
8929         else
8930           --
8931           l_not_hash_found := false;
8932           --
8933         end if;
8934         --
8935       end loop;
8936       --
8937     end if;
8938     --
8939     g_cache_elpeln_lookup(l_id).id := objlook.eligy_prfl_id;
8940     g_cache_elpeln_lookup(l_id).fk_id := objlook.business_group_id;
8941     --
8942   end loop;
8943   --
8944   l_torrwnum := 0;
8945   l_prev_id := -1;
8946   --
8947   for objinst in c_elpeln_inst loop
8948     --
8949     -- Populate the cache lookup details
8950     --
8951     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
8952     --
8953     -- Check if hashed value is already allocated
8954     --
8955     if g_cache_elpeln_lookup(l_id).id = objinst.eligy_prfl_id then
8956       --
8957       null;
8958       --
8959     else
8960       --
8961       loop
8962         --
8963         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
8964         --
8965         if g_cache_elpeln_lookup(l_id).id = objinst.eligy_prfl_id then
8966           --
8967           exit;
8968           --
8969         end if;
8970         --
8971       end loop;
8972       --
8973     end if;
8974     --
8975     -- Check for first row
8976     --
8977     if l_prev_id = -1 then
8978       --
8979       g_cache_elpeln_lookup(l_id).starttorele_num := l_torrwnum;
8980       --
8981     elsif l_id <> l_prev_id then
8982       --
8983       g_cache_elpeln_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
8984       g_cache_elpeln_lookup(l_id).starttorele_num := l_torrwnum;
8985       --
8986     end if;
8987     --
8988     -- Populate the cache instance details
8989     --
8990     g_cache_elpeln_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
8991     g_cache_elpeln_inst(l_torrwnum).pk_id := objinst.pk_id;
8992     g_cache_elpeln_inst(l_torrwnum).short_code := objinst.short_code;
8993     g_cache_elpeln_inst(l_torrwnum).criteria_score := objinst.criteria_score;
8994     g_cache_elpeln_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
8995     g_cache_elpeln_inst(l_torrwnum).excld_flag := objinst.excld_flag;
8996     g_cache_elpeln_inst(l_torrwnum).name := objinst.name;
8997     --
8998     l_torrwnum := l_torrwnum+1;
8999     l_prev_id := l_id;
9000     --
9001   end loop;
9002   --
9003   g_cache_elpeln_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9004   --
9005 end elpeln_writecache;
9006 --
9007 procedure elpeln_getcacdets
9008   (p_effective_date    in  date,
9009    p_business_group_id in  number,
9010    p_eligy_prfl_id     in  number,
9011    p_refresh_cache     in  boolean default FALSE,
9012    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeln_instor,
9013    p_inst_count        out nocopy number) is
9014   --
9015   l_proc varchar2(72) :=  'elpeln_getcacdets';
9016   l_torrwnum pls_integer;
9017   l_insttorrw_num pls_integer;
9018   l_index         pls_integer;
9019   --
9020   l_not_hash_found boolean;
9021   --
9022 begin
9023   --
9024   -- Flush the cache
9025   --
9026   if p_refresh_cache then
9027     --
9028     g_cache_elpeln_lookup.delete;
9029     g_cache_elpeln_inst.delete;
9030     --
9031   end if;
9032   --
9033   -- Populate the global cache
9034   --
9035   if g_cache_elpeln_lookup.count = 0 then
9036     --
9037     -- Build the cache
9038     --
9039     ben_elp_cache.elpeln_writecache
9040       (p_effective_date => p_effective_date,
9041        p_refresh_cache  => p_refresh_cache);
9042     --
9043   end if;
9044   --
9045   -- Get the instance details
9046   --
9047   l_torrwnum := 0;
9048   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
9049   --
9050   -- Check if hashed value is already allocated
9051   --
9052   if g_cache_elpeln_lookup.exists(l_index) then
9053     --
9054     -- If it does exist make sure its the right one
9055     --
9056     if g_cache_elpeln_lookup(l_index).id <> p_eligy_prfl_id then
9057       --
9058       l_not_hash_found := false;
9059       --
9060       -- Loop until un-allocated has value is derived
9061       --
9062       while not l_not_hash_found loop
9063         --
9064         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
9065         --
9066         -- Check if the hash index exists, if not we can use it
9067         --
9068         if not g_cache_elpeln_lookup.exists(l_index) then
9069           --
9070           -- Lets store the hash value in the index
9071           --
9072           l_not_hash_found := true;
9073           exit;
9074           --
9075         else
9076           --
9077           l_not_hash_found := false;
9078           --
9079         end if;
9080         --
9081       end loop;
9082       --
9083     end if;
9084     --
9085   end if;
9086   --
9087   for l_insttorrw_num in g_cache_elpeln_lookup(l_index).starttorele_num ..
9088     g_cache_elpeln_lookup(l_index).endtorele_num loop
9089     --
9090     p_inst_set(l_torrwnum) := g_cache_elpeln_inst(l_insttorrw_num);
9091     l_torrwnum := l_torrwnum+1;
9092     --
9093   end loop;
9094   --
9095   p_inst_count := l_torrwnum;
9096   --
9097 exception
9098   --
9099   when no_data_found then
9100     --
9101     p_inst_count := 0;
9102     --
9103 end elpeln_getcacdets;
9104 --
9105 procedure elpepp_writecache
9106   (p_effective_date in date,
9107    p_refresh_cache  in boolean default FALSE) is
9108   --
9109   l_proc varchar2(72) :=  'elpepp_writecache';
9110   l_torrwnum pls_integer;
9111   l_prev_id number;
9112   l_id number;
9113   --
9114   cursor c_elpepp_look is
9115     select elp.eligy_prfl_id,
9116            elp.business_group_id
9117     from   ben_eligy_prfl_f elp
9118     where  p_effective_date
9119            between elp.effective_start_date
9120            and     elp.effective_end_date
9121     and    exists(select null
9122                   from   ben_elig_prtt_anthr_pl_prte_f epp
9123                   where  p_effective_date
9124                          between epp.effective_start_date
9125                          and     epp.effective_end_date
9126                   and    epp.eligy_prfl_id = elp.eligy_prfl_id)
9127     order  by elp.eligy_prfl_id;
9128   --
9129   cursor c_elpepp_inst is
9130     select epp.eligy_prfl_id,
9131            epp.pl_id,
9132            epp.excld_flag
9133     from   ben_elig_prtt_anthr_pl_prte_f epp
9134     where  p_effective_date
9135            between epp.effective_start_date
9136            and     epp.effective_end_date
9137     order  by epp.eligy_prfl_id,
9138            decode(epp.excld_flag,'Y',1,2),
9139            epp.ordr_num;
9140   --
9141   l_not_hash_found boolean;
9142   --
9143 begin
9144   --
9145   for objlook in c_elpepp_look loop
9146     --
9147     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
9148     --
9149     -- Check if hashed value is already allocated
9150     --
9151     if g_cache_elpepp_lookup.exists(l_id) then
9152       --
9153       l_not_hash_found := false;
9154       --
9155       -- Loop until un-allocated has value is derived
9156       --
9157       while not l_not_hash_found loop
9158         --
9159         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9160         --
9161         -- Check if the hash index exists, if not we can use it
9162         --
9163         if not g_cache_elpepp_lookup.exists(l_id) then
9164           --
9165           -- Lets store the hash value in the index
9166           --
9167           l_not_hash_found := true;
9168           exit;
9169           --
9170         else
9171           --
9172           l_not_hash_found := false;
9173           --
9174         end if;
9175         --
9176       end loop;
9177       --
9178     end if;
9179     --
9180     g_cache_elpepp_lookup(l_id).id := objlook.eligy_prfl_id;
9181     g_cache_elpepp_lookup(l_id).fk_id := objlook.business_group_id;
9182     --
9183   end loop;
9184   --
9185   l_torrwnum := 0;
9186   l_prev_id := -1;
9187   --
9188   for objinst in c_elpepp_inst loop
9189     --
9190     -- Populate the cache lookup details
9191     --
9192     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
9193     --
9194     -- Check if hashed value is already allocated
9195     --
9196     if g_cache_elpepp_lookup(l_id).id = objinst.eligy_prfl_id then
9197       --
9198       null;
9199       --
9200     else
9201       --
9202       loop
9203         --
9204         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9205         --
9206         if g_cache_elpepp_lookup(l_id).id = objinst.eligy_prfl_id then
9207           --
9208           exit;
9209           --
9210         end if;
9211         --
9212       end loop;
9213       --
9214     end if;
9215     --
9216     -- Check for first row
9217     --
9218     if l_prev_id = -1 then
9219       --
9220       g_cache_elpepp_lookup(l_id).starttorele_num := l_torrwnum;
9221       --
9222     elsif l_id <> l_prev_id then
9223       --
9224       g_cache_elpepp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9225       g_cache_elpepp_lookup(l_id).starttorele_num := l_torrwnum;
9226       --
9227     end if;
9228     --
9229     -- Populate the cache instance details
9230     --
9231     g_cache_elpepp_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
9232     g_cache_elpepp_inst(l_torrwnum).pl_id := objinst.pl_id;
9233     g_cache_elpepp_inst(l_torrwnum).excld_flag := objinst.excld_flag;
9234     --
9235     l_torrwnum := l_torrwnum+1;
9236     l_prev_id := l_id;
9237     --
9238   end loop;
9239   --
9240   g_cache_elpepp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9241   --
9242 end elpepp_writecache;
9243 --
9244 procedure elpepp_getcacdets
9245   (p_effective_date    in date,
9246    p_business_group_id in number,
9247    p_eligy_prfl_id     in number,
9248    p_refresh_cache     in boolean default FALSE,
9249    p_inst_set          out nocopy ben_elp_cache.g_cache_elpepp_instor,
9250    p_inst_count        out nocopy number) is
9251   --
9252   l_proc varchar2(72) :=  'elpepp_getcacdets';
9253   l_torrwnum pls_integer;
9254   l_insttorrw_num pls_integer;
9255   l_index         pls_integer;
9256   --
9257   l_not_hash_found boolean;
9258   --
9259 begin
9260   --
9261   -- Flush the cache
9262   --
9263   if p_refresh_cache then
9264     --
9265     g_cache_elpepp_lookup.delete;
9266     g_cache_elpepp_inst.delete;
9267     --
9268   end if;
9269   --
9270   -- Populate the global cache
9271   --
9272   if g_cache_elpepp_lookup.count = 0 then
9273     --
9274     -- Build the cache
9275     --
9276     ben_elp_cache.elpepp_writecache
9277       (p_effective_date => p_effective_date,
9278        p_refresh_cache  => p_refresh_cache);
9279     --
9280   end if;
9281   --
9282   -- Get the instance details
9283   --
9284   l_torrwnum := 0;
9285   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
9286   --
9287   -- Check if hashed value is already allocated
9288   --
9289   if g_cache_elpepp_lookup.exists(l_index) then
9290     --
9291     -- If it does exist make sure its the right one
9292     --
9293     if g_cache_elpepp_lookup(l_index).id <> p_eligy_prfl_id then
9294       --
9295       l_not_hash_found := false;
9296       --
9297       -- Loop until un-allocated has value is derived
9298       --
9299       while not l_not_hash_found loop
9300         --
9301         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
9302         --
9303         -- Check if the hash index exists, if not we can use it
9304         --
9305         if not g_cache_elpepp_lookup.exists(l_index) then
9306           --
9307           -- Lets store the hash value in the index
9308           --
9309           l_not_hash_found := true;
9310           exit;
9311           --
9312         else
9313           --
9314           l_not_hash_found := false;
9315           --
9316         end if;
9317         --
9318       end loop;
9319       --
9320     end if;
9321     --
9322   end if;
9323   --
9324   for l_insttorrw_num in g_cache_elpepp_lookup(l_index).starttorele_num ..
9325     g_cache_elpepp_lookup(l_index).endtorele_num loop
9326     --
9327     p_inst_set(l_torrwnum) := g_cache_elpepp_inst(l_insttorrw_num);
9328     l_torrwnum := l_torrwnum+1;
9329     --
9330   end loop;
9331   --
9332   p_inst_count := l_torrwnum;
9333   --
9334 exception
9335   --
9336   when no_data_found then
9337     --
9338     p_inst_count := 0;
9339     --
9340 end elpepp_getcacdets;
9341 --
9342 procedure elpeoy_writecache
9343   (p_effective_date in date,
9344    p_refresh_cache  in boolean default FALSE) is
9345   --
9346   l_proc varchar2(72) :=  'elpeoy_writecache';
9347   l_torrwnum pls_integer;
9348   l_prev_id number;
9349   l_id number;
9350   --
9351   cursor c_elpeoy_look is
9352     select elp.eligy_prfl_id,
9353            elp.business_group_id
9354     from   ben_eligy_prfl_f elp
9355     where  p_effective_date
9356            between elp.effective_start_date
9357            and     elp.effective_end_date
9358     and    exists(select null
9359                   from   ben_elig_othr_ptip_prte_f eoy
9360                   where  p_effective_date
9361                          between eoy.effective_start_date
9362                          and     eoy.effective_end_date
9363                   and    eoy.eligy_prfl_id = elp.eligy_prfl_id)
9364     order  by elp.eligy_prfl_id;
9365   --
9366   cursor c_elpeoy_inst is
9367     select eoy.eligy_prfl_id,
9368            eoy.ptip_id,
9369            eoy.only_pls_subj_cobra_flag,
9370            eoy.excld_flag
9371     from   ben_elig_othr_ptip_prte_f eoy
9372     where  p_effective_date
9373            between eoy.effective_start_date
9374            and     eoy.effective_end_date
9375     order  by eoy.eligy_prfl_id,
9376            decode(eoy.excld_flag,'Y',1,2),
9377            eoy.ordr_num;
9378   --
9379   l_not_hash_found boolean;
9380   --
9381 begin
9382   --
9383   for objlook in c_elpeoy_look loop
9384     --
9385     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
9386     --
9387     -- Check if hashed value is already allocated
9388     --
9389     if g_cache_elpeoy_lookup.exists(l_id) then
9390       --
9391       l_not_hash_found := false;
9392       --
9393       -- Loop until un-allocated has value is derived
9394       --
9395       while not l_not_hash_found loop
9396         --
9397         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9398         --
9399         -- Check if the hash index exists, if not we can use it
9400         --
9401         if not g_cache_elpeoy_lookup.exists(l_id) then
9402           --
9403           -- Lets store the hash value in the index
9404           --
9405           l_not_hash_found := true;
9406           exit;
9407           --
9408         else
9409           --
9410           l_not_hash_found := false;
9411           --
9412         end if;
9413         --
9414       end loop;
9415       --
9416     end if;
9417     --
9418     g_cache_elpeoy_lookup(l_id).id := objlook.eligy_prfl_id;
9419     g_cache_elpeoy_lookup(l_id).fk_id := objlook.business_group_id;
9420     --
9421   end loop;
9422   --
9423   l_torrwnum := 0;
9424   l_prev_id := -1;
9425   --
9426   for objinst in c_elpeoy_inst loop
9427     --
9428     -- Populate the cache lookup details
9429     --
9430     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
9431     --
9432     -- Check if hashed value is already allocated
9433     --
9434     if g_cache_elpeoy_lookup(l_id).id = objinst.eligy_prfl_id then
9435       --
9436       null;
9437       --
9438     else
9439       --
9440       loop
9441         --
9442         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9443         --
9444         if g_cache_elpeoy_lookup(l_id).id = objinst.eligy_prfl_id then
9445           --
9446           exit;
9447           --
9448         end if;
9449         --
9450       end loop;
9451       --
9452     end if;
9453     --
9454     -- Check for first row
9455     --
9456     if l_prev_id = -1 then
9457       --
9458       g_cache_elpeoy_lookup(l_id).starttorele_num := l_torrwnum;
9459       --
9460     elsif l_id <> l_prev_id then
9461       --
9462       g_cache_elpeoy_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9463       g_cache_elpeoy_lookup(l_id).starttorele_num := l_torrwnum;
9464       --
9465     end if;
9466     --
9467     -- Populate the cache instance details
9468     --
9469     g_cache_elpeoy_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
9470     g_cache_elpeoy_inst(l_torrwnum).ptip_id := objinst.ptip_id;
9471     g_cache_elpeoy_inst(l_torrwnum).only_pls_subj_cobra_flag :=
9472                                     objinst.only_pls_subj_cobra_flag;
9473     g_cache_elpeoy_inst(l_torrwnum).excld_flag := objinst.excld_flag;
9474     --
9475     l_torrwnum := l_torrwnum+1;
9476     l_prev_id := l_id;
9477     --
9478   end loop;
9479   --
9480   g_cache_elpeoy_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9481   --
9482 end elpeoy_writecache;
9483 --
9484 procedure elpeoy_getcacdets
9485   (p_effective_date    in date,
9486    p_business_group_id in number,
9487    p_eligy_prfl_id     in number,
9488    p_refresh_cache     in boolean default FALSE,
9489    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeoy_instor,
9490    p_inst_count        out nocopy number) is
9491   --
9492   l_proc varchar2(72) :=  'elpeoy_getcacdets';
9493   l_torrwnum pls_integer;
9494   l_insttorrw_num pls_integer;
9495   l_index         pls_integer;
9496   --
9497   l_not_hash_found boolean;
9498   --
9499 begin
9500   --
9501   -- Flush the cache
9502   --
9503   if p_refresh_cache then
9504     --
9505     g_cache_elpeoy_lookup.delete;
9506     g_cache_elpeoy_inst.delete;
9507     --
9508   end if;
9509   --
9510   -- Populate the global cache
9511   --
9512   if g_cache_elpeoy_lookup.count = 0 then
9513     --
9514     -- Build the cache
9515     --
9516     ben_elp_cache.elpeoy_writecache
9517       (p_effective_date => p_effective_date,
9518        p_refresh_cache  => p_refresh_cache);
9519     --
9520   end if;
9521   --
9522   -- Get the instance details
9523   --
9524   l_torrwnum := 0;
9525   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
9526   --
9527   -- Check if hashed value is already allocated
9528   --
9529   if g_cache_elpeoy_lookup.exists(l_index) then
9530     --
9531     -- If it does exist make sure its the right one
9532     --
9533     if g_cache_elpeoy_lookup(l_index).id <> p_eligy_prfl_id then
9534       --
9535       l_not_hash_found := false;
9536       --
9537       -- Loop until un-allocated has value is derived
9538       --
9539       while not l_not_hash_found loop
9540         --
9541         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
9542         --
9543         -- Check if the hash index exists, if not we can use it
9544         --
9545         if not g_cache_elpeoy_lookup.exists(l_index) then
9546           --
9547           -- Lets store the hash value in the index
9548           --
9549           l_not_hash_found := true;
9550           exit;
9551           --
9552         else
9553           --
9554           l_not_hash_found := false;
9555           --
9556         end if;
9557         --
9558       end loop;
9559       --
9560     end if;
9561     --
9562   end if;
9563   --
9564   for l_insttorrw_num in g_cache_elpeoy_lookup(l_index).starttorele_num ..
9565     g_cache_elpeoy_lookup(l_index).endtorele_num loop
9566     --
9567     p_inst_set(l_torrwnum) := g_cache_elpeoy_inst(l_insttorrw_num);
9568     l_torrwnum := l_torrwnum+1;
9569     --
9570   end loop;
9571   --
9572   p_inst_count := l_torrwnum;
9573   --
9574 exception
9575   --
9576   when no_data_found then
9577     --
9578     p_inst_count := 0;
9579     --
9580 end elpeoy_getcacdets;
9581 --
9582 /************************************************/
9583 procedure elpetd_writecache
9584   (p_effective_date in date,
9585    p_refresh_cache  in boolean default FALSE) is
9586   --
9587   l_proc varchar2(72) :=  'elpetd_writecache';
9588   l_torrwnum pls_integer;
9589   l_prev_id number;
9590   l_id number;
9591   --
9592   cursor c_elpetd_look is
9593     select elp.eligy_prfl_id,
9594            elp.business_group_id
9595     from   ben_eligy_prfl_f elp
9596     where  p_effective_date
9597            between elp.effective_start_date
9598            and     elp.effective_end_date
9599     and    exists(select null
9600                   from   ben_elig_dpnt_othr_ptip_f etd
9601                   where  p_effective_date
9602                          between etd.effective_start_date
9603                          and     etd.effective_end_date
9604                   and    etd.eligy_prfl_id = elp.eligy_prfl_id)
9605     order  by elp.eligy_prfl_id;
9606   --
9607   cursor c_elpetd_inst is
9608     select etd.eligy_prfl_id,
9609            etd.ptip_id,
9610            --etd.only_pls_subj_cobra_flag,
9611            etd.excld_flag
9612     from   ben_elig_dpnt_othr_ptip_f etd
9613     where  p_effective_date
9614            between etd.effective_start_date
9615            and     etd.effective_end_date
9616     order  by etd.eligy_prfl_id,
9617            decode(etd.excld_flag,'Y',1,2),
9618            etd.ordr_num;
9619   --
9620   l_not_hash_found boolean;
9621   --
9622 begin
9623   --
9624   for objlook in c_elpetd_look loop
9625     --
9626     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
9627     --
9628     -- Check if hashed value is already allocated
9629     --
9630     if g_cache_elpetd_lookup.exists(l_id) then
9631       --
9632       l_not_hash_found := false;
9633       --
9634       -- Loop until un-allocated has value is derived
9635       --
9636       while not l_not_hash_found loop
9637         --
9638         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9639         --
9640         -- Check if the hash index exists, if not we can use it
9641         --
9642         if not g_cache_elpetd_lookup.exists(l_id) then
9643           --
9644           -- Lets store the hash value in the index
9645           --
9646           l_not_hash_found := true;
9647           exit;
9648           --
9649         else
9650           --
9651           l_not_hash_found := false;
9652           --
9653         end if;
9654         --
9655       end loop;
9656       --
9657     end if;
9658     --
9659     g_cache_elpetd_lookup(l_id).id := objlook.eligy_prfl_id;
9660     g_cache_elpetd_lookup(l_id).fk_id := objlook.business_group_id;
9661     --
9662   end loop;
9663   --
9664   l_torrwnum := 0;
9665   l_prev_id := -1;
9666   --
9667   for objinst in c_elpetd_inst loop
9668     --
9669     -- Populate the cache lookup details
9670     --
9671     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
9672     --
9673     -- Check if hashed value is already allocated
9674     --
9675     if g_cache_elpetd_lookup(l_id).id = objinst.eligy_prfl_id then
9676       --
9677       null;
9678       --
9679     else
9680       --
9681       loop
9682         --
9683         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9684         --
9685         if g_cache_elpetd_lookup(l_id).id = objinst.eligy_prfl_id then
9686           --
9687           exit;
9688           --
9689         end if;
9690         --
9691       end loop;
9692       --
9693     end if;
9694     --
9695     -- Check for first row
9696     --
9697     if l_prev_id = -1 then
9698       --
9699       g_cache_elpetd_lookup(l_id).starttorele_num := l_torrwnum;
9700       --
9701     elsif l_id <> l_prev_id then
9702       --
9703       g_cache_elpetd_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9704       g_cache_elpetd_lookup(l_id).starttorele_num := l_torrwnum;
9705       --
9706     end if;
9707     --
9708     -- Populate the cache instance details
9709     --
9710     g_cache_elpetd_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
9711     g_cache_elpetd_inst(l_torrwnum).ptip_id := objinst.ptip_id;
9712    -- g_cache_elpetd_inst(l_torrwnum).only_pls_subj_cobra_flag :=
9713     --                                objinst.only_pls_subj_cobra_flag;
9714     g_cache_elpetd_inst(l_torrwnum).excld_flag := objinst.excld_flag;
9715     --
9716     l_torrwnum := l_torrwnum+1;
9717     l_prev_id := l_id;
9718     --
9719   end loop;
9720   --
9721   g_cache_elpetd_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9722   --
9723 end elpetd_writecache;
9724 --
9725 procedure elpetd_getcacdets
9726   (p_effective_date    in date,
9727    p_business_group_id in number,
9728    p_eligy_prfl_id     in number,
9729    p_refresh_cache     in boolean default FALSE,
9730    p_inst_set          out nocopy ben_elp_cache.g_cache_elpetd_instor,
9731    p_inst_count        out nocopy number) is
9732   --
9733   l_proc varchar2(72) :=  'elpetd_getcacdets';
9734   l_torrwnum pls_integer;
9735   l_insttorrw_num pls_integer;
9736   l_index         pls_integer;
9737   --
9738   l_not_hash_found boolean;
9739   --
9740 begin
9741   --
9742   -- Flush the cache
9743   --
9744   if p_refresh_cache then
9745     --
9746     g_cache_elpetd_lookup.delete;
9747     g_cache_elpetd_inst.delete;
9748     --
9749   end if;
9750   --
9751   -- Populate the global cache
9752   --
9753   if g_cache_elpetd_lookup.count = 0 then
9754     --
9755     -- Build the cache
9756     --
9757     ben_elp_cache.elpetd_writecache
9758       (p_effective_date => p_effective_date,
9759        p_refresh_cache  => p_refresh_cache);
9760     --
9761   end if;
9762   --
9763   -- Get the instance details
9764   --
9765   l_torrwnum := 0;
9766   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
9767   --
9768   -- Check if hashed value is already allocated
9769   --
9770   if g_cache_elpetd_lookup.exists(l_index) then
9771     --
9772     -- If it does exist make sure its the right one
9773     --
9774     if g_cache_elpetd_lookup(l_index).id <> p_eligy_prfl_id then
9775       --
9776       l_not_hash_found := false;
9777       --
9778       -- Loop until un-allocated has value is derived
9779       --
9780       while not l_not_hash_found loop
9781        --
9782         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index)
9783 ;
9784         --
9785         -- Check if the hash index exists, if not we can use it
9786         --
9787         if not g_cache_elpetd_lookup.exists(l_index) then
9788           --
9789           -- Lets store the hash value in the index
9790           --
9791           l_not_hash_found := true;
9792           exit;
9793           --
9794         else
9795           --
9796           l_not_hash_found := false;
9797           --
9798         end if;
9799         --
9800       end loop;
9801       --
9802     end if;
9803     --
9804  end if;
9805   --
9806   for l_insttorrw_num in g_cache_elpetd_lookup(l_index).starttorele_num ..
9807     g_cache_elpetd_lookup(l_index).endtorele_num loop
9808     --
9809     p_inst_set(l_torrwnum) := g_cache_elpetd_inst(l_insttorrw_num);
9810     l_torrwnum := l_torrwnum+1;
9811     --
9812   end loop;
9813   --
9814   p_inst_count := l_torrwnum;
9815   --
9816 exception
9817   --
9818   when no_data_found then
9819     --
9820     p_inst_count := 0;
9821     --
9822 end elpetd_getcacdets;
9823 --
9824 /************************************************/
9825 procedure elpeno_writecache
9826   (p_effective_date in date,
9827    p_refresh_cache  in boolean default FALSE) is
9828   --
9829   l_proc varchar2(72) :=  'elpeno_writecache';
9830   l_torrwnum pls_integer;
9831   l_prev_id number;
9832   l_id number;
9833   --
9834   cursor c_elpeno_look is
9835     select elp.eligy_prfl_id,
9836            elp.business_group_id
9837     from   ben_eligy_prfl_f elp
9838     where  p_effective_date
9839            between elp.effective_start_date
9840            and     elp.effective_end_date
9841     and    exists(select null
9842                   from   ben_elig_no_othr_cvg_prte_f eno
9843                   where  p_effective_date
9844                          between eno.effective_start_date
9845                          and     eno.effective_end_date
9846                   and    eno.eligy_prfl_id = elp.eligy_prfl_id)
9847     order  by elp.eligy_prfl_id;
9848   --
9849   cursor c_elpeno_inst is
9850     select eno.eligy_prfl_id,
9851            eno.coord_ben_no_cvg_flag
9852     from   ben_elig_no_othr_cvg_prte_f eno
9853     where  p_effective_date
9854            between eno.effective_start_date
9855            and     eno.effective_end_date
9856     order  by eno.eligy_prfl_id;
9857   --
9858   l_not_hash_found boolean;
9859   --
9860 begin
9861   --
9862   for objlook in c_elpeno_look loop
9863     --
9864     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
9865     --
9866     -- Check if hashed value is already allocated
9867     --
9868     if g_cache_elpeno_lookup.exists(l_id) then
9869       --
9870       l_not_hash_found := false;
9871       --
9872       -- Loop until un-allocated has value is derived
9873       --
9874       while not l_not_hash_found loop
9875         --
9876         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9877         --
9878         -- Check if the hash index exists, if not we can use it
9879         --
9880         if not g_cache_elpeno_lookup.exists(l_id) then
9881           --
9882           -- Lets store the hash value in the index
9883           --
9884           l_not_hash_found := true;
9885           exit;
9886           --
9887         else
9888           --
9889           l_not_hash_found := false;
9890           --
9891         end if;
9892         --
9893       end loop;
9894       --
9895     end if;
9896     --
9897     g_cache_elpeno_lookup(l_id).id := objlook.eligy_prfl_id;
9898     g_cache_elpeno_lookup(l_id).fk_id := objlook.business_group_id;
9899     --
9900   end loop;
9901   --
9902   l_torrwnum := 0;
9903   l_prev_id := -1;
9904   --
9905   for objinst in c_elpeno_inst loop
9906     --
9907     -- Populate the cache lookup details
9908     --
9909     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
9910     --
9911     -- Check if hashed value is already allocated
9912     --
9913     if g_cache_elpeno_lookup(l_id).id = objinst.eligy_prfl_id then
9914       --
9915       null;
9916       --
9917     else
9918       --
9919       loop
9920         --
9921         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
9922         --
9923         if g_cache_elpeno_lookup(l_id).id = objinst.eligy_prfl_id then
9924           --
9925           exit;
9926           --
9927         end if;
9928         --
9929       end loop;
9930       --
9931     end if;
9932     --
9933     -- Check for first row
9934     --
9935     if l_prev_id = -1 then
9936       --
9937       g_cache_elpeno_lookup(l_id).starttorele_num := l_torrwnum;
9938       --
9939     elsif l_id <> l_prev_id then
9940       --
9941       g_cache_elpeno_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9942       g_cache_elpeno_lookup(l_id).starttorele_num := l_torrwnum;
9943       --
9944     end if;
9945     --
9946     -- Populate the cache instance details
9947     --
9948     g_cache_elpeno_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
9949     g_cache_elpeno_inst(l_torrwnum).coord_ben_no_cvg_flag :=
9950                                     objinst.coord_ben_no_cvg_flag;
9951     --
9952     l_torrwnum := l_torrwnum+1;
9953     l_prev_id := l_id;
9954     --
9955   end loop;
9956   --
9957   g_cache_elpeno_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
9958   --
9959 end elpeno_writecache;
9960 --
9961 procedure elpeno_getcacdets
9962   (p_effective_date    in date,
9963    p_business_group_id in number,
9964    p_eligy_prfl_id     in number,
9965    p_refresh_cache     in boolean default FALSE,
9966    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeno_instor,
9967    p_inst_count        out nocopy number) is
9968   --
9969   l_proc varchar2(72) :=  'elpeno_getcacdets';
9970   l_torrwnum pls_integer;
9971   l_insttorrw_num pls_integer;
9972   l_index         pls_integer;
9973   --
9974   l_not_hash_found boolean;
9975   --
9976 begin
9977   --
9978   -- Flush the cache
9979   --
9980   if p_refresh_cache then
9981     --
9982     g_cache_elpeno_lookup.delete;
9983     g_cache_elpeno_inst.delete;
9984     --
9985   end if;
9986   --
9987   -- Populate the global cache
9988   --
9989   if g_cache_elpeno_lookup.count = 0 then
9990     --
9991     -- Build the cache
9992     --
9993     ben_elp_cache.elpeno_writecache
9994       (p_effective_date => p_effective_date,
9995        p_refresh_cache  => p_refresh_cache);
9996     --
9997   end if;
9998   --
9999   -- Get the instance details
10000   --
10001   l_torrwnum := 0;
10002   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
10003   --
10004   -- Check if hashed value is already allocated
10005   --
10006   if g_cache_elpeno_lookup.exists(l_index) then
10007     --
10008     -- If it does exist make sure its the right one
10009     --
10010     if g_cache_elpeno_lookup(l_index).id <> p_eligy_prfl_id then
10011       --
10012       l_not_hash_found := false;
10013       --
10014       -- Loop until un-allocated has value is derived
10015       --
10016       while not l_not_hash_found loop
10017         --
10018         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
10019         --
10020         -- Check if the hash index exists, if not we can use it
10021         --
10022         if not g_cache_elpeno_lookup.exists(l_index) then
10023           --
10024           -- Lets store the hash value in the index
10025           --
10026           l_not_hash_found := true;
10027           exit;
10028           --
10029         else
10030           --
10031           l_not_hash_found := false;
10032           --
10033         end if;
10034         --
10035       end loop;
10036       --
10037     end if;
10038     --
10039   end if;
10040   --
10041   for l_insttorrw_num in g_cache_elpeno_lookup(l_index).starttorele_num ..
10042     g_cache_elpeno_lookup(l_index).endtorele_num loop
10043     --
10044     p_inst_set(l_torrwnum) := g_cache_elpeno_inst(l_insttorrw_num);
10045     l_torrwnum := l_torrwnum+1;
10046     --
10047   end loop;
10048   --
10049   p_inst_count := l_torrwnum;
10050   --
10051 exception
10052   --
10053   when no_data_found then
10054     --
10055     p_inst_count := 0;
10056     --
10057 end elpeno_getcacdets;
10058 --
10059 procedure elpeep_writecache
10060   (p_effective_date in date,
10061    p_refresh_cache  in boolean default FALSE) is
10062   --
10063   l_proc varchar2(72) :=  'elpeep_writecache';
10064   l_torrwnum pls_integer;
10065   l_prev_id number;
10066   l_id number;
10067   --
10068   cursor c_elpeep_look is
10069     select elp.eligy_prfl_id,
10070            elp.business_group_id
10071     from   ben_eligy_prfl_f elp
10072     where  p_effective_date
10073            between elp.effective_start_date
10074            and     elp.effective_end_date
10075     and    exists(select null
10076                   from   ben_elig_enrld_anthr_pl_f eep
10077                   where  p_effective_date
10078                          between eep.effective_start_date
10079                          and     eep.effective_end_date
10080                   and    eep.eligy_prfl_id = elp.eligy_prfl_id)
10081     order  by elp.eligy_prfl_id;
10082   --
10083   cursor c_elpeep_inst is
10084     select eep.eligy_prfl_id,
10085            eep.pl_id,
10086            eep.enrl_det_dt_cd,
10087            eep.excld_flag
10088     from   ben_elig_enrld_anthr_pl_f eep
10089     where  p_effective_date
10090            between eep.effective_start_date
10091            and     eep.effective_end_date
10092     order  by eep.eligy_prfl_id,
10093            decode(eep.excld_flag,'Y',1,2),
10094            eep.ordr_num;
10095   --
10096   l_not_hash_found boolean;
10097   --
10098 begin
10099   --
10100   for objlook in c_elpeep_look loop
10101     --
10102     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
10103     --
10104     -- Check if hashed value is already allocated
10105     --
10106     if g_cache_elpeep_lookup.exists(l_id) then
10107       --
10108       l_not_hash_found := false;
10109       --
10110       -- Loop until un-allocated has value is derived
10111       --
10112       while not l_not_hash_found loop
10113         --
10114         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10115         --
10116         -- Check if the hash index exists, if not we can use it
10117         --
10118         if not g_cache_elpeep_lookup.exists(l_id) then
10119           --
10120           -- Lets store the hash value in the index
10121           --
10122           l_not_hash_found := true;
10123           exit;
10124           --
10125         else
10126           --
10127           l_not_hash_found := false;
10128           --
10129         end if;
10130         --
10131       end loop;
10132       --
10133     end if;
10134     --
10135     g_cache_elpeep_lookup(l_id).id := objlook.eligy_prfl_id;
10136     g_cache_elpeep_lookup(l_id).fk_id := objlook.business_group_id;
10137     --
10138   end loop;
10139   --
10140   l_torrwnum := 0;
10141   l_prev_id := -1;
10142   --
10143   for objinst in c_elpeep_inst loop
10144     --
10145     -- Populate the cache lookup details
10146     --
10147     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
10148     --
10149     -- Check if hashed value is already allocated
10150     --
10151     if g_cache_elpeep_lookup(l_id).id = objinst.eligy_prfl_id then
10152       --
10153       null;
10154       --
10155     else
10156       --
10157       loop
10158         --
10159         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10160         --
10161         if g_cache_elpeep_lookup(l_id).id = objinst.eligy_prfl_id then
10162           --
10163           exit;
10164           --
10165         end if;
10166         --
10167       end loop;
10168       --
10169     end if;
10170     --
10171     -- Check for first row
10172     --
10173     if l_prev_id = -1 then
10174       --
10175       g_cache_elpeep_lookup(l_id).starttorele_num := l_torrwnum;
10176       --
10177     elsif l_id <> l_prev_id then
10178       --
10179       g_cache_elpeep_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10180       g_cache_elpeep_lookup(l_id).starttorele_num := l_torrwnum;
10181       --
10182     end if;
10183     --
10184     -- Populate the cache instance details
10185     --
10186     g_cache_elpeep_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
10187     g_cache_elpeep_inst(l_torrwnum).pl_id := objinst.pl_id;
10188     g_cache_elpeep_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
10189     g_cache_elpeep_inst(l_torrwnum).excld_flag := objinst.excld_flag;
10190     --
10191     l_torrwnum := l_torrwnum+1;
10192     l_prev_id := l_id;
10193     --
10194   end loop;
10195   --
10196   g_cache_elpeep_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10197   --
10198 end elpeep_writecache;
10199 --
10200 procedure elpeep_getcacdets
10201   (p_effective_date    in date,
10202    p_business_group_id in number,
10203    p_eligy_prfl_id     in number,
10204    p_refresh_cache     in boolean default FALSE,
10205    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeep_instor,
10206    p_inst_count        out nocopy number) is
10207   --
10208   l_proc varchar2(72) :=  'elpeep_getcacdets';
10209   l_torrwnum pls_integer;
10210   l_insttorrw_num pls_integer;
10211   l_index         pls_integer;
10212   --
10213   l_not_hash_found boolean;
10214   --
10215 begin
10216   --
10217   -- Flush the cache
10218   --
10219   if p_refresh_cache then
10220     --
10221     g_cache_elpeep_lookup.delete;
10222     g_cache_elpeep_inst.delete;
10223     --
10224   end if;
10225   --
10226   -- Populate the global cache
10227   --
10228   if g_cache_elpeep_lookup.count = 0 then
10229     --
10230     -- Build the cache
10231     --
10232     ben_elp_cache.elpeep_writecache
10233       (p_effective_date => p_effective_date,
10234        p_refresh_cache  => p_refresh_cache);
10235     --
10236   end if;
10237   --
10238   -- Get the instance details
10239   --
10240   l_torrwnum := 0;
10241   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
10242   --
10243   -- Check if hashed value is already allocated
10244   --
10245   if g_cache_elpeep_lookup.exists(l_index) then
10246     --
10247     -- If it does exist make sure its the right one
10248     --
10249     if g_cache_elpeep_lookup(l_index).id <> p_eligy_prfl_id then
10250       --
10251       l_not_hash_found := false;
10252       --
10253       -- Loop until un-allocated has value is derived
10254       --
10255       while not l_not_hash_found loop
10256         --
10257         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
10258         --
10259         -- Check if the hash index exists, if not we can use it
10260         --
10261         if not g_cache_elpeep_lookup.exists(l_index) then
10262           --
10263           -- Lets store the hash value in the index
10264           --
10265           l_not_hash_found := true;
10266           exit;
10267           --
10268         else
10269           --
10270           l_not_hash_found := false;
10271           --
10272         end if;
10273         --
10274       end loop;
10275       --
10276     end if;
10277     --
10278   end if;
10279   --
10280   for l_insttorrw_num in g_cache_elpeep_lookup(l_index).starttorele_num ..
10281     g_cache_elpeep_lookup(l_index).endtorele_num loop
10282     --
10283     p_inst_set(l_torrwnum) := g_cache_elpeep_inst(l_insttorrw_num);
10284     l_torrwnum := l_torrwnum+1;
10285     --
10286   end loop;
10287   --
10288   p_inst_count := l_torrwnum;
10289   --
10290 exception
10291   --
10292   when no_data_found then
10293     --
10294     p_inst_count := 0;
10295     --
10296 end elpeep_getcacdets;
10297 --
10298 procedure elpeei_writecache
10299   (p_effective_date in date,
10300    p_refresh_cache  in boolean default FALSE) is
10301   --
10302   l_proc varchar2(72) :=  'elpeei_writecache';
10303   l_torrwnum pls_integer;
10304   l_prev_id number;
10305   l_id number;
10306   --
10307   cursor c_elpeei_look is
10308     select elp.eligy_prfl_id,
10309            elp.business_group_id
10310     from   ben_eligy_prfl_f elp
10311     where  p_effective_date
10312            between elp.effective_start_date
10313            and     elp.effective_end_date
10314     and    exists(select null
10315                   from   ben_elig_enrld_anthr_oipl_f eei
10316                   where  p_effective_date
10317                          between eei.effective_start_date
10318                          and     eei.effective_end_date
10319                   and    eei.eligy_prfl_id = elp.eligy_prfl_id)
10320     order  by elp.eligy_prfl_id;
10321   --
10322   cursor c_elpeei_inst is
10323     select eei.eligy_prfl_id,
10324            eei.oipl_id,
10325            eei.enrl_det_dt_cd,
10326            eei.excld_flag
10327     from   ben_elig_enrld_anthr_oipl_f eei
10328     where  p_effective_date
10329            between eei.effective_start_date
10330            and     eei.effective_end_date
10331     order  by eei.eligy_prfl_id,
10332            decode(eei.excld_flag,'Y',1,2),
10333            eei.ordr_num;
10334   --
10335   l_not_hash_found boolean;
10336   --
10337 begin
10338   --
10339   for objlook in c_elpeei_look loop
10340     --
10341     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
10342     --
10343     -- Check if hashed value is already allocated
10344     --
10345     if g_cache_elpeei_lookup.exists(l_id) then
10346       --
10347       l_not_hash_found := false;
10348       --
10349       -- Loop until un-allocated has value is derived
10350       --
10351       while not l_not_hash_found loop
10352         --
10353         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10354         --
10355         -- Check if the hash index exists, if not we can use it
10356         --
10357         if not g_cache_elpeei_lookup.exists(l_id) then
10358           --
10359           -- Lets store the hash value in the index
10360           --
10361           l_not_hash_found := true;
10362           exit;
10363           --
10364         else
10365           --
10366           l_not_hash_found := false;
10367           --
10368         end if;
10369         --
10370       end loop;
10371       --
10372     end if;
10373     --
10374     g_cache_elpeei_lookup(l_id).id := objlook.eligy_prfl_id;
10375     g_cache_elpeei_lookup(l_id).fk_id := objlook.business_group_id;
10376     --
10377   end loop;
10378   --
10379   l_torrwnum := 0;
10380   l_prev_id := -1;
10381   --
10382   for objinst in c_elpeei_inst loop
10383     --
10384     -- Populate the cache lookup details
10385     --
10386     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
10387     --
10388     -- Check if hashed value is already allocated
10389     --
10390     if g_cache_elpeei_lookup(l_id).id = objinst.eligy_prfl_id then
10391       --
10392       null;
10393       --
10394     else
10395       --
10396       loop
10397         --
10398         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10399         --
10400         if g_cache_elpeei_lookup(l_id).id = objinst.eligy_prfl_id then
10401           --
10402           exit;
10403           --
10404         end if;
10405         --
10406       end loop;
10407       --
10408     end if;
10409     --
10410     -- Check for first row
10411     --
10412     if l_prev_id = -1 then
10413       --
10414       g_cache_elpeei_lookup(l_id).starttorele_num := l_torrwnum;
10415       --
10416     elsif l_id <> l_prev_id then
10417       --
10418       g_cache_elpeei_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10419       g_cache_elpeei_lookup(l_id).starttorele_num := l_torrwnum;
10420       --
10421     end if;
10422     --
10423     -- Populate the cache instance details
10424     --
10425     g_cache_elpeei_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
10426     g_cache_elpeei_inst(l_torrwnum).oipl_id := objinst.oipl_id;
10427     g_cache_elpeei_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
10428     g_cache_elpeei_inst(l_torrwnum).excld_flag := objinst.excld_flag;
10429     --
10430     l_torrwnum := l_torrwnum+1;
10431     l_prev_id := l_id;
10432     --
10433   end loop;
10434   --
10435   g_cache_elpeei_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10436   --
10437 end elpeei_writecache;
10438 --
10439 procedure elpeei_getcacdets
10440   (p_effective_date    in date,
10441    p_business_group_id in number,
10442    p_eligy_prfl_id     in number,
10443    p_refresh_cache     in boolean default FALSE,
10444    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeei_instor,
10445    p_inst_count        out nocopy number) is
10446   --
10447   l_proc varchar2(72) :=  'elpeei_getcacdets';
10448   l_torrwnum pls_integer;
10449   l_insttorrw_num pls_integer;
10450   l_index         pls_integer;
10451   --
10452   l_not_hash_found boolean;
10453   --
10454 begin
10455   --
10456   -- Flush the cache
10457   --
10458   if p_refresh_cache then
10459     --
10460     g_cache_elpeei_lookup.delete;
10461     g_cache_elpeei_inst.delete;
10462     --
10463   end if;
10464   --
10465   -- Populate the global cache
10466   --
10467   if g_cache_elpeei_lookup.count = 0 then
10468     --
10469     -- Build the cache
10470     --
10471     ben_elp_cache.elpeei_writecache
10472       (p_effective_date => p_effective_date,
10473        p_refresh_cache  => p_refresh_cache);
10474     --
10475   end if;
10476   --
10477   -- Get the instance details
10478   --
10479   l_torrwnum := 0;
10480   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
10481   --
10482   -- Check if hashed value is already allocated
10483   --
10484   if g_cache_elpeei_lookup.exists(l_index) then
10485     --
10486     -- If it does exist make sure its the right one
10487     --
10488     if g_cache_elpeei_lookup(l_index).id <> p_eligy_prfl_id then
10489       --
10490       l_not_hash_found := false;
10491       --
10492       -- Loop until un-allocated has value is derived
10493       --
10494       while not l_not_hash_found loop
10495         --
10496         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
10497         --
10498         -- Check if the hash index exists, if not we can use it
10499         --
10500         if not g_cache_elpeei_lookup.exists(l_index) then
10501           --
10502           -- Lets store the hash value in the index
10503           --
10504           l_not_hash_found := true;
10505           exit;
10506           --
10507         else
10508           --
10509           l_not_hash_found := false;
10510           --
10511         end if;
10512         --
10513       end loop;
10514       --
10515     end if;
10516     --
10517   end if;
10518   --
10519   for l_insttorrw_num in g_cache_elpeei_lookup(l_index).starttorele_num ..
10520     g_cache_elpeei_lookup(l_index).endtorele_num loop
10521     --
10522     p_inst_set(l_torrwnum) := g_cache_elpeei_inst(l_insttorrw_num);
10523     l_torrwnum := l_torrwnum+1;
10524     --
10525   end loop;
10526   --
10527   p_inst_count := l_torrwnum;
10528   --
10529 exception
10530   --
10531   when no_data_found then
10532     --
10533     p_inst_count := 0;
10534     --
10535 end elpeei_getcacdets;
10536 --
10537 procedure elpeeg_writecache
10538   (p_effective_date in date,
10539    p_refresh_cache  in boolean default FALSE) is
10540   --
10541   l_proc varchar2(72) :=  'elpeeg_writecache';
10542   l_torrwnum pls_integer;
10543   l_prev_id number;
10544   l_id number;
10545   --
10546   cursor c_elpeeg_look is
10547     select elp.eligy_prfl_id,
10548            elp.business_group_id
10549     from   ben_eligy_prfl_f elp
10550     where  p_effective_date
10551            between elp.effective_start_date
10552            and     elp.effective_end_date
10553     and    exists(select null
10554                   from   ben_elig_enrld_anthr_pgm_f eeg
10555                   where  p_effective_date
10556                          between eeg.effective_start_date
10557                          and     eeg.effective_end_date
10558                   and    eeg.eligy_prfl_id = elp.eligy_prfl_id)
10559     order  by elp.eligy_prfl_id;
10560   --
10561   cursor c_elpeeg_inst is
10562     select eeg.eligy_prfl_id,
10563            eeg.pgm_id,
10564            eeg.enrl_det_dt_cd,
10565            eeg.excld_flag
10566     from   ben_elig_enrld_anthr_pgm_f eeg
10567     where  p_effective_date
10568            between eeg.effective_start_date
10569            and     eeg.effective_end_date
10570     order  by eeg.eligy_prfl_id,
10571            decode(eeg.excld_flag,'Y',1,2),
10572            eeg.ordr_num;
10573   --
10574   l_not_hash_found boolean;
10575   --
10576 begin
10577   --
10578   for objlook in c_elpeeg_look loop
10579     --
10580     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
10581     --
10582     -- Check if hashed value is already allocated
10583     --
10584     if g_cache_elpeeg_lookup.exists(l_id) then
10585       --
10586       l_not_hash_found := false;
10587       --
10588       -- Loop until un-allocated has value is derived
10589       --
10590       while not l_not_hash_found loop
10591         --
10592         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10593         --
10594         -- Check if the hash index exists, if not we can use it
10595         --
10596         if not g_cache_elpeeg_lookup.exists(l_id) then
10597           --
10598           -- Lets store the hash value in the index
10599           --
10600           l_not_hash_found := true;
10601           exit;
10602           --
10603         else
10604           --
10605           l_not_hash_found := false;
10606           --
10607         end if;
10608         --
10609       end loop;
10610       --
10611     end if;
10612     --
10613     g_cache_elpeeg_lookup(l_id).id := objlook.eligy_prfl_id;
10614     g_cache_elpeeg_lookup(l_id).fk_id := objlook.business_group_id;
10615     --
10616   end loop;
10617   --
10618   l_torrwnum := 0;
10619   l_prev_id := -1;
10620   --
10621   for objinst in c_elpeeg_inst loop
10622     --
10623     -- Populate the cache lookup details
10624     --
10625     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
10626     --
10627     -- Check if hashed value is already allocated
10628     --
10629     if g_cache_elpeeg_lookup(l_id).id = objinst.eligy_prfl_id then
10630       --
10631       null;
10632       --
10633     else
10634       --
10635       loop
10636         --
10637         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10638         --
10639         if g_cache_elpeeg_lookup(l_id).id = objinst.eligy_prfl_id then
10640           --
10641           exit;
10642           --
10643         end if;
10644         --
10645       end loop;
10646       --
10647     end if;
10648     --
10649     -- Check for first row
10650     --
10651     if l_prev_id = -1 then
10652       --
10653       g_cache_elpeeg_lookup(l_id).starttorele_num := l_torrwnum;
10654       --
10655     elsif l_id <> l_prev_id then
10656       --
10657       g_cache_elpeeg_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10658       g_cache_elpeeg_lookup(l_id).starttorele_num := l_torrwnum;
10659       --
10660     end if;
10661     --
10662     -- Populate the cache instance details
10663     --
10664     g_cache_elpeeg_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
10665     g_cache_elpeeg_inst(l_torrwnum).pgm_id := objinst.pgm_id;
10666     g_cache_elpeeg_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
10667     g_cache_elpeeg_inst(l_torrwnum).excld_flag := objinst.excld_flag;
10668     --
10669     l_torrwnum := l_torrwnum+1;
10670     l_prev_id := l_id;
10671     --
10672   end loop;
10673   --
10674   g_cache_elpeeg_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10675   --
10676 end elpeeg_writecache;
10677 --
10678 procedure elpeeg_getcacdets
10679   (p_effective_date    in date,
10680    p_business_group_id in number,
10681    p_eligy_prfl_id     in number,
10682    p_refresh_cache     in boolean default FALSE,
10683    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeeg_instor,
10684    p_inst_count        out nocopy number) is
10685   --
10686   l_proc varchar2(72) :=  'elpeeg_getcacdets';
10687   l_torrwnum pls_integer;
10688   l_insttorrw_num pls_integer;
10689   l_index         pls_integer;
10690   --
10691   l_not_hash_found boolean;
10692   --
10693 begin
10694   --
10695   -- Flush the cache
10696   --
10697   if p_refresh_cache then
10698     --
10699     g_cache_elpeeg_lookup.delete;
10700     g_cache_elpeeg_inst.delete;
10701     --
10702   end if;
10703   --
10704   -- Populate the global cache
10705   --
10706   if g_cache_elpeeg_lookup.count = 0 then
10707     --
10708     -- Build the cache
10709     --
10710     ben_elp_cache.elpeeg_writecache
10711       (p_effective_date => p_effective_date,
10712        p_refresh_cache  => p_refresh_cache);
10713     --
10714   end if;
10715   --
10716   -- Get the instance details
10717   --
10718   l_torrwnum := 0;
10719   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
10720   --
10721   -- Check if hashed value is already allocated
10722   --
10723   if g_cache_elpeeg_lookup.exists(l_index) then
10724     --
10725     -- If it does exist make sure its the right one
10726     --
10727     if g_cache_elpeeg_lookup(l_index).id <> p_eligy_prfl_id then
10728       --
10729       l_not_hash_found := false;
10730       --
10731       -- Loop until un-allocated has value is derived
10732       --
10733       while not l_not_hash_found loop
10734         --
10735         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
10736         --
10737         -- Check if the hash index exists, if not we can use it
10738         --
10739         if not g_cache_elpeeg_lookup.exists(l_index) then
10740           --
10741           -- Lets store the hash value in the index
10742           --
10743           l_not_hash_found := true;
10744           exit;
10745           --
10746         else
10747           --
10748           l_not_hash_found := false;
10749           --
10750         end if;
10751         --
10752       end loop;
10753       --
10754     end if;
10755     --
10756   end if;
10757   --
10758   for l_insttorrw_num in g_cache_elpeeg_lookup(l_index).starttorele_num ..
10759     g_cache_elpeeg_lookup(l_index).endtorele_num loop
10760     --
10761     p_inst_set(l_torrwnum) := g_cache_elpeeg_inst(l_insttorrw_num);
10762     l_torrwnum := l_torrwnum+1;
10763     --
10764   end loop;
10765   --
10766   p_inst_count := l_torrwnum;
10767   --
10768 exception
10769   --
10770   when no_data_found then
10771     --
10772     p_inst_count := 0;
10773     --
10774 end elpeeg_getcacdets;
10775 --
10776 procedure elpedp_writecache
10777   (p_effective_date in date,
10778    p_refresh_cache  in boolean default FALSE) is
10779   --
10780   l_proc varchar2(72) :=  'elpedp_writecache';
10781   l_torrwnum pls_integer;
10782   l_prev_id number;
10783   l_id number;
10784   --
10785   cursor c_elpedp_look is
10786     select elp.eligy_prfl_id,
10787            elp.business_group_id
10788     from   ben_eligy_prfl_f elp
10789     where  p_effective_date
10790            between elp.effective_start_date
10791            and     elp.effective_end_date
10792     and    exists(select null
10793                   from   ben_elig_dpnt_cvrd_othr_pl_f edp
10794                   where  p_effective_date
10795                          between edp.effective_start_date
10796                          and     edp.effective_end_date
10797                   and    edp.eligy_prfl_id = elp.eligy_prfl_id)
10798     order  by elp.eligy_prfl_id;
10799   --
10800   cursor c_elpedp_inst is
10801     select edp.eligy_prfl_id,
10802            edp.pl_id,
10803            edp.cvg_det_dt_cd,
10804            edp.excld_flag
10805     from   ben_elig_dpnt_cvrd_othr_pl_f edp
10806     where  p_effective_date
10807            between edp.effective_start_date
10808            and     edp.effective_end_date
10809     order  by edp.eligy_prfl_id,
10810            decode(edp.excld_flag,'Y',1,2),
10811            edp.ordr_num;
10812   --
10813   l_not_hash_found boolean;
10814   --
10815 begin
10816   --
10817   for objlook in c_elpedp_look loop
10818     --
10819     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
10820     --
10821     -- Check if hashed value is already allocated
10822     --
10823     if g_cache_elpedp_lookup.exists(l_id) then
10824       --
10825       l_not_hash_found := false;
10826       --
10827       -- Loop until un-allocated has value is derived
10828       --
10829       while not l_not_hash_found loop
10830         --
10831         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10832         --
10833         -- Check if the hash index exists, if not we can use it
10834         --
10835         if not g_cache_elpedp_lookup.exists(l_id) then
10836           --
10837           -- Lets store the hash value in the index
10838           --
10839           l_not_hash_found := true;
10840           exit;
10841           --
10842         else
10843           --
10844           l_not_hash_found := false;
10845           --
10846         end if;
10847         --
10848       end loop;
10849       --
10850     end if;
10851     --
10852     g_cache_elpedp_lookup(l_id).id := objlook.eligy_prfl_id;
10853     g_cache_elpedp_lookup(l_id).fk_id := objlook.business_group_id;
10854     --
10855   end loop;
10856   --
10857   l_torrwnum := 0;
10858   l_prev_id := -1;
10859   --
10860   for objinst in c_elpedp_inst loop
10861     --
10862     -- Populate the cache lookup details
10863     --
10864     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
10865     --
10866     -- Check if hashed value is already allocated
10867     --
10868     if g_cache_elpedp_lookup(l_id).id = objinst.eligy_prfl_id then
10869       --
10870       null;
10871       --
10872     else
10873       --
10874       loop
10875         --
10876         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
10877         --
10878         if g_cache_elpedp_lookup(l_id).id = objinst.eligy_prfl_id then
10879           --
10880           exit;
10881           --
10882         end if;
10883         --
10884       end loop;
10885       --
10886     end if;
10887     --
10888     -- Check for first row
10889     --
10890     if l_prev_id = -1 then
10891       --
10892       g_cache_elpedp_lookup(l_id).starttorele_num := l_torrwnum;
10893       --
10894     elsif l_id <> l_prev_id then
10895       --
10896       g_cache_elpedp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10897       g_cache_elpedp_lookup(l_id).starttorele_num := l_torrwnum;
10898       --
10899     end if;
10900     --
10901     -- Populate the cache instance details
10902     --
10903     g_cache_elpedp_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
10904     g_cache_elpedp_inst(l_torrwnum).pl_id := objinst.pl_id;
10905     g_cache_elpedp_inst(l_torrwnum).cvg_det_dt_cd := objinst.cvg_det_dt_cd;
10906     g_cache_elpedp_inst(l_torrwnum).excld_flag := objinst.excld_flag;
10907     --
10908     l_torrwnum := l_torrwnum+1;
10909     l_prev_id := l_id;
10910     --
10911   end loop;
10912   --
10913   g_cache_elpedp_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
10914   --
10915 end elpedp_writecache;
10916 --
10917 procedure elpedp_getcacdets
10918   (p_effective_date    in date,
10919    p_business_group_id in number,
10920    p_eligy_prfl_id     in number,
10921    p_refresh_cache     in boolean default FALSE,
10922    p_inst_set          out nocopy ben_elp_cache.g_cache_elpedp_instor,
10923    p_inst_count        out nocopy number) is
10924   --
10925   l_proc varchar2(72) :=  'elpedp_getcacdets';
10926   l_torrwnum pls_integer;
10927   l_insttorrw_num pls_integer;
10928   l_index         pls_integer;
10929   --
10930   l_not_hash_found boolean;
10931   --
10932 begin
10933   --
10934   -- Flush the cache
10935   --
10936   if p_refresh_cache then
10937     --
10938     g_cache_elpedp_lookup.delete;
10939     g_cache_elpedp_inst.delete;
10940     --
10941   end if;
10942   --
10943   -- Populate the global cache
10944   --
10945   if g_cache_elpedp_lookup.count = 0 then
10946     --
10947     -- Build the cache
10948     --
10949     ben_elp_cache.elpedp_writecache
10950       (p_effective_date => p_effective_date,
10951        p_refresh_cache  => p_refresh_cache);
10952     --
10953   end if;
10954   --
10955   -- Get the instance details
10956   --
10957   l_torrwnum := 0;
10958   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
10959   --
10960   -- Check if hashed value is already allocated
10961   --
10962   if g_cache_elpedp_lookup.exists(l_index) then
10963     --
10964     -- If it does exist make sure its the right one
10965     --
10966     if g_cache_elpedp_lookup(l_index).id <> p_eligy_prfl_id then
10967       --
10968       l_not_hash_found := false;
10969       --
10970       -- Loop until un-allocated has value is derived
10971       --
10972       while not l_not_hash_found loop
10973         --
10974         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
10975         --
10976         -- Check if the hash index exists, if not we can use it
10977         --
10978         if not g_cache_elpedp_lookup.exists(l_index) then
10979           --
10980           -- Lets store the hash value in the index
10981           --
10982           l_not_hash_found := true;
10983           exit;
10984           --
10985         else
10986           --
10987           l_not_hash_found := false;
10988           --
10989         end if;
10990         --
10991       end loop;
10992       --
10993     end if;
10994     --
10995   end if;
10996   --
10997   for l_insttorrw_num in g_cache_elpedp_lookup(l_index).starttorele_num ..
10998     g_cache_elpedp_lookup(l_index).endtorele_num loop
10999     --
11000     p_inst_set(l_torrwnum) := g_cache_elpedp_inst(l_insttorrw_num);
11001     l_torrwnum := l_torrwnum+1;
11002     --
11003   end loop;
11004   --
11005   p_inst_count := l_torrwnum;
11006   --
11007 exception
11008   --
11009   when no_data_found then
11010     --
11011     p_inst_count := 0;
11012     --
11013 end elpedp_getcacdets;
11014 --
11015 procedure elpelv_writecache
11016   (p_effective_date in date,
11017    p_refresh_cache  in boolean default FALSE) is
11018   --
11019   l_proc varchar2(72) :=  'elpelv_writecache';
11020   l_torrwnum pls_integer;
11021   l_prev_id number;
11022   l_id number;
11023   --
11024   cursor c_elpelv_look is
11025     select elp.eligy_prfl_id,
11026            elp.business_group_id
11027     from   ben_eligy_prfl_f elp
11028     where  p_effective_date
11029            between elp.effective_start_date
11030            and     elp.effective_end_date
11031     and    exists(select null
11032                   from   ben_elig_lvg_rsn_prte_f elv
11033                   where  p_effective_date
11034                          between elv.effective_start_date
11035                          and     elv.effective_end_date
11036                   and    elv.eligy_prfl_id = elp.eligy_prfl_id)
11037     order  by elp.eligy_prfl_id;
11038   --
11039   cursor c_elpelv_inst is
11040     select elv.eligy_prfl_id,
11041            elv.elig_lvg_rsn_prte_id pk_id,
11042            'ELV' short_code,
11043            elv.lvg_rsn_cd,
11044            elv.excld_flag,
11045            elv.criteria_score,
11046            elv.criteria_weight
11047     from   ben_elig_lvg_rsn_prte_f elv
11048     where  p_effective_date
11049            between elv.effective_start_date
11050            and     elv.effective_end_date
11051     order  by elv.eligy_prfl_id,
11052            decode(elv.excld_flag,'Y',1,2),
11053            elv.ordr_num;
11054   --
11055   l_not_hash_found boolean;
11056   --
11057 begin
11058   --
11059   for objlook in c_elpelv_look loop
11060     --
11061     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
11062     --
11063     -- Check if hashed value is already allocated
11064     --
11065     if g_cache_elpelv_lookup.exists(l_id) then
11066       --
11067       l_not_hash_found := false;
11068       --
11069       -- Loop until un-allocated has value is derived
11070       --
11071       while not l_not_hash_found loop
11072         --
11073         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11074         --
11075         -- Check if the hash index exists, if not we can use it
11076         --
11077         if not g_cache_elpelv_lookup.exists(l_id) then
11078           --
11079           -- Lets store the hash value in the index
11080           --
11081           l_not_hash_found := true;
11082           exit;
11083           --
11084         else
11085           --
11086           l_not_hash_found := false;
11087           --
11088         end if;
11089         --
11090       end loop;
11091       --
11092     end if;
11093     --
11094     g_cache_elpelv_lookup(l_id).id := objlook.eligy_prfl_id;
11095     g_cache_elpelv_lookup(l_id).fk_id := objlook.business_group_id;
11096     --
11097   end loop;
11098   --
11099   l_torrwnum := 0;
11100   l_prev_id := -1;
11101   --
11102   for objinst in c_elpelv_inst loop
11103     --
11104     -- Populate the cache lookup details
11105     --
11106     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
11107     --
11108     -- Check if hashed value is already allocated
11109     --
11110     if g_cache_elpelv_lookup(l_id).id = objinst.eligy_prfl_id then
11111       --
11112       null;
11113       --
11114     else
11115       --
11116       loop
11117         --
11118         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11119         --
11120         if g_cache_elpelv_lookup(l_id).id = objinst.eligy_prfl_id then
11121           --
11122           exit;
11123           --
11124         end if;
11125         --
11126       end loop;
11127       --
11128     end if;
11129     --
11130     -- Check for first row
11131     --
11132     if l_prev_id = -1 then
11133       --
11134       g_cache_elpelv_lookup(l_id).starttorele_num := l_torrwnum;
11135       --
11136     elsif l_id <> l_prev_id then
11137       --
11138       g_cache_elpelv_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11139       g_cache_elpelv_lookup(l_id).starttorele_num := l_torrwnum;
11140       --
11141     end if;
11142     --
11143     -- Populate the cache instance details
11144     --
11145     g_cache_elpelv_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
11146     g_cache_elpelv_inst(l_torrwnum).pk_id := objinst.pk_id;
11147     g_cache_elpelv_inst(l_torrwnum).short_code := objinst.short_code;
11148     g_cache_elpelv_inst(l_torrwnum).criteria_score := objinst.criteria_score;
11149     g_cache_elpelv_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
11150     g_cache_elpelv_inst(l_torrwnum).lvg_rsn_cd := objinst.lvg_rsn_cd;
11151     g_cache_elpelv_inst(l_torrwnum).excld_flag := objinst.excld_flag;
11152     --
11153     l_torrwnum := l_torrwnum+1;
11154     l_prev_id := l_id;
11155     --
11156   end loop;
11157   --
11158   g_cache_elpelv_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11159   --
11160 end elpelv_writecache;
11161 --
11162 procedure elpelv_getcacdets
11163   (p_effective_date    in date,
11164    p_business_group_id in number,
11165    p_eligy_prfl_id     in number,
11166    p_refresh_cache     in boolean default FALSE,
11167    p_inst_set          out nocopy ben_elp_cache.g_cache_elpelv_instor,
11168    p_inst_count        out nocopy number) is
11169   --
11170   l_proc varchar2(72) :=  'elpelv_getcacdets';
11171   l_torrwnum pls_integer;
11172   l_insttorrw_num pls_integer;
11173   l_index         pls_integer;
11174   --
11175   l_not_hash_found boolean;
11176   --
11177 begin
11178   --
11179   -- Flush the cache
11180   --
11181   if p_refresh_cache then
11182     --
11183     g_cache_elpelv_lookup.delete;
11184     g_cache_elpelv_inst.delete;
11185     --
11186   end if;
11187   --
11188   -- Populate the global cache
11189   --
11190   if g_cache_elpelv_lookup.count = 0 then
11191     --
11192     -- Build the cache
11193     --
11194     ben_elp_cache.elpelv_writecache
11195       (p_effective_date => p_effective_date,
11196        p_refresh_cache  => p_refresh_cache);
11197     --
11198   end if;
11199   --
11200   -- Get the instance details
11201   --
11202   l_torrwnum := 0;
11203   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
11204   --
11205   -- Check if hashed value is already allocated
11206   --
11207   if g_cache_elpelv_lookup.exists(l_index) then
11208     --
11209     -- If it does exist make sure its the right one
11210     --
11211     if g_cache_elpelv_lookup(l_index).id <> p_eligy_prfl_id then
11212       --
11213       l_not_hash_found := false;
11214       --
11215       -- Loop until un-allocated has value is derived
11216       --
11217       while not l_not_hash_found loop
11218         --
11219         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
11220         --
11221         -- Check if the hash index exists, if not we can use it
11222         --
11223         if not g_cache_elpelv_lookup.exists(l_index) then
11224           --
11225           -- Lets store the hash value in the index
11226           --
11227           l_not_hash_found := true;
11228           exit;
11229           --
11230         else
11231           --
11232           l_not_hash_found := false;
11233           --
11234         end if;
11235         --
11236       end loop;
11237       --
11238     end if;
11239     --
11240   end if;
11241   --
11242   for l_insttorrw_num in g_cache_elpelv_lookup(l_index).starttorele_num ..
11243     g_cache_elpelv_lookup(l_index).endtorele_num loop
11244     --
11245     p_inst_set(l_torrwnum) := g_cache_elpelv_inst(l_insttorrw_num);
11246     l_torrwnum := l_torrwnum+1;
11247     --
11248   end loop;
11249   --
11250   p_inst_count := l_torrwnum;
11251   --
11252 exception
11253   --
11254   when no_data_found then
11255     --
11256     p_inst_count := 0;
11257     --
11258 end elpelv_getcacdets;
11259 --
11260 procedure elpeom_writecache
11261   (p_effective_date in date,
11262    p_refresh_cache  in boolean default FALSE) is
11263   --
11264   l_proc varchar2(72) :=  'elpeom_writecache';
11265   l_torrwnum pls_integer;
11266   l_prev_id number;
11267   l_id number;
11268   --
11269   cursor c_elpeom_look is
11270     select elp.eligy_prfl_id,
11271            elp.business_group_id
11272     from   ben_eligy_prfl_f elp
11273     where  p_effective_date
11274            between elp.effective_start_date
11275            and     elp.effective_end_date
11276     and    exists(select null
11277                   from   ben_elig_optd_mdcr_prte_f eom
11278                   where  p_effective_date
11279                          between eom.effective_start_date
11280                          and     eom.effective_end_date
11281                   and    eom.eligy_prfl_id = elp.eligy_prfl_id)
11282     order  by elp.eligy_prfl_id;
11283   --
11284   cursor c_elpeom_inst is
11285     select eom.eligy_prfl_id,
11286            eom.optd_mdcr_flag,
11287            eom.exlcd_flag
11288     from   ben_elig_optd_mdcr_prte_f eom
11289     where  p_effective_date
11290            between eom.effective_start_date
11291            and     eom.effective_end_date
11292     order  by eom.eligy_prfl_id,
11293            decode(eom.exlcd_flag,'Y',1,2);
11294   --
11295   l_not_hash_found boolean;
11296   --
11297 begin
11298   --
11299   for objlook in c_elpeom_look loop
11300     --
11301     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
11302     --
11303     -- Check if hashed value is already allocated
11304     --
11305     if g_cache_elpeom_lookup.exists(l_id) then
11306       --
11307       l_not_hash_found := false;
11308       --
11309       -- Loop until un-allocated has value is derived
11310       --
11311       while not l_not_hash_found loop
11312         --
11313         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11314         --
11315         -- Check if the hash index exists, if not we can use it
11316         --
11317         if not g_cache_elpeom_lookup.exists(l_id) then
11318           --
11319           -- Lets store the hash value in the index
11320           --
11321           l_not_hash_found := true;
11322           exit;
11323           --
11324         else
11325           --
11326           l_not_hash_found := false;
11327           --
11328         end if;
11329         --
11330       end loop;
11331       --
11332     end if;
11333     --
11334     g_cache_elpeom_lookup(l_id).id := objlook.eligy_prfl_id;
11335     g_cache_elpeom_lookup(l_id).fk_id := objlook.business_group_id;
11336     --
11337   end loop;
11338   --
11339   l_torrwnum := 0;
11340   l_prev_id := -1;
11341   --
11342   for objinst in c_elpeom_inst loop
11343     --
11344     -- Populate the cache lookup details
11345     --
11346     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
11347     --
11348     -- Check if hashed value is already allocated
11349     --
11350     if g_cache_elpeom_lookup(l_id).id = objinst.eligy_prfl_id then
11351       --
11352       null;
11353       --
11354     else
11355       --
11356       loop
11357         --
11358         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11359         --
11360         if g_cache_elpeom_lookup(l_id).id = objinst.eligy_prfl_id then
11361           --
11362           exit;
11363           --
11364         end if;
11365         --
11366       end loop;
11367       --
11368     end if;
11369     --
11370     -- Check for first row
11371     --
11372     if l_prev_id = -1 then
11373       --
11374       g_cache_elpeom_lookup(l_id).starttorele_num := l_torrwnum;
11375       --
11376     elsif l_id <> l_prev_id then
11377       --
11378       g_cache_elpeom_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11379       g_cache_elpeom_lookup(l_id).starttorele_num := l_torrwnum;
11380       --
11381     end if;
11382     --
11383     -- Populate the cache instance details
11384     --
11385     g_cache_elpeom_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
11386     g_cache_elpeom_inst(l_torrwnum).optd_mdcr_flag := objinst.optd_mdcr_flag;
11387     g_cache_elpeom_inst(l_torrwnum).excld_flag := objinst.exlcd_flag;
11388     --
11389     l_torrwnum := l_torrwnum+1;
11390     l_prev_id := l_id;
11391     --
11392   end loop;
11393   --
11394   g_cache_elpeom_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11395   --
11396 end elpeom_writecache;
11397 --
11398 procedure elpeom_getcacdets
11399   (p_effective_date    in date,
11400    p_business_group_id in number,
11401    p_eligy_prfl_id     in number,
11402    p_refresh_cache     in boolean default FALSE,
11403    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeom_instor,
11404    p_inst_count        out nocopy number) is
11405   --
11406   l_proc varchar2(72) :=  'elpeom_getcacdets';
11407   l_torrwnum pls_integer;
11408   l_insttorrw_num pls_integer;
11409   l_index         pls_integer;
11410   --
11411   l_not_hash_found boolean;
11412   --
11413 begin
11414   --
11415   -- Flush the cache
11416   --
11417   if p_refresh_cache then
11418     --
11419     g_cache_elpeom_lookup.delete;
11420     g_cache_elpeom_inst.delete;
11421     --
11422   end if;
11423   --
11424   -- Populate the global cache
11425   --
11426   if g_cache_elpeom_lookup.count = 0 then
11427     --
11428     -- Build the cache
11429     --
11430     ben_elp_cache.elpeom_writecache
11431       (p_effective_date => p_effective_date,
11432        p_refresh_cache  => p_refresh_cache);
11433     --
11434   end if;
11435   --
11436   -- Get the instance details
11437   --
11438   l_torrwnum := 0;
11439   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
11440   --
11441   -- Check if hashed value is already allocated
11442   --
11443   if g_cache_elpeom_lookup.exists(l_index) then
11444     --
11445     -- If it does exist make sure its the right one
11446     --
11447     if g_cache_elpeom_lookup(l_index).id <> p_eligy_prfl_id then
11448       --
11449       l_not_hash_found := false;
11450       --
11451       -- Loop until un-allocated has value is derived
11452       --
11453       while not l_not_hash_found loop
11454         --
11455         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
11456         --
11457         -- Check if the hash index exists, if not we can use it
11458         --
11459         if not g_cache_elpeom_lookup.exists(l_index) then
11460           --
11461           -- Lets store the hash value in the index
11462           --
11463           l_not_hash_found := true;
11464           exit;
11465           --
11466         else
11467           --
11468           l_not_hash_found := false;
11469           --
11470         end if;
11471         --
11472       end loop;
11473       --
11474     end if;
11475     --
11476   end if;
11477   --
11478   for l_insttorrw_num in g_cache_elpeom_lookup(l_index).starttorele_num ..
11479     g_cache_elpeom_lookup(l_index).endtorele_num loop
11480     --
11481     p_inst_set(l_torrwnum) := g_cache_elpeom_inst(l_insttorrw_num);
11482     l_torrwnum := l_torrwnum+1;
11483     --
11484   end loop;
11485   --
11486   p_inst_count := l_torrwnum;
11487   --
11488 exception
11489   --
11490   when no_data_found then
11491     --
11492     p_inst_count := 0;
11493     --
11494 end elpeom_getcacdets;
11495 --
11496 procedure elpeai_writecache
11497   (p_effective_date in date,
11498    p_refresh_cache  in boolean default FALSE) is
11499   --
11500   l_proc varchar2(72) :=  'elpeai_writecache';
11501   l_torrwnum pls_integer;
11502   l_prev_id number;
11503   l_id number;
11504   --
11505   cursor c_elpeai_look is
11506     select elp.eligy_prfl_id,
11507            elp.business_group_id
11508     from   ben_eligy_prfl_f elp
11509     where  p_effective_date
11510            between elp.effective_start_date
11511            and     elp.effective_end_date
11512     and    exists(select null
11513                   from   ben_elig_enrld_anthr_plip_f eai
11514                   where  p_effective_date
11515                          between eai.effective_start_date
11516                          and     eai.effective_end_date
11517                   and    eai.eligy_prfl_id = elp.eligy_prfl_id)
11518     order  by elp.eligy_prfl_id;
11519   --
11520   cursor c_elpeai_inst is
11521     select eai.eligy_prfl_id,
11522            eai.enrl_det_dt_cd,
11523            eai.plip_id,
11524            eai.excld_flag
11525     from   ben_elig_enrld_anthr_plip_f eai
11526     where  p_effective_date
11527            between eai.effective_start_date
11528            and     eai.effective_end_date
11529     order  by eai.eligy_prfl_id,
11530            decode(eai.excld_flag,'Y',1,2);
11531   --
11532   l_not_hash_found boolean;
11533   --
11534 begin
11535   --
11536   for objlook in c_elpeai_look loop
11537     --
11538     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
11539     --
11540     -- Check if hashed value is already allocated
11541     --
11542     if g_cache_elpeai_lookup.exists(l_id) then
11543       --
11544       l_not_hash_found := false;
11545       --
11546       -- Loop until un-allocated has value is derived
11547       --
11548       while not l_not_hash_found loop
11549         --
11550         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11551         --
11552         -- Check if the hash index exists, if not we can use it
11553         --
11554         if not g_cache_elpeai_lookup.exists(l_id) then
11555           --
11556           -- Lets store the hash value in the index
11557           --
11558           l_not_hash_found := true;
11559           exit;
11560           --
11561         else
11562           --
11563           l_not_hash_found := false;
11564           --
11565         end if;
11566         --
11567       end loop;
11568       --
11569     end if;
11570     --
11571     g_cache_elpeai_lookup(l_id).id := objlook.eligy_prfl_id;
11572     g_cache_elpeai_lookup(l_id).fk_id := objlook.business_group_id;
11573     --
11574   end loop;
11575   --
11576   l_torrwnum := 0;
11577   l_prev_id := -1;
11578   --
11579   for objinst in c_elpeai_inst loop
11580     --
11581     -- Populate the cache lookup details
11582     --
11583     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
11584     --
11585     -- Check if hashed value is already allocated
11586     --
11587     if g_cache_elpeai_lookup(l_id).id = objinst.eligy_prfl_id then
11588       --
11589       null;
11590       --
11591     else
11592       --
11593       loop
11594         --
11595         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11596         --
11597         if g_cache_elpeai_lookup(l_id).id = objinst.eligy_prfl_id then
11598           --
11599           exit;
11600           --
11601         end if;
11602         --
11603       end loop;
11604       --
11605     end if;
11606     --
11607     -- Check for first row
11608     --
11609     if l_prev_id = -1 then
11610       --
11611       g_cache_elpeai_lookup(l_id).starttorele_num := l_torrwnum;
11612       --
11613     elsif l_id <> l_prev_id then
11614       --
11615       g_cache_elpeai_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11616       g_cache_elpeai_lookup(l_id).starttorele_num := l_torrwnum;
11617       --
11618     end if;
11619     --
11620     -- Populate the cache instance details
11621     --
11622     g_cache_elpeai_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
11623     g_cache_elpeai_inst(l_torrwnum).excld_flag := objinst.excld_flag;
11624     g_cache_elpeai_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
11625     g_cache_elpeai_inst(l_torrwnum).plip_id := objinst.plip_id;
11626     --
11627     l_torrwnum := l_torrwnum+1;
11628     l_prev_id := l_id;
11629     --
11630   end loop;
11631   --
11632   g_cache_elpeai_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11633   --
11634 end elpeai_writecache;
11635 --
11636 procedure elpeai_getcacdets
11637   (p_effective_date    in date,
11638    p_business_group_id in number,
11639    p_eligy_prfl_id     in number,
11640    p_refresh_cache     in boolean default FALSE,
11641    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeai_instor,
11642    p_inst_count        out nocopy number) is
11643   --
11644   l_proc varchar2(72) :=  'elpeai_getcacdets';
11645   l_torrwnum pls_integer;
11646   l_insttorrw_num pls_integer;
11647   l_index         pls_integer;
11648   --
11649   l_not_hash_found boolean;
11650   --
11651 begin
11652   --
11653   -- Flush the cache
11654   --
11655   if p_refresh_cache then
11656     --
11657     g_cache_elpeai_lookup.delete;
11658     g_cache_elpeai_inst.delete;
11659     --
11660   end if;
11661   --
11662   -- Populate the global cache
11663   --
11664   if g_cache_elpeai_lookup.count = 0 then
11665     --
11666     -- Build the cache
11667     --
11668     ben_elp_cache.elpeai_writecache
11669       (p_effective_date => p_effective_date,
11670        p_refresh_cache  => p_refresh_cache);
11671     --
11672   end if;
11673   --
11674   -- Get the instance details
11675   --
11676   l_torrwnum := 0;
11677   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
11678   --
11679   -- Check if hashed value is already allocated
11680   --
11681   if g_cache_elpeai_lookup.exists(l_index) then
11682     --
11683     -- If it does exist make sure its the right one
11684     --
11685     if g_cache_elpeai_lookup(l_index).id <> p_eligy_prfl_id then
11686       --
11687       l_not_hash_found := false;
11688       --
11689       -- Loop until un-allocated has value is derived
11690       --
11691       while not l_not_hash_found loop
11692         --
11693         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
11694         --
11695         -- Check if the hash index exists, if not we can use it
11696         --
11697         if not g_cache_elpeai_lookup.exists(l_index) then
11698           --
11699           -- Lets store the hash value in the index
11700           --
11701           l_not_hash_found := true;
11702           exit;
11703           --
11704         else
11705           --
11706           l_not_hash_found := false;
11707           --
11708         end if;
11709         --
11710       end loop;
11711       --
11712     end if;
11713     --
11714   end if;
11715   --
11716   for l_insttorrw_num in g_cache_elpeai_lookup(l_index).starttorele_num ..
11717     g_cache_elpeai_lookup(l_index).endtorele_num loop
11718     --
11719     p_inst_set(l_torrwnum) := g_cache_elpeai_inst(l_insttorrw_num);
11720     l_torrwnum := l_torrwnum+1;
11721     --
11722   end loop;
11723   --
11724   p_inst_count := l_torrwnum;
11725   --
11726 exception
11727   --
11728   when no_data_found then
11729     --
11730     p_inst_count := 0;
11731     --
11732 end elpeai_getcacdets;
11733 --
11734 procedure elpedi_writecache
11735   (p_effective_date in date,
11736    p_refresh_cache  in boolean default FALSE) is
11737   --
11738   l_proc varchar2(72) :=  'elpedi_writecache';
11739   l_torrwnum pls_integer;
11740   l_prev_id number;
11741   l_id number;
11742   --
11743   cursor c_elpedi_look is
11744     select elp.eligy_prfl_id,
11745            elp.business_group_id
11746     from   ben_eligy_prfl_f elp
11747     where  p_effective_date
11748            between elp.effective_start_date
11749            and     elp.effective_end_date
11750     and    exists(select null
11751                   from   ben_elig_dpnt_cvrd_plip_f edi
11752                   where  p_effective_date
11753                          between edi.effective_start_date
11754                          and     edi.effective_end_date
11755                   and    edi.eligy_prfl_id = elp.eligy_prfl_id)
11756     order  by elp.eligy_prfl_id;
11757   --
11758   cursor c_elpedi_inst is
11759     select edi.eligy_prfl_id,
11760            edi.enrl_det_dt_cd,
11761            edi.plip_id,
11762            edi.excld_flag
11763     from   ben_elig_dpnt_cvrd_plip_f edi
11764     where  p_effective_date
11765            between edi.effective_start_date
11766            and     edi.effective_end_date
11767     order  by edi.eligy_prfl_id,
11768            decode(edi.excld_flag,'Y',1,2);
11769   --
11770   l_not_hash_found boolean;
11771   --
11772 begin
11773   --
11774   for objlook in c_elpedi_look loop
11775     --
11776     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
11777     --
11778     -- Check if hashed value is already allocated
11779     --
11780     if g_cache_elpedi_lookup.exists(l_id) then
11781       --
11782       l_not_hash_found := false;
11783       --
11784       -- Loop until un-allocated has value is derived
11785       --
11786       while not l_not_hash_found loop
11787         --
11788         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11789         --
11790         -- Check if the hash index exists, if not we can use it
11791         --
11792         if not g_cache_elpedi_lookup.exists(l_id) then
11793           --
11794           -- Lets store the hash value in the index
11795           --
11796           l_not_hash_found := true;
11797           exit;
11798           --
11799         else
11800           --
11801           l_not_hash_found := false;
11802           --
11803         end if;
11804         --
11805       end loop;
11806       --
11807     end if;
11808     --
11809     g_cache_elpedi_lookup(l_id).id := objlook.eligy_prfl_id;
11810     g_cache_elpedi_lookup(l_id).fk_id := objlook.business_group_id;
11811     --
11812   end loop;
11813   --
11814   l_torrwnum := 0;
11815   l_prev_id := -1;
11816   --
11817   for objinst in c_elpedi_inst loop
11818     --
11819     -- Populate the cache lookup details
11820     --
11821     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
11822     --
11823     -- Check if hashed value is already allocated
11824     --
11825     if g_cache_elpedi_lookup(l_id).id = objinst.eligy_prfl_id then
11826       --
11827       null;
11828       --
11829     else
11830       --
11831       loop
11832         --
11833         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
11834         --
11835         if g_cache_elpedi_lookup(l_id).id = objinst.eligy_prfl_id then
11836           --
11837           exit;
11838           --
11839         end if;
11840         --
11841       end loop;
11842       --
11843     end if;
11844     --
11845     -- Check for first row
11846     --
11847     if l_prev_id = -1 then
11848       --
11849       g_cache_elpedi_lookup(l_id).starttorele_num := l_torrwnum;
11850       --
11851     elsif l_id <> l_prev_id then
11852       --
11853       g_cache_elpedi_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11854       g_cache_elpedi_lookup(l_id).starttorele_num := l_torrwnum;
11855       --
11856     end if;
11857     --
11858     -- Populate the cache instance details
11859     --
11860     g_cache_elpedi_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
11861     g_cache_elpedi_inst(l_torrwnum).excld_flag := objinst.excld_flag;
11862     g_cache_elpedi_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
11863     g_cache_elpedi_inst(l_torrwnum).plip_id := objinst.plip_id;
11864     --
11865     l_torrwnum := l_torrwnum+1;
11866     l_prev_id := l_id;
11867     --
11868   end loop;
11869   --
11870   g_cache_elpedi_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
11871   --
11872 end elpedi_writecache;
11873 --
11874 procedure elpedi_getcacdets
11875   (p_effective_date    in date,
11876    p_business_group_id in number,
11877    p_eligy_prfl_id     in number,
11878    p_refresh_cache     in boolean default FALSE,
11879    p_inst_set          out nocopy ben_elp_cache.g_cache_elpedi_instor,
11880    p_inst_count        out nocopy number) is
11881   --
11882   l_proc varchar2(72) :=  'elpedi_getcacdets';
11883   l_torrwnum pls_integer;
11884   l_insttorrw_num pls_integer;
11885   l_index         pls_integer;
11886   --
11887   l_not_hash_found boolean;
11888   --
11889 begin
11890   --
11891   -- Flush the cache
11892   --
11893   if p_refresh_cache then
11894     --
11895     g_cache_elpedi_lookup.delete;
11896     g_cache_elpedi_inst.delete;
11897     --
11898   end if;
11899   --
11900   -- Populate the global cache
11901   --
11902   if g_cache_elpedi_lookup.count = 0 then
11903     --
11904     -- Build the cache
11905     --
11906     ben_elp_cache.elpedi_writecache
11907       (p_effective_date => p_effective_date,
11908        p_refresh_cache  => p_refresh_cache);
11909     --
11910   end if;
11911   --
11912   -- Get the instance details
11913   --
11914   l_torrwnum := 0;
11915   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
11916   --
11917   -- Check if hashed value is already allocated
11918   --
11919   if g_cache_elpedi_lookup.exists(l_index) then
11920     --
11921     -- If it does exist make sure its the right one
11922     --
11923     if g_cache_elpedi_lookup(l_index).id <> p_eligy_prfl_id then
11924       --
11925       l_not_hash_found := false;
11926       --
11927       -- Loop until un-allocated has value is derived
11928       --
11929       while not l_not_hash_found loop
11930         --
11931         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
11932         --
11933         -- Check if the hash index exists, if not we can use it
11934         --
11935         if not g_cache_elpedi_lookup.exists(l_index) then
11936           --
11937           -- Lets store the hash value in the index
11938           --
11939           l_not_hash_found := true;
11940           exit;
11941           --
11942         else
11943           --
11944           l_not_hash_found := false;
11945           --
11946         end if;
11947         --
11948       end loop;
11949       --
11950     end if;
11951     --
11952   end if;
11953   --
11954   for l_insttorrw_num in g_cache_elpedi_lookup(l_index).starttorele_num ..
11955     g_cache_elpedi_lookup(l_index).endtorele_num loop
11956     --
11957     p_inst_set(l_torrwnum) := g_cache_elpedi_inst(l_insttorrw_num);
11958     l_torrwnum := l_torrwnum+1;
11959     --
11960   end loop;
11961   --
11962   p_inst_count := l_torrwnum;
11963   --
11964 exception
11965   --
11966   when no_data_found then
11967     --
11968     p_inst_count := 0;
11969     --
11970 end elpedi_getcacdets;
11971 --
11972 procedure elpeet_writecache
11973   (p_effective_date in date,
11974    p_refresh_cache  in boolean default FALSE) is
11975   --
11976   l_proc varchar2(72) :=  'elpeet_writecache';
11977   l_torrwnum pls_integer;
11978   l_prev_id number;
11979   l_id number;
11980   --
11981   cursor c_elpeet_look is
11982     select elp.eligy_prfl_id,
11983            elp.business_group_id
11984     from   ben_eligy_prfl_f elp
11985     where  p_effective_date
11986            between elp.effective_start_date
11987            and     elp.effective_end_date
11988     and    exists(select null
11989                   from   ben_elig_enrld_anthr_ptip_f eet
11990                   where  p_effective_date
11991                          between eet.effective_start_date
11992                          and     eet.effective_end_date
11993                   and    eet.eligy_prfl_id = elp.eligy_prfl_id)
11994     order  by elp.eligy_prfl_id;
11995   --
11996   cursor c_elpeet_inst is
11997     select eet.eligy_prfl_id,
11998            eet.excld_flag,
11999            eet.enrl_det_dt_cd,
12000            eet.only_pls_subj_cobra_flag,
12001            eet.ptip_id
12002     from   ben_elig_enrld_anthr_ptip_f eet
12003     where  p_effective_date
12004            between eet.effective_start_date
12005            and     eet.effective_end_date
12006     order  by eet.eligy_prfl_id,
12007            decode(eet.excld_flag,'Y',1,2);
12008   --
12009   l_not_hash_found boolean;
12010   --
12011 begin
12012   --
12013   for objlook in c_elpeet_look loop
12014     --
12015     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
12016     --
12017     -- Check if hashed value is already allocated
12018     --
12019     if g_cache_elpeet_lookup.exists(l_id) then
12020       --
12021       l_not_hash_found := false;
12022       --
12023       -- Loop until un-allocated has value is derived
12024       --
12025       while not l_not_hash_found loop
12026         --
12027         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12028         --
12029         -- Check if the hash index exists, if not we can use it
12030         --
12031         if not g_cache_elpeet_lookup.exists(l_id) then
12032           --
12033           -- Lets store the hash value in the index
12034           --
12035           l_not_hash_found := true;
12036           exit;
12037           --
12038         else
12039           --
12040           l_not_hash_found := false;
12041           --
12042         end if;
12043         --
12044       end loop;
12045       --
12046     end if;
12047     --
12048     g_cache_elpeet_lookup(l_id).id := objlook.eligy_prfl_id;
12049     g_cache_elpeet_lookup(l_id).fk_id := objlook.business_group_id;
12050     --
12051   end loop;
12052   --
12053   l_torrwnum := 0;
12054   l_prev_id := -1;
12055   --
12056   for objinst in c_elpeet_inst loop
12057     --
12058     -- Populate the cache lookup details
12059     --
12060     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
12061     --
12062     -- Check if hashed value is already allocated
12063     --
12064     if g_cache_elpeet_lookup(l_id).id = objinst.eligy_prfl_id then
12065       --
12066       null;
12067       --
12068     else
12069       --
12070       loop
12071         --
12072         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12073         --
12074         if g_cache_elpeet_lookup(l_id).id = objinst.eligy_prfl_id then
12075           --
12076           exit;
12077           --
12078         end if;
12079         --
12080       end loop;
12081       --
12082     end if;
12083     --
12084     -- Check for first row
12085     --
12086     if l_prev_id = -1 then
12087       --
12088       g_cache_elpeet_lookup(l_id).starttorele_num := l_torrwnum;
12089       --
12090     elsif l_id <> l_prev_id then
12091       --
12092       g_cache_elpeet_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12093       g_cache_elpeet_lookup(l_id).starttorele_num := l_torrwnum;
12094       --
12095     end if;
12096     --
12097     -- Populate the cache instance details
12098     --
12099     g_cache_elpeet_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
12100     g_cache_elpeet_inst(l_torrwnum).excld_flag := objinst.excld_flag;
12101     g_cache_elpeet_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
12102     g_cache_elpeet_inst(l_torrwnum).only_pls_subj_cobra_flag := objinst.only_pls_subj_cobra_flag;
12103     g_cache_elpeet_inst(l_torrwnum).ptip_id := objinst.ptip_id;
12104     --
12105     l_torrwnum := l_torrwnum+1;
12106     l_prev_id := l_id;
12107     --
12108   end loop;
12109   --
12110   g_cache_elpeet_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12111   --
12112 end elpeet_writecache;
12113 --
12114 procedure elpeet_getcacdets
12115   (p_effective_date    in date,
12116    p_business_group_id in number,
12117    p_eligy_prfl_id     in number,
12118    p_refresh_cache     in boolean default FALSE,
12119    p_inst_set          out nocopy ben_elp_cache.g_cache_elpeet_instor,
12120    p_inst_count        out nocopy number) is
12121   --
12122   l_proc varchar2(72) :=  'elpeet_getcacdets';
12123   l_torrwnum pls_integer;
12124   l_insttorrw_num pls_integer;
12125   l_index         pls_integer;
12126   --
12127   l_not_hash_found boolean;
12128   --
12129 begin
12130   --
12131   -- Flush the cache
12132   --
12133   if p_refresh_cache then
12134     --
12135     g_cache_elpeet_lookup.delete;
12136     g_cache_elpeet_inst.delete;
12137     --
12138   end if;
12139   --
12140   -- Populate the global cache
12141   --
12142   if g_cache_elpeet_lookup.count = 0 then
12143     --
12144     -- Build the cache
12145     --
12146     ben_elp_cache.elpeet_writecache
12147       (p_effective_date => p_effective_date,
12148        p_refresh_cache  => p_refresh_cache);
12149     --
12150   end if;
12151   --
12152   -- Get the instance details
12153   --
12154   l_torrwnum := 0;
12155   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
12156   --
12157   -- Check if hashed value is already allocated
12158   --
12159   if g_cache_elpeet_lookup.exists(l_index) then
12160     --
12161     -- If it does exist make sure its the right one
12162     --
12163     if g_cache_elpeet_lookup(l_index).id <> p_eligy_prfl_id then
12164       --
12165       l_not_hash_found := false;
12166       --
12167       -- Loop until un-allocated has value is derived
12168       --
12169       while not l_not_hash_found loop
12170         --
12171         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
12172         --
12173         -- Check if the hash index exists, if not we can use it
12174         --
12175         if not g_cache_elpeet_lookup.exists(l_index) then
12176           --
12177           -- Lets store the hash value in the index
12178           --
12179           l_not_hash_found := true;
12180           exit;
12181           --
12182         else
12183           --
12184           l_not_hash_found := false;
12185           --
12186         end if;
12187         --
12188       end loop;
12189       --
12190     end if;
12191     --
12192   end if;
12193   --
12194   for l_insttorrw_num in g_cache_elpeet_lookup(l_index).starttorele_num ..
12195     g_cache_elpeet_lookup(l_index).endtorele_num loop
12196     --
12197     p_inst_set(l_torrwnum) := g_cache_elpeet_inst(l_insttorrw_num);
12198     l_torrwnum := l_torrwnum+1;
12199     --
12200   end loop;
12201   --
12202   p_inst_count := l_torrwnum;
12203   --
12204 exception
12205   --
12206   when no_data_found then
12207     --
12208     p_inst_count := 0;
12209     --
12210 end elpeet_getcacdets;
12211 --
12212 procedure elpedt_writecache
12213   (p_effective_date in date,
12214    p_refresh_cache  in boolean default FALSE) is
12215   --
12216   l_proc varchar2(72) :=  'elpedt_writecache';
12217   l_torrwnum pls_integer;
12218   l_prev_id number;
12219   l_id number;
12220   --
12221   cursor c_elpedt_look is
12222     select elp.eligy_prfl_id,
12223            elp.business_group_id
12224     from   ben_eligy_prfl_f elp
12225     where  p_effective_date
12226            between elp.effective_start_date
12227            and     elp.effective_end_date
12228     and    exists(select null
12229                   from   ben_elig_dpnt_cvrd_othr_ptip_f edt
12230                   where  p_effective_date
12231                          between edt.effective_start_date
12232                          and     edt.effective_end_date
12233                   and    edt.eligy_prfl_id = elp.eligy_prfl_id)
12234     order  by elp.eligy_prfl_id;
12235   --
12236   cursor c_elpedt_inst is
12237     select edt.eligy_prfl_id,
12238            edt.excld_flag,
12239            edt.enrl_det_dt_cd,
12240            edt.only_pls_subj_cobra_flag,
12241            edt.ptip_id
12242     from   ben_elig_dpnt_cvrd_othr_ptip_f edt
12243     where  p_effective_date
12244            between edt.effective_start_date
12245            and     edt.effective_end_date
12246     order  by edt.eligy_prfl_id,
12247            decode(edt.excld_flag,'Y',1,2);
12248   --
12249   l_not_hash_found boolean;
12250   --
12251 begin
12252   --
12253   for objlook in c_elpedt_look loop
12254     --
12255     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
12256     --
12257     -- Check if hashed value is already allocated
12258     --
12259     if g_cache_elpedt_lookup.exists(l_id) then
12260       --
12261       l_not_hash_found := false;
12262       --
12263       -- Loop until un-allocated has value is derived
12264       --
12265       while not l_not_hash_found loop
12266         --
12267         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12268         --
12269         -- Check if the hash index exists, if not we can use it
12270         --
12271         if not g_cache_elpedt_lookup.exists(l_id) then
12272           --
12273           -- Lets store the hash value in the index
12274           --
12275           l_not_hash_found := true;
12276           exit;
12277           --
12278         else
12279           --
12280           l_not_hash_found := false;
12281           --
12282         end if;
12283         --
12284       end loop;
12285       --
12286     end if;
12287     --
12288     g_cache_elpedt_lookup(l_id).id := objlook.eligy_prfl_id;
12289     g_cache_elpedt_lookup(l_id).fk_id := objlook.business_group_id;
12290     --
12291   end loop;
12292   --
12293   l_torrwnum := 0;
12294   l_prev_id := -1;
12295   --
12296   for objinst in c_elpedt_inst loop
12297     --
12298     -- Populate the cache lookup details
12299     --
12300     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
12301     --
12302     -- Check if hashed value is already allocated
12303     --
12304     if g_cache_elpedt_lookup(l_id).id = objinst.eligy_prfl_id then
12305       --
12306       null;
12307       --
12308     else
12309       --
12310       loop
12311         --
12312         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12313         --
12314         if g_cache_elpedt_lookup(l_id).id = objinst.eligy_prfl_id then
12315           --
12316           exit;
12317           --
12318         end if;
12319         --
12320       end loop;
12321       --
12322     end if;
12323     --
12324     -- Check for first row
12325     --
12326     if l_prev_id = -1 then
12327       --
12328       g_cache_elpedt_lookup(l_id).starttorele_num := l_torrwnum;
12329       --
12330     elsif l_id <> l_prev_id then
12331       --
12332       g_cache_elpedt_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12333       g_cache_elpedt_lookup(l_id).starttorele_num := l_torrwnum;
12334       --
12335     end if;
12336     --
12337     -- Populate the cache instance details
12338     --
12339     g_cache_elpedt_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
12340     g_cache_elpedt_inst(l_torrwnum).excld_flag := objinst.excld_flag;
12341     g_cache_elpedt_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
12342     g_cache_elpedt_inst(l_torrwnum).only_pls_subj_cobra_flag := objinst.only_pls_subj_cobra_flag;
12343     g_cache_elpedt_inst(l_torrwnum).ptip_id := objinst.ptip_id;
12344     --
12345     l_torrwnum := l_torrwnum+1;
12346     l_prev_id := l_id;
12347     --
12348   end loop;
12349   --
12350   g_cache_elpedt_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12351   --
12352 end elpedt_writecache;
12353 --
12354 procedure elpedt_getcacdets
12355   (p_effective_date    in date,
12356    p_business_group_id in number,
12357    p_eligy_prfl_id     in number,
12358    p_refresh_cache     in boolean default FALSE,
12359    p_inst_set          out nocopy ben_elp_cache.g_cache_elpedt_instor,
12360    p_inst_count        out nocopy number) is
12361   --
12362   l_proc varchar2(72) :=  'elpedt_getcacdets';
12363   l_torrwnum pls_integer;
12364   l_insttorrw_num pls_integer;
12365   l_index         pls_integer;
12366   --
12367   l_not_hash_found boolean;
12368   --
12369 begin
12370   --
12371   -- Flush the cache
12372   --
12373   if p_refresh_cache then
12374     --
12375     g_cache_elpedt_lookup.delete;
12376     g_cache_elpedt_inst.delete;
12377     --
12378   end if;
12379   --
12380   -- Populate the global cache
12381   --
12382   if g_cache_elpedt_lookup.count = 0 then
12383     --
12384     -- Build the cache
12385     --
12386     ben_elp_cache.elpedt_writecache
12387       (p_effective_date => p_effective_date,
12388        p_refresh_cache  => p_refresh_cache);
12389     --
12390   end if;
12391   --
12392   -- Get the instance details
12393   --
12394   l_torrwnum := 0;
12395   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
12396   --
12397   -- Check if hashed value is already allocated
12398   --
12399   if g_cache_elpedt_lookup.exists(l_index) then
12400     --
12401     -- If it does exist make sure its the right one
12402     --
12403     if g_cache_elpedt_lookup(l_index).id <> p_eligy_prfl_id then
12404       --
12405       l_not_hash_found := false;
12406       --
12407       -- Loop until un-allocated has value is derived
12408       --
12409       while not l_not_hash_found loop
12410         --
12411         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
12412         --
12413         -- Check if the hash index exists, if not we can use it
12414         --
12415         if not g_cache_elpedt_lookup.exists(l_index) then
12416           --
12417           -- Lets store the hash value in the index
12418           --
12419           l_not_hash_found := true;
12420           exit;
12421           --
12422         else
12423           --
12424           l_not_hash_found := false;
12425           --
12426         end if;
12427         --
12428       end loop;
12429       --
12430     end if;
12431     --
12432   end if;
12433   --
12434   for l_insttorrw_num in g_cache_elpedt_lookup(l_index).starttorele_num ..
12435     g_cache_elpedt_lookup(l_index).endtorele_num loop
12436     --
12437     p_inst_set(l_torrwnum) := g_cache_elpedt_inst(l_insttorrw_num);
12438     l_torrwnum := l_torrwnum+1;
12439     --
12440   end loop;
12441   --
12442   p_inst_count := l_torrwnum;
12443   --
12444 exception
12445   --
12446   when no_data_found then
12447     --
12448     p_inst_count := 0;
12449     --
12450 end elpedt_getcacdets;
12451 --
12452 procedure elpedg_writecache
12453   (p_effective_date in date,
12454    p_refresh_cache  in boolean default FALSE) is
12455   --
12456   l_proc varchar2(72) :=  'elpedg_writecache';
12457   l_torrwnum pls_integer;
12458   l_prev_id number;
12459   l_id number;
12460   --
12461   cursor c_elpedg_look is
12462     select elp.eligy_prfl_id,
12463            elp.business_group_id
12464     from   ben_eligy_prfl_f elp
12465     where  p_effective_date
12466            between elp.effective_start_date
12467            and     elp.effective_end_date
12468     and    exists(select null
12469                   from   ben_elig_dpnt_cvrd_othr_pgm_f edg
12470                   where  p_effective_date
12471                          between edg.effective_start_date
12472                          and     edg.effective_end_date
12473                   and    edg.eligy_prfl_id = elp.eligy_prfl_id)
12474     order  by elp.eligy_prfl_id;
12475   --
12476   cursor c_elpedg_inst is
12477     select edg.eligy_prfl_id,
12478            edg.excld_flag,
12479            edg.enrl_det_dt_cd,
12480            edg.pgm_id
12481     from   ben_elig_dpnt_cvrd_othr_pgm_f edg
12482     where  p_effective_date
12483            between edg.effective_start_date
12484            and     edg.effective_end_date
12485     order  by edg.eligy_prfl_id,
12486            decode(edg.excld_flag,'Y',1,2);
12487   --
12488   l_not_hash_found boolean;
12489   --
12490 begin
12491   --
12492   for objlook in c_elpedg_look loop
12493     --
12494     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
12495     --
12496     -- Check if hashed value is already allocated
12497     --
12498     if g_cache_elpedg_lookup.exists(l_id) then
12499       --
12500       l_not_hash_found := false;
12501       --
12502       -- Loop until un-allocated has value is derived
12503       --
12504       while not l_not_hash_found loop
12505         --
12506         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12507         --
12508         -- Check if the hash index exists, if not we can use it
12509         --
12510         if not g_cache_elpedg_lookup.exists(l_id) then
12511           --
12512           -- Lets store the hash value in the index
12513           --
12514           l_not_hash_found := true;
12515           exit;
12516           --
12517         else
12518           --
12519           l_not_hash_found := false;
12520           --
12521         end if;
12522         --
12523       end loop;
12524       --
12525     end if;
12526     --
12527     g_cache_elpedg_lookup(l_id).id := objlook.eligy_prfl_id;
12528     g_cache_elpedg_lookup(l_id).fk_id := objlook.business_group_id;
12529     --
12530   end loop;
12531   --
12532   l_torrwnum := 0;
12533   l_prev_id := -1;
12534   --
12535   for objinst in c_elpedg_inst loop
12536     --
12537     -- Populate the cache lookup details
12538     --
12539     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
12540     --
12541     -- Check if hashed value is already allocated
12542     --
12543     if g_cache_elpedg_lookup(l_id).id = objinst.eligy_prfl_id then
12544       --
12545       null;
12546       --
12547     else
12548       --
12549       loop
12550         --
12551         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12552         --
12553         if g_cache_elpedg_lookup(l_id).id = objinst.eligy_prfl_id then
12554           --
12555           exit;
12556           --
12557         end if;
12558         --
12559       end loop;
12560       --
12561     end if;
12562     --
12563     -- Check for first row
12564     --
12565     if l_prev_id = -1 then
12566       --
12567       g_cache_elpedg_lookup(l_id).starttorele_num := l_torrwnum;
12568       --
12569     elsif l_id <> l_prev_id then
12570       --
12571       g_cache_elpedg_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12572       g_cache_elpedg_lookup(l_id).starttorele_num := l_torrwnum;
12573       --
12574     end if;
12575     --
12576     -- Populate the cache instance details
12577     --
12578     g_cache_elpedg_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
12579     g_cache_elpedg_inst(l_torrwnum).excld_flag := objinst.excld_flag;
12580     g_cache_elpedg_inst(l_torrwnum).enrl_det_dt_cd := objinst.enrl_det_dt_cd;
12581     g_cache_elpedg_inst(l_torrwnum).pgm_id := objinst.pgm_id;
12582     --
12583     l_torrwnum := l_torrwnum+1;
12584     l_prev_id := l_id;
12585     --
12586   end loop;
12587   --
12588   g_cache_elpedg_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12589   --
12590 end elpedg_writecache;
12591 --
12592 procedure elpedg_getcacdets
12593   (p_effective_date    in date,
12594    p_business_group_id in number,
12595    p_eligy_prfl_id     in number,
12596    p_refresh_cache     in boolean default FALSE,
12597    p_inst_set          out nocopy ben_elp_cache.g_cache_elpedg_instor,
12598    p_inst_count        out nocopy number) is
12599   --
12600   l_proc varchar2(72) :=  'elpedg_getcacdets';
12601   l_torrwnum pls_integer;
12602   l_insttorrw_num pls_integer;
12603   l_index         pls_integer;
12604   --
12605   l_not_hash_found boolean;
12606   --
12607 begin
12608   --
12609   -- Flush the cache
12610   --
12611   if p_refresh_cache then
12612     --
12613     g_cache_elpedg_lookup.delete;
12614     g_cache_elpedg_inst.delete;
12615     --
12616   end if;
12617   --
12618   -- Populate the global cache
12619   --
12620   if g_cache_elpedg_lookup.count = 0 then
12621     --
12622     -- Build the cache
12623     --
12624     ben_elp_cache.elpedg_writecache
12625       (p_effective_date => p_effective_date,
12626        p_refresh_cache  => p_refresh_cache);
12627     --
12628   end if;
12629   --
12630   -- Get the instance details
12631   --
12632   l_torrwnum := 0;
12633   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
12634   --
12635   -- Check if hashed value is already allocated
12636   --
12637   if g_cache_elpedg_lookup.exists(l_index) then
12638     --
12639     -- If it does exist make sure its the right one
12640     --
12641     if g_cache_elpedg_lookup(l_index).id <> p_eligy_prfl_id then
12642       --
12643       l_not_hash_found := false;
12644       --
12645       -- Loop until un-allocated has value is derived
12646       --
12647       while not l_not_hash_found loop
12648         --
12649         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
12650         --
12651         -- Check if the hash index exists, if not we can use it
12652         --
12653         if not g_cache_elpedg_lookup.exists(l_index) then
12654           --
12655           -- Lets store the hash value in the index
12656           --
12657           l_not_hash_found := true;
12658           exit;
12659           --
12660         else
12661           --
12662           l_not_hash_found := false;
12663           --
12664         end if;
12665         --
12666       end loop;
12667       --
12668     end if;
12669     --
12670   end if;
12671   --
12672   for l_insttorrw_num in g_cache_elpedg_lookup(l_index).starttorele_num ..
12673     g_cache_elpedg_lookup(l_index).endtorele_num loop
12674     --
12675     p_inst_set(l_torrwnum) := g_cache_elpedg_inst(l_insttorrw_num);
12676     l_torrwnum := l_torrwnum+1;
12677     --
12678   end loop;
12679   --
12680   p_inst_count := l_torrwnum;
12681   --
12682 exception
12683   --
12684   when no_data_found then
12685     --
12686     p_inst_count := 0;
12687     --
12688 end elpedg_getcacdets;
12689 --
12690 procedure elpecq_writecache
12691   (p_effective_date in date,
12692    p_refresh_cache  in boolean default FALSE) is
12693   --
12694   l_proc varchar2(72) :=  'elpecq_writecache';
12695   l_torrwnum pls_integer;
12696   l_prev_id number;
12697   l_id number;
12698   --
12699   cursor c_elpecq_look is
12700     select elp.eligy_prfl_id,
12701            elp.business_group_id
12702     from   ben_eligy_prfl_f elp
12703     where  p_effective_date
12704            between elp.effective_start_date
12705            and     elp.effective_end_date
12706     and    exists(select null
12707                   from   ben_elig_cbr_quald_bnf_f ecq
12708                   where  p_effective_date
12709                          between ecq.effective_start_date
12710                          and     ecq.effective_end_date
12711                   and    ecq.eligy_prfl_id = elp.eligy_prfl_id)
12712     order  by elp.eligy_prfl_id;
12713   --
12714   cursor c_elpecq_inst is
12715     select ecq.eligy_prfl_id,
12716            ecq.elig_cbr_quald_bnf_id pk_id,
12717            'ECQ' short_code,
12718            ecq.quald_bnf_flag,
12719            ecq.pgm_id, -- lamc added 2 fields
12720            ecq.ptip_id,
12721            ecq.criteria_score,
12722            ecq.criteria_weight
12723     from   ben_elig_cbr_quald_bnf_f ecq
12724     where  p_effective_date
12725            between ecq.effective_start_date
12726            and     ecq.effective_end_date
12727     order  by ecq.eligy_prfl_id;
12728   --
12729   l_not_hash_found boolean;
12730   --
12731 begin
12732   --
12733   for objlook in c_elpecq_look loop
12734     --
12735     l_id := ben_hash_utility.get_hashed_index(p_id => objlook.eligy_prfl_id);
12736     --
12737     -- Check if hashed value is already allocated
12738     --
12739     if g_cache_elpecq_lookup.exists(l_id) then
12740       --
12741       l_not_hash_found := false;
12742       --
12743       -- Loop until un-allocated has value is derived
12744       --
12745       while not l_not_hash_found loop
12746         --
12747         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12748         --
12749         -- Check if the hash index exists, if not we can use it
12750         --
12751         if not g_cache_elpecq_lookup.exists(l_id) then
12752           --
12753           -- Lets store the hash value in the index
12754           --
12755           l_not_hash_found := true;
12756           exit;
12757           --
12758         else
12759           --
12760           l_not_hash_found := false;
12761           --
12762         end if;
12763         --
12764       end loop;
12765       --
12766     end if;
12767     --
12768     g_cache_elpecq_lookup(l_id).id := objlook.eligy_prfl_id;
12769     g_cache_elpecq_lookup(l_id).fk_id := objlook.business_group_id;
12770     --
12771   end loop;
12772   --
12773   l_torrwnum := 0;
12774   l_prev_id := -1;
12775   --
12776   for objinst in c_elpecq_inst loop
12777     --
12778     -- Populate the cache lookup details
12779     --
12780     l_id := ben_hash_utility.get_hashed_index(p_id => objinst.eligy_prfl_id);
12781     --
12782     -- Check if hashed value is already allocated
12783     --
12784     if g_cache_elpecq_lookup(l_id).id = objinst.eligy_prfl_id then
12785       --
12786       null;
12787       --
12788     else
12789       --
12790       loop
12791         --
12792         l_id := ben_hash_utility.get_next_hash_index(p_hash_index => l_id);
12793         --
12794         if g_cache_elpecq_lookup(l_id).id = objinst.eligy_prfl_id then
12795           --
12796           exit;
12797           --
12798         end if;
12799         --
12800       end loop;
12801       --
12802     end if;
12803     --
12804     -- Check for first row
12805     --
12806     if l_prev_id = -1 then
12807       --
12808       g_cache_elpecq_lookup(l_id).starttorele_num := l_torrwnum;
12809       --
12810     elsif l_id <> l_prev_id then
12811       --
12812       g_cache_elpecq_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12813       g_cache_elpecq_lookup(l_id).starttorele_num := l_torrwnum;
12814       --
12815     end if;
12816     --
12817     -- Populate the cache instance details
12818     --
12819     g_cache_elpecq_inst(l_torrwnum).eligy_prfl_id := objinst.eligy_prfl_id;
12820     g_cache_elpecq_inst(l_torrwnum).pk_id := objinst.pk_id;
12821     g_cache_elpecq_inst(l_torrwnum).short_code := objinst.short_code;
12822     g_cache_elpecq_inst(l_torrwnum).criteria_score := objinst.criteria_score;
12823     g_cache_elpecq_inst(l_torrwnum).criteria_weight := objinst.criteria_weight;
12824     g_cache_elpecq_inst(l_torrwnum).quald_bnf_flag := objinst.quald_bnf_flag;
12825     -- lamc added these 2 lines:
12826     g_cache_elpecq_inst(l_torrwnum).pgm_id := objinst.pgm_id;
12827     g_cache_elpecq_inst(l_torrwnum).ptip_id := objinst.ptip_id;
12828     --
12829     l_torrwnum := l_torrwnum+1;
12830     l_prev_id := l_id;
12831     --
12832   end loop;
12833   --
12834   g_cache_elpecq_lookup(l_prev_id).endtorele_num := l_torrwnum-1;
12835   --
12836 end elpecq_writecache;
12837 --
12838 procedure elpecq_getcacdets
12839   (p_effective_date    in date,
12840    p_business_group_id in number,
12841    p_eligy_prfl_id     in number,
12842    p_refresh_cache     in boolean default FALSE,
12843    p_inst_set          out nocopy ben_elp_cache.g_cache_elpecq_instor,
12844    p_inst_count        out nocopy number) is
12845   --
12846   l_proc varchar2(72) :=  'elpecq_getcacdets';
12847   l_torrwnum pls_integer;
12848   l_insttorrw_num pls_integer;
12849   l_index         pls_integer;
12850   --
12851   l_not_hash_found boolean;
12852   --
12853 begin
12854   --
12855   -- Flush the cache
12856   --
12857   if p_refresh_cache then
12858     --
12859     g_cache_elpecq_lookup.delete;
12860     g_cache_elpecq_inst.delete;
12861     --
12862   end if;
12863   --
12864   -- Populate the global cache
12865   --
12866   if g_cache_elpecq_lookup.count = 0 then
12867     --
12868     -- Build the cache
12869     --
12870     ben_elp_cache.elpecq_writecache
12871       (p_effective_date => p_effective_date,
12872        p_refresh_cache  => p_refresh_cache);
12873     --
12874   end if;
12875   --
12876   -- Get the instance details
12877   --
12878   l_torrwnum := 0;
12879   l_index := ben_hash_utility.get_hashed_index(p_id => p_eligy_prfl_id);
12880   --
12881   -- Check if hashed value is already allocated
12882   --
12883   if g_cache_elpecq_lookup.exists(l_index) then
12884     --
12885     -- If it does exist make sure its the right one
12886     --
12887     if g_cache_elpecq_lookup(l_index).id <> p_eligy_prfl_id then
12888       --
12889       l_not_hash_found := false;
12890       --
12891       -- Loop until un-allocated has value is derived
12892       --
12893       while not l_not_hash_found loop
12894         --
12895         l_index := ben_hash_utility.get_next_hash_index(p_hash_index => l_index);
12896         --
12897         -- Check if the hash index exists, if not we can use it
12898         --
12899         if not g_cache_elpecq_lookup.exists(l_index) then
12900           --
12901           -- Lets store the hash value in the index
12902           --
12903           l_not_hash_found := true;
12904           exit;
12905           --
12906         else
12907           --
12908           l_not_hash_found := false;
12909           --
12910         end if;
12911         --
12912       end loop;
12913       --
12914     end if;
12915     --
12916   end if;
12917   --
12918   for l_insttorrw_num in g_cache_elpecq_lookup(l_index).starttorele_num ..
12919     g_cache_elpecq_lookup(l_index).endtorele_num loop
12920     --
12921     p_inst_set(l_torrwnum) := g_cache_elpecq_inst(l_insttorrw_num);
12922     l_torrwnum := l_torrwnum+1;
12923     --
12924   end loop;
12925   --
12926   p_inst_count := l_torrwnum;
12927   --
12928 exception
12929   --
12930   when no_data_found then
12931     --
12932     p_inst_count := 0;
12933     --
12934 end elpecq_getcacdets;
12935 -- ---------------------------------------------------------------------
12936 -- eligibility profile - Disability
12937 -- ---------------------------------------------------------------------
12938 procedure elpeds_getdets
12939   (p_effective_date in     date
12940   ,p_eligy_prfl_id  in     number
12941   --
12942   ,p_inst_set       in out nocopy g_elp_cache
12943   )
12944 is
12945   --
12946   l_proc varchar2(72) := g_package||'.elpeds_getdets';
12947   --
12948   l_inst_set     g_elp_cache := g_elp_cache();
12949   --
12950   l_elenum       pls_integer;
12951   --
12952   cursor c_instance
12953     (c_eligy_prfl_id  number
12954     ,c_effective_date date
12955     )
12956   is
12957     select tab.eligy_prfl_id,
12958            tab.elig_dsbld_prte_id pk_id,
12959            'EDB' short_code,
12960            tab.dsbld_cd,
12961            tab.excld_flag,
12962            tab.criteria_score,
12963            tab.criteria_weight
12964     from   ben_elig_dsbld_prte_f tab
12965     where tab.eligy_prfl_id = c_eligy_prfl_id
12966       and c_effective_date
12967         between tab.effective_start_date and tab.effective_end_date
12968     order by tab.eligy_prfl_id,
12969              decode(tab.excld_flag,'Y',1,2);
12970   --
12971 begin
12972   --
12973   l_elenum := 1;
12974   --
12975   for instrow in c_instance
12976     (c_eligy_prfl_id  => p_eligy_prfl_id
12977     ,c_effective_date => p_effective_date
12978     )
12979   loop
12980     --
12981     l_inst_set.extend(1);
12982     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
12983     l_inst_set(l_elenum).pk_id         := instrow.pk_id;
12984     l_inst_set(l_elenum).short_code    := instrow.short_code;
12985     l_inst_set(l_elenum).criteria_score := instrow.criteria_score;
12986     l_inst_set(l_elenum).criteria_weight := instrow.criteria_weight;
12987     l_inst_set(l_elenum).v230_val      := instrow.dsbld_cd;
12988     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
12989     l_elenum := l_elenum+1;
12990     --
12991   end loop;
12992   --
12993   p_inst_set := l_inst_set;
12994   --
12995 exception
12996   --
12997   when no_data_found then
12998     --
12999     null;
13000     --
13001 end elpeds_getdets;
13002 --
13003 -- ---------------------------------------------------------------------
13004 -- eligibility profile - Tobacco use
13005 -- ---------------------------------------------------------------------
13006 procedure elpetu_getdets
13007   (p_effective_date in     date
13008   ,p_eligy_prfl_id  in     number
13009   --
13010   ,p_inst_set       in out nocopy g_elp_cache
13011   )
13012 is
13013   --
13014   l_proc varchar2(72) := g_package||'.elpetu_getdets';
13015   --
13016   l_inst_set     g_elp_cache := g_elp_cache();
13017   --
13018   l_elenum       pls_integer;
13019   --
13020   cursor c_instance
13021     (c_eligy_prfl_id  number
13022     ,c_effective_date date
13023     )
13024   is
13025     select tab.eligy_prfl_id,
13026            tab.elig_tbco_use_prte_id pk_id,
13027            'ETU' short_code,
13028            tab.uses_tbco_flag,
13029            tab.excld_flag,
13030            tab.criteria_score,
13031            tab.criteria_weight
13032     from   ben_elig_tbco_use_prte_f tab
13033     where tab.eligy_prfl_id = c_eligy_prfl_id
13034       and c_effective_date
13035         between tab.effective_start_date and tab.effective_end_date
13036     order by tab.eligy_prfl_id,
13037              decode(tab.excld_flag,'Y',1,2);
13038   --
13039 begin
13040   --
13041   l_elenum := 1;
13042   --
13043   for instrow in c_instance
13044     (c_eligy_prfl_id  => p_eligy_prfl_id
13045     ,c_effective_date => p_effective_date
13046     )
13047   loop
13048     --
13049     l_inst_set.extend(1);
13050     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13051     l_inst_set(l_elenum).v230_val      := instrow.uses_tbco_flag;
13052     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
13053      --start 4446984
13054     l_inst_set(l_elenum).short_code        := instrow.short_code;
13055     l_inst_set(l_elenum).pk_id             := instrow.pk_id;
13056     l_inst_set(l_elenum).criteria_score    := instrow.criteria_score;
13057     l_inst_set(l_elenum).criteria_weight   := instrow.criteria_weight;
13058     --end 4446984
13059     l_elenum := l_elenum+1;
13060     --
13061   end loop;
13062   --
13063   p_inst_set := l_inst_set;
13064   --
13065 exception
13066   --
13067   when no_data_found then
13068     --
13069     null;
13070     --
13071 end elpetu_getdets;
13072 --
13073 -- ---------------------------------------------------------------------
13074 -- eligibility profile - Total coverage volume
13075 -- ---------------------------------------------------------------------
13076 --
13077 procedure elpetc_getdets
13078   (p_effective_date in     date
13079   ,p_eligy_prfl_id  in     number
13080    --
13081   ,p_inst_set       in out nocopy g_elp_cache  ) is
13082   --
13083   l_proc varchar2(80) := g_package || '.elpetc_getdets';
13084   --
13085   l_inst_set     g_elp_cache := g_elp_cache();
13086   --
13087   l_elenum       pls_integer;
13088   --
13089   cursor c_instance
13090       (c_eligy_prfl_id  number
13091       ,c_effective_date date  ) is
13092        select etc.eligy_prfl_id
13093        	    , etc.mn_cvg_vol_amt
13094        	    , etc.mx_cvg_vol_amt
13095        	    , etc.no_mn_cvg_vol_amt_apls_flag
13096        	    , etc.no_mx_cvg_vol_amt_apls_flag
13097        from ben_elig_ttl_cvg_vol_prte_f etc
13098        where etc.eligy_prfl_id = c_eligy_prfl_id
13099 	 and c_effective_date
13100 	     between etc.effective_start_date and etc.effective_end_date
13101        order by etc.eligy_prfl_id;
13102   --
13103 begin
13104   --
13105   l_elenum := 1;
13106   --
13107   for instrow in c_instance
13108     (c_eligy_prfl_id  => p_eligy_prfl_id
13109     ,c_effective_date => p_effective_date
13110     )
13111   loop
13112     --
13113     l_inst_set.extend(1);
13114     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13115     l_inst_set(l_elenum).num_val       := instrow.mn_cvg_vol_amt;
13116     l_inst_set(l_elenum).num_val1      := instrow.mx_cvg_vol_amt;
13117     l_elenum := l_elenum+1;
13118     --
13119   end loop;
13120   --
13121   p_inst_set := l_inst_set;
13122   --
13123 exception
13124   --
13125   when no_data_found then
13126     --
13127     null ;
13128     --
13129 end;
13130 --
13131 -- ---------------------------------------------------------------------
13132 -- eligibility profile - Total participants
13133 -- ---------------------------------------------------------------------
13134 --
13135 procedure elpetp_getdets
13136   (p_effective_date in     date
13137   ,p_eligy_prfl_id  in     number
13138    --
13139   ,p_inst_set       in out nocopy g_elp_cache  ) is
13140   --
13141   l_proc varchar2(80) := g_package || '.elpetp_getdets';
13142   --
13143   l_inst_set     g_elp_cache := g_elp_cache();
13144   --
13145   l_elenum       pls_integer;
13146   --
13147   cursor c_instance
13148       (c_eligy_prfl_id  number
13149       ,c_effective_date date  ) is
13150        select etp.eligy_prfl_id
13151             , etp.mn_prtt_num
13152             , etp.mx_prtt_num
13153             , etp.no_mn_prtt_num_apls_flag
13154             , etp.no_mx_prtt_num_apls_flag
13155        from ben_elig_ttl_prtt_prte_f etp
13156        where etp.eligy_prfl_id = c_eligy_prfl_id
13157 	 and c_effective_date
13158 	     between etp.effective_start_date and etp.effective_end_date
13159        order by etp.eligy_prfl_id;
13160   --
13161 begin
13162   --
13163   l_elenum := 1;
13164   --
13165   for instrow in c_instance
13166     (c_eligy_prfl_id  => p_eligy_prfl_id
13167     ,c_effective_date => p_effective_date
13168     )
13169   loop
13170     --
13171     l_inst_set.extend(1);
13172     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13173     l_inst_set(l_elenum).num_val       := instrow.mn_prtt_num;
13174     l_inst_set(l_elenum).num_val1      := instrow.mx_prtt_num;
13175     l_elenum := l_elenum+1;
13176     --
13177   end loop;
13178   --
13179   p_inst_set := l_inst_set;
13180   --
13181 exception
13182   --
13183   when no_data_found then
13184     --
13185     null ;
13186     --
13187 end;
13188 --
13189 -- ---------------------------------------------------------------------
13190 -- eligibility profile - Participation in another plan
13191 -- ---------------------------------------------------------------------
13192 --
13193 procedure elpeop_getdets
13194   (p_effective_date in     date
13195   ,p_eligy_prfl_id  in     number
13196   --
13197   ,p_inst_set       in out nocopy g_elp_cache
13198   )
13199 is
13200   --
13201   l_proc varchar2(72) := g_package||'.elpeop_getdets';
13202   --
13203   l_inst_set     g_elp_cache := g_elp_cache();
13204   --
13205   l_elenum       pls_integer;
13206   --
13207   cursor c_instance
13208     (c_eligy_prfl_id  number
13209     ,c_effective_date date
13210     )
13211   is
13212     select tab.eligy_prfl_id,
13213            tab.pl_id,
13214            tab.excld_flag
13215     from   ben_elig_anthr_pl_prte_f tab
13216     where tab.eligy_prfl_id = c_eligy_prfl_id
13217       and c_effective_date
13218         between tab.effective_start_date and tab.effective_end_date
13219     order by tab.eligy_prfl_id,
13220              decode(tab.excld_flag,'Y',1,2);
13221   --
13222 begin
13223   --
13224   l_elenum := 1;
13225   --
13226   for instrow in c_instance
13227     (c_eligy_prfl_id  => p_eligy_prfl_id
13228     ,c_effective_date => p_effective_date
13229     )
13230   loop
13231     --
13232     l_inst_set.extend(1);
13233     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13234     l_inst_set(l_elenum).num_val       := instrow.pl_id;
13235     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
13236     l_elenum := l_elenum+1;
13237     --
13238   end loop;
13239   --
13240   p_inst_set := l_inst_set;
13241   --
13242 exception
13243   --
13244   when no_data_found then
13245     --
13246     null;
13247     --
13248 end elpeop_getdets;
13249 --
13250 -- ---------------------------------------------------------------------
13251 -- eligibility profile - Health Coverage Selected
13252 -- ---------------------------------------------------------------------
13253 --
13254 procedure elpehc_getdets
13255   (p_effective_date in     date
13256   ,p_eligy_prfl_id  in     number
13257   --
13258   ,p_inst_set       in out nocopy g_elp_cache
13259   )
13260 is
13261   --
13262   l_proc varchar2(72) := g_package||'.elpehc_getdets';
13263   --
13264   l_inst_set     g_elp_cache := g_elp_cache();
13265   --
13266   l_elenum       pls_integer;
13267   --
13268   cursor c_instance
13269     (c_eligy_prfl_id  number
13270     ,c_effective_date date
13271     )
13272   is
13273     select tab.eligy_prfl_id,
13274            tab.pl_typ_opt_typ_id,
13275            tab.oipl_id,
13276            tab.excld_flag
13277     from   ben_elig_hlth_cvg_prte_f tab
13278     where tab.eligy_prfl_id = c_eligy_prfl_id
13279       and c_effective_date
13280         between tab.effective_start_date and tab.effective_end_date
13281     order by tab.eligy_prfl_id,
13282              decode(tab.excld_flag,'Y',1,2);
13283   --
13284 begin
13285   --
13286   l_elenum := 1;
13287   --
13288   for instrow in c_instance
13289     (c_eligy_prfl_id  => p_eligy_prfl_id
13290     ,c_effective_date => p_effective_date
13291     )
13292   loop
13293     --
13294     l_inst_set.extend(1);
13295     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13296     l_inst_set(l_elenum).num_val       := instrow.pl_typ_opt_typ_id;
13297     l_inst_set(l_elenum).num_val1      := instrow.oipl_id;
13298     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
13299     l_elenum := l_elenum+1;
13300     --
13301   end loop;
13302   --
13303   p_inst_set := l_inst_set;
13304   --
13305 exception
13306   --
13307   when no_data_found then
13308     --
13309     null;
13310     --
13311 end elpehc_getdets;
13312 --
13313 -- ---------------------------------------------------------------------
13314 -- eligibility profile - Competency
13315 -- ---------------------------------------------------------------------
13316 --
13317 procedure elpecy_getdets
13318   (p_effective_date in     date
13319   ,p_eligy_prfl_id  in     number
13320   --
13321   ,p_inst_set       in out nocopy g_elp_cache
13322   )
13323 is
13324   --
13325   l_proc varchar2(72) := g_package||'.elpecy_getdets';
13326   --
13327   l_inst_set     g_elp_cache := g_elp_cache();
13328   --
13329   l_elenum       pls_integer;
13330   --
13331   cursor c_instance
13332     (c_eligy_prfl_id  number
13333     ,c_effective_date date
13334     )
13335   is
13336     select tab.eligy_prfl_id,
13337            tab.elig_comptncy_prte_id pk_id,
13338            'ECY' short_code,
13339            tab.competence_id,
13340            tab.rating_level_id,
13341            tab.excld_flag,
13342            tab.criteria_score,
13343            tab.criteria_weight
13344     from   ben_elig_comptncy_prte_f tab
13345     where tab.eligy_prfl_id = c_eligy_prfl_id
13346       and c_effective_date
13347         between tab.effective_start_date and tab.effective_end_date
13348     order by tab.eligy_prfl_id,
13349              decode(tab.excld_flag,'Y',1,2);
13350   --
13351 begin
13352   --
13353   l_elenum := 1;
13354   --
13355   for instrow in c_instance
13356     (c_eligy_prfl_id  => p_eligy_prfl_id
13357     ,c_effective_date => p_effective_date
13358     )
13359   loop
13360     --
13361     l_inst_set.extend(1);
13362     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13363     l_inst_set(l_elenum).num_val       := instrow.competence_id;
13364     l_inst_set(l_elenum).num_val1      := instrow.rating_level_id;
13365     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
13366     --start 4446984
13367     l_inst_set(l_elenum).short_code    := instrow.short_code;
13368     l_inst_set(l_elenum).pk_id    := instrow.pk_id;
13369     l_inst_set(l_elenum).criteria_score    := instrow.criteria_score;
13370     l_inst_set(l_elenum).criteria_weight    := instrow.criteria_weight;
13371     --end 4446984
13372     l_elenum := l_elenum+1;
13373     --
13374   end loop;
13375   --
13376   p_inst_set := l_inst_set;
13377   --
13378 exception
13379   --
13380   when no_data_found then
13381     --
13382     null;
13383     --
13384 end elpecy_getdets;
13385 --
13386 -- ---------------------------------------------------------------------
13387 -- eligibility profile - Quartile in Grade
13388 -- ---------------------------------------------------------------------
13389 --
13390 procedure elpeqg_getdets
13391   (p_effective_date in     date
13392   ,p_eligy_prfl_id  in     number
13393    --
13394   ,p_inst_set       in out nocopy g_elp_cache
13395   ) is
13396   --
13397   l_proc varchar2(72) := g_package||'.elpeqg_getdets';
13398   --
13399   l_inst_set     g_elp_cache := g_elp_cache();
13400   --
13401   l_elenum       pls_integer;
13402   --
13403   cursor c_instance
13404     (c_eligy_prfl_id  number
13405     ,c_effective_date date
13406     )
13407   is
13408     select tab.eligy_prfl_id,
13409            tab.elig_qua_in_gr_prte_id pk_id,
13410            'EQG' short_code,
13411            tab.quar_in_grade_cd,
13412            tab.excld_flag,
13413            tab.criteria_score,
13414            tab.criteria_weight
13415     from   ben_elig_qua_in_gr_prte_f tab
13416     where tab.eligy_prfl_id = c_eligy_prfl_id
13417       and c_effective_date
13418         between tab.effective_start_date and tab.effective_end_date
13419     order by tab.eligy_prfl_id,
13420              decode(tab.excld_flag,'Y',1,2);
13421   --
13422 begin
13423   --
13424   l_elenum := 1;
13425   --
13426   for instrow in c_instance
13427     (c_eligy_prfl_id  => p_eligy_prfl_id
13428     ,c_effective_date => p_effective_date
13429     )
13430   loop
13431     --
13432     l_inst_set.extend(1);
13433     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13434     l_inst_set(l_elenum).v230_val       := instrow.quar_in_grade_cd;
13435     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
13436     l_elenum := l_elenum+1;
13437     --
13438   end loop;
13439   --
13440   p_inst_set := l_inst_set;
13441   --
13442 exception
13443   --
13444   when no_data_found then
13445     --
13446     null;
13447     --
13448 end elpeqg_getdets;
13449 --
13450 -- ---------------------------------------------------------------------
13451 -- eligibility profile - Performance Rating
13452 -- ---------------------------------------------------------------------
13453 --
13454 procedure elpepr_getdets
13455   (p_effective_date in     date
13456   ,p_eligy_prfl_id  in     number
13457   --
13458   ,p_inst_set       in out nocopy g_elp_cache
13459   ) is
13460 
13461   --
13462   l_proc varchar2(72) := g_package||'.elpepr_getdets';
13463   --
13464   l_inst_set     g_elp_cache := g_elp_cache();
13465   --
13466   l_elenum       pls_integer;
13467   --
13468   cursor c_instance
13469     (c_eligy_prfl_id  number
13470     ,c_effective_date date
13471     )
13472   is
13473     select tab.eligy_prfl_id,
13474            tab.elig_perf_rtng_prte_id pk_id,
13475            'ERG' short_code,
13476            tab.perf_rtng_cd,
13477            tab.event_type,
13478            tab.excld_flag,
13479            tab.criteria_score,
13480            tab.criteria_weight
13481     from   ben_elig_perf_rtng_prte_f tab
13482     where tab.eligy_prfl_id = c_eligy_prfl_id
13483       and c_effective_date
13484         between tab.effective_start_date and tab.effective_end_date
13485     order by tab.eligy_prfl_id,
13486              decode(tab.excld_flag,'Y',1,2);
13487   --
13488 begin
13489   --
13490   l_elenum := 1;
13491   --
13492   for instrow in c_instance
13493     (c_eligy_prfl_id  => p_eligy_prfl_id
13494     ,c_effective_date => p_effective_date
13495     )
13496   loop
13497     --
13498     l_inst_set.extend(1);
13499     l_inst_set(l_elenum).eligy_prfl_id := instrow.eligy_prfl_id;
13500     l_inst_set(l_elenum).v230_val      := instrow.perf_rtng_cd;
13501     l_inst_set(l_elenum).v230_val1     := instrow.event_type;
13502     l_inst_set(l_elenum).excld_flag    := instrow.excld_flag;
13503     l_elenum := l_elenum+1;
13504     --
13505   end loop;
13506   --
13507   p_inst_set := l_inst_set;
13508   --
13509 exception
13510   --
13511   when no_data_found then
13512     --
13513     null;
13514     --
13515 end elpepr_getdets;
13516 --
13517 procedure clear_down_cache
13518 is
13519   --
13520   --
13521 begin
13522   --
13523   -- On demand cache structures
13524   --
13525   g_copcep_odlookup.delete;
13526   g_copcep_odinst.delete;
13527   g_copcep_odcached := 0;
13528   g_copcep_nxelenum := null;
13529   --
13530   -- Clear down all cache structures
13531   --
13532   g_cobcep_lookup.delete;
13533   g_cobcep_inst.delete;
13534   g_cobcep_cached := FALSE;
13535   --
13536   g_elpept_lookup.delete;
13537   g_elpept_inst.delete;
13538   g_elpees_lookup.delete;
13539   g_elpees_inst.delete;
13540   g_elpesa_lookup.delete;
13541   g_elpesa_inst.delete;
13542   g_elpehs_lookup.delete;
13543   g_elpehs_inst.delete;
13544   g_elpels_lookup.delete;
13545   g_elpels_inst.delete;
13546   g_elpecp_lookup.delete;
13547   g_elpecp_inst.delete;
13548   --
13549   -- Old
13550   --
13551   g_cache_elpept_lookup.delete;
13552   g_cache_elpept_inst.delete;
13553   g_cache_elpepg_lookup.delete;
13554   g_cache_elpepg_inst.delete;
13555   g_cache_elpees_lookup.delete;
13556   g_cache_elpees_inst.delete;
13557   g_cache_elpels_lookup.delete;
13558   g_cache_elpels_inst.delete;
13559   g_cache_elpecp_lookup.delete;
13560   g_cache_elpecp_inst.delete;
13561   g_cache_elpewl_lookup.delete;
13562   g_cache_elpewl_inst.delete;
13563   g_cache_elpeou_lookup.delete;
13564   g_cache_elpeou_inst.delete;
13565   g_cache_elpehs_lookup.delete;
13566   g_cache_elpehs_inst.delete;
13567   g_cache_elpefp_lookup.delete;
13568   g_cache_elpefp_inst.delete;
13569   g_cache_elpesh_lookup.delete;
13570   g_cache_elpesh_inst.delete;
13571   g_cache_elpecl_lookup.delete;
13572   g_cache_elpecl_inst.delete;
13573   g_cache_elpehw_lookup.delete;
13574   g_cache_elpehw_inst.delete;
13575   g_cache_elpepf_lookup.delete;
13576   g_cache_elpepf_inst.delete;
13577   g_cache_elpegr_lookup.delete;
13578   g_cache_elpegr_inst.delete;
13579   g_cache_elpejp_lookup.delete;
13580   g_cache_elpejp_inst.delete;
13581   g_cache_elpepb_lookup.delete;
13582   g_cache_elpepb_inst.delete;
13583   g_cache_elpepy_lookup.delete;
13584   g_cache_elpepy_inst.delete;
13585   g_cache_elpebu_lookup.delete;
13586   g_cache_elpebu_inst.delete;
13587   g_cache_elpelu_lookup.delete;
13588   g_cache_elpelu_inst.delete;
13589   g_cache_elpelr_lookup.delete;
13590   g_cache_elpelr_inst.delete;
13591   g_cache_elpeap_lookup.delete;
13592   g_cache_elpeap_inst.delete;
13593   g_cache_elpepz_lookup.delete;
13594   g_cache_elpepz_inst.delete;
13595   g_cache_elpebn_lookup.delete;
13596   g_cache_elpebn_inst.delete;
13597   g_cache_elpeln_lookup.delete;
13598   g_cache_elpeln_inst.delete;
13599   g_cache_elpepp_lookup.delete;
13600   g_cache_elpepp_inst.delete;
13601   g_cache_elpesa_lookup.delete;
13602   g_cache_elpesa_inst.delete;
13603   g_cache_elpeoy_lookup.delete;
13604   g_cache_elpeoy_inst.delete;
13605   g_cache_elpetd_lookup.delete;
13606   g_cache_elpetd_inst.delete;
13607   g_cache_elpeno_lookup.delete;
13608   g_cache_elpeno_inst.delete;
13609   g_cache_elpeep_lookup.delete;
13610   g_cache_elpeep_inst.delete;
13611   g_cache_elpeei_lookup.delete;
13612   g_cache_elpeei_inst.delete;
13613   g_cache_elpeeg_lookup.delete;
13614   g_cache_elpeeg_inst.delete;
13615   g_cache_elpedp_lookup.delete;
13616   g_cache_elpedp_inst.delete;
13617   g_cache_elpelv_lookup.delete;
13618   g_cache_elpelv_inst.delete;
13619   g_cache_elpeom_lookup.delete;
13620   g_cache_elpeom_inst.delete;
13621   g_cache_elpeai_lookup.delete;
13622   g_cache_elpeai_inst.delete;
13623   g_cache_elpedi_lookup.delete;
13624   g_cache_elpedi_inst.delete;
13625   g_cache_elpeet_lookup.delete;
13626   g_cache_elpeet_inst.delete;
13627   g_cache_elpedt_lookup.delete;
13628   g_cache_elpedt_inst.delete;
13629   g_cache_elpedg_lookup.delete;
13630   g_cache_elpedg_inst.delete;
13631   g_cache_elpecq_lookup.delete;
13632   g_cache_elpecq_inst.delete;
13633   --
13634   -- Grab back memory
13635   --
13636   begin
13637     --
13638     dbms_session.free_unused_user_memory;
13639     --
13640   end;
13641   --
13642 end clear_down_cache;
13643 --
13644 end ben_elp_cache;
13645 --