1 package body ben_pil_object as
2 /* $Header: bepilobj.pkb 120.0 2005/05/28 10:50:10 appldev noship $ */
3 --
4 /*
5 +==============================================================================+
6 | Copyright (c) 1997 Oracle Corporation |
7 | Redwood Shores, California, USA |
8 | All rights reserved. |
9 +==============================================================================+
10 --
11 Name
12 Person Object Caching Routine
13 Purpose
14 This package is used to return person object information.
15 History
16 Version Date Who What?
17 --------- --------- ---------- --------------------------------------------
18 115.0 11-Jun-99 mhoyes Created.
19 115.1 31-Jan-01 mhoyes - Removed STRTD life event restriction so that
20 cache supports all types of life event.
21 115.2 20-Mar-02 vsethi added dbdrv lines
22 -----------------------------------------------------------------------------
23 */
24 --
25 g_package varchar2(30) := 'ben_pil_object.';
26 g_hash_key number := ben_hash_utility.get_hash_key;
27 g_hash_jump number := ben_hash_utility.get_hash_jump;
28 --
29 -- Set object routines
30 --
31 procedure set_object
32 (p_rec in out nocopy ben_per_in_ler%rowtype
33 )
34 is
35 --
36 l_index pls_integer;
37 --
38 begin
39 --
40 -- 1) get hash index
41 -- 2) If hash index is not used use hash index
42 -- 3) If hash index is used and correct then do nothing
43 -- 4) If hash index is used and not correct then try next hash index
44 --
45 -- Get hashed index value
46 --
47 l_index := mod(p_rec.per_in_ler_id,g_hash_key);
48 --
49 if g_cache_pil_rec(l_index).per_in_ler_id = p_rec.per_in_ler_id then
50 -- do nothing, cache entry already exists
51 null;
52 else
53 --
54 -- Loop through the hash using the jump routine to check further
55 -- indexes
56 -- 115.23 if none exists at current index the NO_DATA_FOUND expection will fire
57 --
58 l_index := l_index+g_hash_jump;
59 while g_cache_pil_rec(l_index).per_in_ler_id <> p_rec.per_in_ler_id loop
60 --
61 l_index := l_index+g_hash_jump;
62 end loop;
63 --
64 end if;
65 --
66 exception when NO_DATA_FOUND then
67 -- set cache entry at current index location
68 g_cache_pil_rec(l_index):=p_rec;
69 --
70 end set_object;
71 --
72 procedure get_object
73 (p_per_in_ler_id in number
74 ,p_rec in out nocopy ben_per_in_ler%rowtype
75 )
76 is
77 --
78 l_index pls_integer;
79 l_env ben_env_object.g_global_env_rec_type;
80 --
81 cursor c1
82 is
83 select pil.*
84 from ben_per_in_ler pil
85 where pil.per_in_ler_id = p_per_in_ler_id;
86 --
87 -- Removed for EFC. This cache is intended to support all life
88 -- event information for all types of life event. It should not be
89 -- restricted to started life events only
90 --
91 /*
92 and pil.per_in_ler_stat_cd = 'STRTD';
93 */
94 --
95 begin
96 --
97 if g_cache_last_pil_rec.per_in_ler_id = p_per_in_ler_id then
98 --
99 p_rec := g_cache_last_pil_rec;
100 return;
101 --
102 end if;
103 -- 1) Get hashed index
104 -- 2) If hashed index is correct person_id then return assignment
105 -- 3) If hashed index is not correct person_id then check next index
106 -- 4) Repest 3 until correct person_id found, if not found raise error.
107 --
108 -- Get hashed index value
109 --
110 l_index := mod(p_per_in_ler_id,g_hash_key);
111 --
112 if g_cache_pil_rec(l_index).per_in_ler_id = p_per_in_ler_id then
113 --
114 g_cache_last_pil_rec := g_cache_pil_rec(l_index);
115 p_rec := g_cache_last_pil_rec;
116 --
117 else
118 --
119 -- We need to loop through all the hashed indexes
120 -- if none exists at current index the NO_DATA_FOUND expection will fire
121 --
122 l_index := l_index+g_hash_jump;
123 while g_cache_pil_rec(l_index).person_id <> p_per_in_ler_id loop
124 --
125 l_index := l_index+g_hash_jump;
126 --
127 end loop;
128 --
129 g_cache_last_pil_rec := g_cache_pil_rec(l_index);
130 p_rec := g_cache_last_pil_rec;
131 --
132 end if;
133 exception
134 --
135 when no_data_found then
136 --
137 open c1;
138 fetch c1 into p_rec;
139 if c1%notfound then
140 fnd_message.set_name('BEN','BEN_92204_OBJECT_NOT_FOUND');
141 fnd_message.set_token('PROC','ben_pil_object.get_object ');
142 fnd_message.set_token('PIL',p_per_in_ler_id);
143 fnd_message.raise_error;
144 end if;
145 close c1;
146 set_object(p_rec => p_rec);
147 --
148 end get_object;
149 --
150 procedure clear_down_cache is
151 --
152 l_cache_last_pil_rec ben_per_in_ler%rowtype;
153 --
154 begin
155 --
156 g_cache_pil_rec.delete;
157 --
158 -- Clear last cache records
159 --
160 g_cache_last_pil_rec := l_cache_last_pil_rec;
161 --
162 end clear_down_cache;
163 --
164 end ben_pil_object;