1 Package Body hxc_lkr_upd as
2 /* $Header: hxclockrulesrhi.pkb 120.2 2005/09/23 07:58:43 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
8 g_package varchar2(33) := ' hxc_lkr_upd.'; -- Global package name
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |------------------------------< update_dml >------------------------------|
14 -- ----------------------------------------------------------------------------
15 -- {Start Of Comments}
16 --
17 -- Description:
18 -- This procedure controls the actual dml update logic. The processing of
19 -- this procedure is:
20 -- 1) Increment the object_version_number by 1 if the object_version_number
21 -- is defined as an attribute for this entity.
22 -- 2) To set and unset the g_api_dml status as required (as we are about to
23 -- perform dml).
24 -- 3) To update the specified row in the schema using the primary key in
25 -- the predicates.
26 -- 4) To trap any constraint violations that may have occurred.
27 -- 5) To raise any other errors.
28 --
29 -- Prerequisites:
30 -- This is an internal private procedure which must be called from the upd
31 -- procedure.
32 --
33 -- In Parameters:
34 -- A Pl/Sql record structre.
35 --
36 -- Post Success:
37 -- The specified row will be updated in the schema.
38 --
39 -- Post Failure:
40 -- On the update dml failure it is important to note that we always reset the
41 -- g_api_dml status to false.
42 -- If a check, unique or parent integrity constraint violation is raised the
43 -- constraint_error procedure will be called.
44 -- If any other error is reported, the error will be raised after the
45 -- g_api_dml status is reset.
46 --
47 -- Developer Implementation Notes:
48 -- The update 'set' attribute list should be modified if any of your
49 -- attributes are not updateable.
50 --
51 -- Access Status:
52 -- Internal Row Handler Use Only.
53 --
54 -- {End Of Comments}
55 -- ----------------------------------------------------------------------------
56 Procedure update_dml
57 (p_rec in out nocopy hxc_lkr_shd.g_rec_type
58 ) is
59 --
60 l_proc varchar2(72);
61 --
62 Begin
63
64
65 if g_debug then
66 l_proc := g_package||'update_dml';
67 hr_utility.set_location('Entering:'||l_proc, 5);
68 end if;
69 --
70 --
71 --
72 --
73 -- Update the hxc_locking_rules Row
74 --
75 update hxc_locking_rules
76 set
77 locker_type_owner_id = p_rec.locker_type_owner_id
78 ,locker_type_requestor_id = p_rec.locker_type_requestor_id
79 ,grant_lock = p_rec.grant_lock
80 ,last_updated_by = fnd_global.user_id
81 ,last_update_date = sysdate
82 ,last_update_login = fnd_global.login_id
83
84 where locker_type_owner_id = p_rec.locker_type_owner_id
85 and locker_type_requestor_id = p_rec.locker_type_requestor_id;
86 --
87 --
88 --
89 if g_debug then
90 hr_utility.set_location(' Leaving:'||l_proc, 10);
91 end if;
92 --
93 Exception
94 When hr_api.check_integrity_violated Then
95 -- A check constraint has been violated
96 --
97 hxc_lkr_shd.constraint_error
98 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99 When hr_api.parent_integrity_violated Then
100 -- Parent integrity has been violated
101 --
102 hxc_lkr_shd.constraint_error
103 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104 When hr_api.unique_integrity_violated Then
105 -- Unique integrity has been violated
106 --
107 hxc_lkr_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When Others Then
110 --
111 Raise;
112 End update_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_update >------------------------------|
116 -- ----------------------------------------------------------------------------
117 -- {Start Of Comments}
118 --
119 -- Description:
120 -- This private procedure contains any processing which is required before
121 -- the update dml.
122 --
123 -- Prerequisites:
124 -- This is an internal procedure which is called from the upd procedure.
125 --
126 -- In Parameters:
127 -- A Pl/Sql record structure.
128 --
129 -- Post Success:
130 -- Processing continues.
131 --
132 -- Post Failure:
133 -- If an error has occurred, an error message and exception wil be raised
134 -- but not handled.
135 --
136 -- Developer Implementation Notes:
137 -- Any pre-processing required before the update dml is issued should be
138 -- coded within this procedure. It is important to note that any 3rd party
139 -- maintenance should be reviewed before placing in this procedure.
140 --
141 -- Access Status:
142 -- Internal Row Handler Use Only.
143 --
144 -- {End Of Comments}
145 -- ----------------------------------------------------------------------------
146 Procedure pre_update
147 (p_rec in hxc_lkr_shd.g_rec_type
148 ) is
149 --
150 l_proc varchar2(72);
151 --
152 Begin
153
154
155 if g_debug then
156 l_proc := g_package||'pre_update';
157 hr_utility.set_location('Entering:'||l_proc, 5);
158 --
162 --
159 hr_utility.set_location(' Leaving:'||l_proc, 10);
160 end if;
161 End pre_update;
163 -- ----------------------------------------------------------------------------
164 -- |-----------------------------< post_update >------------------------------|
165 -- ----------------------------------------------------------------------------
166 -- {Start Of Comments}
167 --
168 -- Description:
169 -- This private procedure contains any processing which is required after
170 -- the update dml.
171 --
172 -- Prerequisites:
173 -- This is an internal procedure which is called from the upd procedure.
174 --
175 -- In Parameters:
176 -- A Pl/Sql record structure.
177 --
178 -- Post Success:
179 -- Processing continues.
180 --
181 -- Post Failure:
182 -- If an error has occurred, an error message and exception will be raised
183 -- but not handled.
184 --
185 -- Developer Implementation Notes:
186 -- Any post-processing required after the update dml is issued should be
187 -- coded within this procedure. It is important to note that any 3rd party
188 -- maintenance should be reviewed before placing in this procedure.
189 --
190 -- Access Status:
191 -- Internal Row Handler Use Only.
192 --
193 -- {End Of Comments}
194 -- ----------------------------------------------------------------------------
195 Procedure post_update
196 (p_rec in hxc_lkr_shd.g_rec_type
197 ) is
198 --
199 l_proc varchar2(72);
200 --
201 Begin
202
203
204 if g_debug then
205 l_proc := g_package||'post_update';
206 hr_utility.set_location('Entering:'||l_proc, 5);
207 end if;
208 begin
209
210 --
211 hxc_lkr_rku.after_update
212 (p_locker_type_owner_id
213 => p_rec.locker_type_owner_id
214 ,p_locker_type_requestor_id
215 => p_rec.locker_type_requestor_id
216 ,p_grant_lock
217 => p_rec.grant_lock
218 ,p_grant_lock_o
219 => hxc_lkr_shd.g_old_rec.grant_lock
220 );
221
222 --
223 exception
224 --
225 when hr_api.cannot_find_prog_unit then
226 --
227 hr_api.cannot_find_prog_unit_error
228 (p_module_name => 'HXC_LOCKING_RULES'
229 ,p_hook_type => 'AU');
230 --
231 end;
232 --
233 if g_debug then
234 hr_utility.set_location(' Leaving:'||l_proc, 10);
235 end if;
236 End post_update;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |-----------------------------< convert_defs >-----------------------------|
240 -- ----------------------------------------------------------------------------
241 -- {Start Of Comments}
242 --
243 -- Description:
244 -- The Convert_Defs procedure has one very important function:
245 -- It must return the record structure for the row with all system defaulted
246 -- values converted into its corresponding parameter value for update. When
247 -- we attempt to update a row through the Upd process , certain
248 -- parameters can be defaulted which enables flexibility in the calling of
249 -- the upd process (e.g. only attributes which need to be updated need to be
250 -- specified). For the upd process to determine which attributes
251 -- have NOT been specified we need to check if the parameter has a reserved
252 -- system default value. Therefore, for all parameters which have a
253 -- corresponding reserved system default mechanism specified we need to
254 -- check if a system default is being used. If a system default is being
255 -- used then we convert the defaulted value into its corresponding attribute
256 -- value held in the g_old_rec data structure.
257 --
258 -- Prerequisites:
259 -- This private function can only be called from the upd process.
260 --
261 -- In Parameters:
262 -- A Pl/Sql record structure.
263 --
264 -- Post Success:
265 -- The record structure will be returned with all system defaulted parameter
266 -- values converted into its current row attribute value.
267 --
268 -- Post Failure:
269 -- No direct error handling is required within this function. Any possible
270 -- errors within this procedure will be a PL/SQL value error due to
271 -- conversion of datatypes or data lengths.
272 --
273 -- Developer Implementation Notes:
274 -- None.
275 --
276 -- Access Status:
277 -- Internal Row Handler Use Only.
278 --
279 -- {End Of Comments}
280 -- ----------------------------------------------------------------------------
281 Procedure convert_defs
282 (p_rec in out nocopy hxc_lkr_shd.g_rec_type
283 ) is
284 --
285 Begin
286 --
287 -- We must now examine each argument value in the
288 -- p_rec plsql record structure
289 -- to see if a system default is being used. If a system default
290 -- is being used then we must set to the 'current' argument value.
291 --
292 If (p_rec.grant_lock = hr_api.g_varchar2) then
293 p_rec.grant_lock :=
294 hxc_lkr_shd.g_old_rec.grant_lock;
295 End If;
296 --
297 End convert_defs;
298 --
299 -- ----------------------------------------------------------------------------
300 -- |---------------------------------< upd >----------------------------------|
301 -- ----------------------------------------------------------------------------
302 Procedure upd
303 (p_rec in out nocopy hxc_lkr_shd.g_rec_type
304 ) is
305 --
306 l_proc varchar2(72);
307 --
308 Begin
309 g_debug := hr_utility.debug_enabled;
310
311 if g_debug then
312 l_proc := g_package||'upd';
313 hr_utility.set_location('Entering:'||l_proc, 5);
314 end if;
315 --
316 -- We must lock the row which we need to update.
317 --
318 hxc_lkr_shd.lck
319 (p_rec.locker_type_owner_id
320 ,p_rec.locker_type_requestor_id
321 );
322 --
323 -- 1. During an update system defaults are used to determine if
324 -- arguments have been defaulted or not. We must therefore
325 -- derive the full record structure values to be updated.
326 --
327 -- 2. Call the supporting update validate operations.
328 --
329 convert_defs(p_rec);
330 hxc_lkr_bus.update_validate
331 (p_rec
332 );
333 --
334 -- Call to raise any errors on multi-message list
335 hr_multi_message.end_validation_set;
336 --
337 -- Call the supporting pre-update operation
338 --
339 hxc_lkr_upd.pre_update(p_rec);
340 --
341 -- Update the row.
342 --
343 hxc_lkr_upd.update_dml(p_rec);
344 --
345 -- Call the supporting post-update operation
346 --
347 hxc_lkr_upd.post_update
348 (p_rec
349 );
350 --
351 -- Call to raise any errors on multi-message list
352 hr_multi_message.end_validation_set;
353 End upd;
354 --
355 -- ----------------------------------------------------------------------------
356 -- |---------------------------------< upd >----------------------------------|
357 -- ----------------------------------------------------------------------------
358 Procedure upd
359 (p_locker_type_owner_id in number
360 ,p_locker_type_requestor_id in number
361 ,p_grant_lock in varchar2 default hr_api.g_varchar2
362 ) is
363 --
364 l_rec hxc_lkr_shd.g_rec_type;
365 l_proc varchar2(72);
366 --
367 Begin
368 g_debug := hr_utility.debug_enabled;
369
370 if g_debug then
371 l_proc := g_package||'upd';
372 hr_utility.set_location('Entering:'||l_proc, 5);
373 end if;
374 --
375 -- Call conversion function to turn arguments into the
376 -- l_rec structure.
377 --
378 l_rec :=
379 hxc_lkr_shd.convert_args
380 (p_locker_type_owner_id
381 ,p_locker_type_requestor_id
382 ,p_grant_lock
383 );
384 --
385 -- Having converted the arguments into the
386 -- plsql record structure we call the corresponding record
387 -- business process.
388 --
389 hxc_lkr_upd.upd
390 (l_rec
391 );
392 --
393 --
394 if g_debug then
395 hr_utility.set_location(' Leaving:'||l_proc, 10);
396 end if;
397 End upd;
398 --
399 end hxc_lkr_upd;