1 package body ben_location_object as
2 /* $Header: benlocch.pkb 120.0 2005/05/28 09:06:47 appldev noship $ */
3 --
4 /*
5 +==============================================================================+
6 | Copyright (c) 1997 Oracle Corporation |
7 | Redwood Shores, California, USA |
8 | All rights reserved. |
9 +==============================================================================+
10 --
11 History
12 Version Date Who What?
13 --------- --------- ---------- --------------------------------------------
14 115.0 08-Jun-99 bbulusu Created.
15 115.1 05-Aug-99 GPERRY Fixed bug in set_object and last
16 cached record logic added.
17 115.2 16-Aug-99 GPERRY Added nocopy compiler directive.
18 115.3 06 May 00 RChase Added additional NOCOPY directives
19 replaced get code and removed additional
20 record assignments
21 115.4 29 Dec 00 Tmathers Fixed chgeck_sql errors.
22 -----------------------------------------------------------------------------
23 */
24 --
25 g_package varchar2(30) := 'ben_location_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(p_rec in out NOCOPY hr_locations_all%rowtype) is
32 --
33 l_proc varchar2(80) := g_package||'set_object';
34 l_index pls_integer;
35 l_not_hash_found boolean;
36 --
37 begin
38 --
39 --hr_utility.set_location('Entering '||l_proc,10);
40 --
41 -- 1) get hash index
42 -- 2) If hash index is not used use hash index
43 -- 3) If hash index is used and correct then do nothing
44 -- 4) If hash index is used and not correct then try next hash index
45 --
46 -- Get hashed index value
47 --
48 l_index := ben_hash_utility.get_hashed_index(p_id => p_rec.location_id);
49 --
50 -- 115.3 check for cache entry at current index. if none exists the NO_DATA_FOUND expection will fire
51 if g_cache_loc_rec(l_index).location_id = p_rec.location_id then
52 -- do nothing, cache entry already exists
53 null;
54 else
55 --
56 -- Loop through the hash using the jump routine to check further
57 -- indexes
58 -- 115.3 if none exists at current index the NO_DATA_FOUND expection will fire
59 --
60 l_index := l_index+g_hash_jump;
61 while g_cache_loc_rec(l_index).location_id <> p_rec.location_id loop
62 --
63 l_index := l_index+g_hash_jump;
64
65 end loop;
66 --
67 end if;
68 --
69 -- hr_utility.set_location('Leaving '||l_proc,10);
70 --
71 exception when NO_DATA_FOUND then
72 --115.3 set cache entry at current index location
73 g_cache_loc_rec(l_index):=p_rec;
74 --
75 end set_object;
76 --
77 -- Set object alternate route routines
78 --
79 procedure set_loc_object
80 (p_location_id in number,
81 p_rec in out nocopy hr_locations_all%rowtype) is
82 --
83 l_proc varchar2(80) := g_package||'set_loc_object';
84 --
85 cursor c1 is
86 select loc.*
87 from hr_locations_all loc
88 where loc.location_id = p_location_id;
89 --115.3 remove additional declaration
90 --l_rec hr_locations_all%rowtype;
91 --
92 begin
93 --
94 --hr_utility.set_location('Entering '||l_proc,10);
95 --
96 -- 1) Get record from database.
97 -- 2) If record not found then raise error.
98 -- 3) Pass record to set_object routine.
99 --
100 open c1;
101 --
102 fetch c1 into p_rec;
103 if c1%notfound then
104 --115.3 altered to use NOCOPY parameter
105 --l_rec.location_id := p_location_id;
106 p_rec.location_id := p_location_id;
107 --
108 end if;
109 --
110 close c1;
111 --
112 set_object(p_rec => p_rec);
113 --115.3 remove assignment
114 --p_rec := l_rec;
115 --
116 --hr_utility.set_location('Leaving '||l_proc,10);
117 --
118 end set_loc_object;
119 --
120 -- Get object routines
121 --
122 procedure get_object(p_location_id in number,
123 p_rec in out nocopy hr_locations_all%rowtype) is
124 --
125 l_proc varchar2(80) := g_package||'get_object';
126 l_index pls_integer;
127 --l_not_hash_found boolean;
128 l_env ben_env_object.g_global_env_rec_type;
129 --l_rec hr_locations_all%rowtype;
130 --
131 begin
132 --
133 --hr_utility.set_location('Entering '||l_proc,10);
134 --
135 if g_cache_last_loc_rec.location_id = p_location_id then
136 --
137 p_rec := g_cache_last_loc_rec;
138 return;
139 --
140 end if;
141 -- 1) Get hashed index
142 -- 2) If hashed index is correct pgm then return program
143 -- 3) If hashed index is not correct program then check next index
144 -- 4) Repest 3 until correct program found, if not found raise error.
145 --
146 -- Get hashed index value
147 --
148 l_index := mod(p_location_id,g_hash_key);
149 --
150 if g_cache_loc_rec(l_index).location_id = p_location_id then
151 --
152 g_cache_last_loc_rec := g_cache_loc_rec(l_index);
153 p_rec := g_cache_last_loc_rec;
154 --
155 else
156 --
157 -- We need to loop through all the hashed indexes
158 -- if none exists at current index the NO_DATA_FOUND expection will fire
159 --
160 l_index := l_index+g_hash_jump;
161 while g_cache_loc_rec(l_index).location_id <> p_location_id loop
162 --
163 l_index := l_index+g_hash_jump;
164 --
165 end loop;
166 --
167 g_cache_last_loc_rec := g_cache_loc_rec(l_index);
168 p_rec := g_cache_last_loc_rec;
169 --
170 end if;
171 --
172 exception
173 --
174 when no_data_found then
175 --
176 ben_env_object.get(p_rec => l_env);
177 --
178 set_loc_object(p_location_id => p_location_id,
179 p_rec => p_rec);
180 --
181 g_cache_last_loc_rec := p_rec;
182 --115.3 remove assignment
183 --p_rec := l_rec;
184 --
185 end get_object;
186 --
187 procedure clear_down_cache is
188 --
189 l_last_loc_rec hr_locations_all%rowtype;
190 --
191 begin
192 --
193 g_cache_loc_rec.delete;
194 g_cache_last_loc_rec := l_last_loc_rec;
195 --
196 end clear_down_cache;
197 --
198 end ben_location_object;