1 Package Body hxc_htr_upd as
2 /* $Header: hxchtrrhi.pkb 120.2 2005/09/23 07:45:11 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_htr_upd.'; -- Global package name
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_htr_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 -- Increment the object version
71 p_rec.object_version_number := p_rec.object_version_number + 1;
72 --
73 hxc_htr_shd.g_api_dml := true; -- Set the api dml status
74 --
75 -- Update the hxc_time_recipients Row
76 --
77 update hxc_time_recipients
78 set
79 time_recipient_id = p_rec.time_recipient_id
80 ,name = p_rec.name
81 ,application_id = p_rec.application_id
82 ,object_version_number = p_rec.object_version_number
83 ,application_retrieval_function = p_rec.application_retrieval_function
84 ,application_update_process = p_rec.application_update_process
85 ,appl_validation_process = p_rec.appl_validation_process
86 ,application_period_function = p_rec.application_period_function
87 ,appl_dynamic_template_process = p_rec.appl_dynamic_template_process
88 ,extension_function1 = p_rec.extension_function1
89 ,extension_function2 = p_rec.extension_function2
90 ,last_updated_by = fnd_global.user_id
91 ,last_update_date = sysdate
92 ,last_update_login = fnd_global.login_id
93
94 where time_recipient_id = p_rec.time_recipient_id;
95 --
96 hxc_htr_shd.g_api_dml := false; -- Unset the api dml status
97 --
98 if g_debug then
99 hr_utility.set_location(' Leaving:'||l_proc, 10);
100 end if;
101 --
102 Exception
103 When hr_api.check_integrity_violated Then
104 -- A check constraint has been violated
105 hxc_htr_shd.g_api_dml := false; -- Unset the api dml status
106 hxc_htr_shd.constraint_error
107 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108 When hr_api.parent_integrity_violated Then
109 -- Parent integrity has been violated
110 hxc_htr_shd.g_api_dml := false; -- Unset the api dml status
111 hxc_htr_shd.constraint_error
112 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113 When hr_api.unique_integrity_violated Then
114 -- Unique integrity has been violated
115 hxc_htr_shd.g_api_dml := false; -- Unset the api dml status
116 hxc_htr_shd.constraint_error
117 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118 When Others Then
119 hxc_htr_shd.g_api_dml := false; -- Unset the api dml status
120 Raise;
121 End update_dml;
122 --
123 -- ----------------------------------------------------------------------------
124 -- |------------------------------< pre_update >------------------------------|
125 -- ----------------------------------------------------------------------------
126 -- {Start Of Comments}
127 --
128 -- Description:
129 -- This private procedure contains any processing which is required before
130 -- the update dml.
131 --
132 -- Prerequisites:
133 -- This is an internal procedure which is called from the upd procedure.
134 --
135 -- In Parameters:
136 -- A Pl/Sql record structure.
137 --
138 -- Post Success:
139 -- Processing continues.
140 --
141 -- Post Failure:
142 -- If an error has occurred, an error message and exception wil be raised
143 -- but not handled.
144 --
145 -- Developer Implementation Notes:
146 -- Any pre-processing required before the update dml is issued should be
147 -- coded within this procedure. It is important to note that any 3rd party
148 -- maintenance should be reviewed before placing in this procedure.
149 --
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure pre_update
156 (p_rec in hxc_htr_shd.g_rec_type
157 ) is
158 --
159 l_proc varchar2(72);
160 --
161 Begin
162
163
164 if g_debug then
165 l_proc := g_package||'pre_update';
166 hr_utility.set_location('Entering:'||l_proc, 5);
167 end if;
168 --
169 if g_debug then
170 hr_utility.set_location(' Leaving:'||l_proc, 10);
171 end if;
172 End pre_update;
173 --
174 -- ----------------------------------------------------------------------------
175 -- |-----------------------------< post_update >------------------------------|
176 -- ----------------------------------------------------------------------------
177 -- {Start Of Comments}
178 --
179 -- Description:
180 -- This private procedure contains any processing which is required after the
181 -- update dml.
182 --
183 -- Prerequisites:
184 -- This is an internal procedure which is called from the upd procedure.
185 --
186 -- In Parameters:
187 -- A Pl/Sql record structure.
188 --
189 -- Post Success:
190 -- Processing continues.
191 --
192 -- Post Failure:
193 -- If an error has occurred, an error message and exception will be raised
194 -- but not handled.
195 --
196 -- Developer Implementation Notes:
197 -- Any post-processing required after the update dml is issued should be
198 -- coded within this procedure. It is important to note that any 3rd party
199 -- maintenance should be reviewed before placing in this procedure.
200 --
201 -- Access Status:
202 -- Internal Row Handler Use Only.
203 --
204 -- {End Of Comments}
205 -- ----------------------------------------------------------------------------
206 Procedure post_update
207 (p_effective_date in date
208 ,p_rec in hxc_htr_shd.g_rec_type
209 ) is
210 --
211 l_proc varchar2(72);
212 --
213 Begin
214
215
216 if g_debug then
217 l_proc := g_package||'post_update';
218 hr_utility.set_location('Entering:'||l_proc, 5);
219 end if;
220 begin
221 --
222 hxc_htr_rku.after_update
223 (p_effective_date => p_effective_date
224 ,p_time_recipient_id
225 => p_rec.time_recipient_id
226 ,p_name
227 => p_rec.name
228 ,p_appl_retrieval_function
229 => p_rec.application_retrieval_function
230 ,p_appl_update_process
231 => p_rec.application_update_process
232 ,p_appl_validation_process
233 => p_rec.appl_validation_process
234 ,p_appl_period_function
235 => p_rec.application_period_function
236 ,p_appl_dyn_template_process
237 => p_rec.appl_dynamic_template_process
238 ,p_extension_function1
239 => p_rec.extension_function1
240 ,p_extension_function2
241 => p_rec.extension_function2
242 ,p_application_id
243 => p_rec.application_id
244 ,p_object_version_number
245 => p_rec.object_version_number
246 ,p_name_o
247 => hxc_htr_shd.g_old_rec.name
248 ,p_appl_retrieval_function_o
249 => hxc_htr_shd.g_old_rec.application_retrieval_function
250 ,p_appl_update_process_o
251 => hxc_htr_shd.g_old_rec.application_update_process
252 ,p_appl_validation_process_o
253 => hxc_htr_shd.g_old_rec.appl_validation_process
254 ,p_appl_period_function_o
255 => hxc_htr_shd.g_old_rec.application_period_function
256 ,p_appl_dyn_template_process_o
257 => hxc_htr_shd.g_old_rec.appl_dynamic_template_process
258 ,p_extension_function1_o
259 => hxc_htr_shd.g_old_rec.extension_function1
260 ,p_extension_function2_o
261 => hxc_htr_shd.g_old_rec.extension_function2
262 ,p_application_id_o
263 => hxc_htr_shd.g_old_rec.application_id
264 ,p_object_version_number_o
265 => hxc_htr_shd.g_old_rec.object_version_number
266 );
267 --
268 exception
269 --
270 when hr_api.cannot_find_prog_unit then
271 --
272 hr_api.cannot_find_prog_unit_error
273 (p_module_name => 'HXC_TIME_RECIPIENTS'
274 ,p_hook_type => 'AU');
275 --
276 end;
277 --
278 if g_debug then
279 hr_utility.set_location(' Leaving:'||l_proc, 10);
280 end if;
281 End post_update;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |-----------------------------< convert_defs >-----------------------------|
285 -- ----------------------------------------------------------------------------
286 -- {Start Of Comments}
287 --
288 -- Description:
289 -- The Convert_Defs procedure has one very important function:
290 -- It must return the record structure for the row with all system defaulted
291 -- values converted into its corresponding parameter value for update. When
292 -- we attempt to update a row through the Upd process , certain
293 -- parameters can be defaulted which enables flexibility in the calling of
294 -- the upd process (e.g. only attributes which need to be updated need to be
295 -- specified). For the upd process to determine which attributes
296 -- have NOT been specified we need to check if the parameter has a reserved
297 -- system default value. Therefore, for all parameters which have a
298 -- corresponding reserved system default mechanism specified we need to
299 -- check if a system default is being used. If a system default is being
300 -- used then we convert the defaulted value into its corresponding attribute
301 -- value held in the g_old_rec data structure.
302 --
303 -- Prerequisites:
304 -- This private function can only be called from the upd process.
305 --
306 -- In Parameters:
307 -- A Pl/Sql record structure.
308 --
309 -- Post Success:
310 -- The record structure will be returned with all system defaulted parameter
311 -- values converted into its current row attribute value.
312 --
313 -- Post Failure:
314 -- No direct error handling is required within this function. Any possible
315 -- errors within this procedure will be a PL/SQL value error due to
316 -- conversion of datatypes or data lengths.
317 --
318 -- Developer Implementation Notes:
319 -- None.
320 --
321 -- Access Status:
322 -- Internal Row Handler Use Only.
323 --
324 -- {End Of Comments}
325 -- ----------------------------------------------------------------------------
326 Procedure convert_defs
327 (p_rec in out nocopy hxc_htr_shd.g_rec_type
328 ) is
329 --
330 Begin
331 --
332 -- We must now examine each argument value in the
333 -- p_rec plsql record structure
334 -- to see if a system default is being used. If a system default
335 -- is being used then we must set to the 'current' argument value.
336 --
337 If (p_rec.name = hr_api.g_varchar2) then
338 p_rec.name :=
339 hxc_htr_shd.g_old_rec.name;
340 End If;
341 If (p_rec.application_id = hr_api.g_number) then
342 p_rec.application_id :=
343 hxc_htr_shd.g_old_rec.application_id;
344 End If;
345 --
346 End convert_defs;
347 --
348 -- ----------------------------------------------------------------------------
349 -- |---------------------------------< upd >----------------------------------|
350 -- ----------------------------------------------------------------------------
351 Procedure upd
352 (p_effective_date in date
353 ,p_rec in out nocopy hxc_htr_shd.g_rec_type
354 ) is
355 --
356 l_proc varchar2(72);
357 --
358 Begin
359 g_debug := hr_utility.debug_enabled;
360
361 if g_debug then
362 l_proc := g_package||'upd';
363 hr_utility.set_location('Entering:'||l_proc, 5);
364 end if;
365 --
366 -- We must lock the row which we need to update.
367 --
368 hxc_htr_shd.lck
369 (p_rec.time_recipient_id
370 ,p_rec.object_version_number
371 );
372 --
373 -- 1. During an update system defaults are used to determine if
374 -- arguments have been defaulted or not. We must therefore
375 -- derive the full record structure values to be updated.
376 --
377 -- 2. Call the supporting update validate operations.
378 --
379 convert_defs(p_rec);
380 hxc_htr_bus.update_validate
381 (p_effective_date
382 ,p_rec
383 );
384 --
385 -- Call the supporting pre-update operation
386 --
387 hxc_htr_upd.pre_update(p_rec);
388 --
389 -- Update the row.
390 --
391 hxc_htr_upd.update_dml(p_rec);
392 --
393 -- Call the supporting post-update operation
394 --
395 hxc_htr_upd.post_update
396 (p_effective_date
397 ,p_rec
398 );
399 End upd;
400 --
401 -- ----------------------------------------------------------------------------
402 -- |---------------------------------< upd >----------------------------------|
403 -- ----------------------------------------------------------------------------
404 Procedure upd
405 (p_effective_date in date
406 ,p_time_recipient_id in number
407 ,p_appl_retrieval_function in varchar2 default NULL
408 ,p_appl_update_process in varchar2 default NULL
409 ,p_appl_validation_process in varchar2 default NULL
410 ,p_appl_period_function in varchar2 default NULL
411 ,p_appl_dyn_template_process in varchar2 default NULL
412 ,p_extension_function1 in varchar2 default NULL
413 ,p_extension_function2 in varchar2 default NULL
414 ,p_object_version_number in out nocopy number
415 ,p_name in varchar2 default hr_api.g_varchar2
416 ,p_application_id in number default hr_api.g_number
417 ) is
418 --
419 l_rec hxc_htr_shd.g_rec_type;
420 l_proc varchar2(72);
421 --
422 Begin
423 g_debug := hr_utility.debug_enabled;
424
425 if g_debug then
426 l_proc := g_package||'upd';
427 hr_utility.set_location('Entering:'||l_proc, 5);
428 end if;
429 --
430 -- Call conversion function to turn arguments into the
431 -- l_rec structure.
432 --
433 l_rec :=
434 hxc_htr_shd.convert_args
435 (p_time_recipient_id
436 ,p_name
437 ,p_appl_retrieval_function
438 ,p_appl_update_process
439 ,p_appl_validation_process
440 ,p_appl_period_function
441 ,p_appl_dyn_template_process
442 ,p_extension_function1
443 ,p_extension_function2
444 ,p_application_id
445 ,p_object_version_number
446 );
447
448 --
449 -- Having converted the arguments into the
450 -- plsql record structure we call the corresponding record
451 -- business process.
452 --
453 hxc_htr_upd.upd
454 (p_effective_date
455 ,l_rec
456 );
457 p_object_version_number := l_rec.object_version_number;
458 --
459 if g_debug then
460 hr_utility.set_location(' Leaving:'||l_proc, 10);
461 end if;
462 End upd;
463 --
464 end hxc_htr_upd;