1 Package Body ghr_cdt_upd as
2 /* $Header: ghcdtrhi.pkb 115.4 2003/01/30 19:25:13 asubrahm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_cdt_upd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< update_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml update logic. The processing of
17 -- this procedure is:
18 -- 1) Increment the object_version_number by 1 if the object_version_number
19 -- is defined as an attribute for this entity.
20 -- 2) To set and unset the g_api_dml status as required (as we are about to
21 -- perform dml).
22 -- 3) To update the specified row in the schema using the primary key in
23 -- the predicates.
24 -- 4) To trap any constraint violations that may have occurred.
25 -- 5) To raise any other errors.
26 --
27 -- Prerequisites:
28 -- This is an internal private procedure which must be called from the upd
29 -- procedure.
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be updated in the schema.
36 --
37 -- Post Failure:
38 -- On the update dml failure it is important to note that we always reset the
39 -- g_api_dml status to false.
40 -- If a check, unique or parent integrity constraint violation is raised the
41 -- constraint_error procedure will be called.
42 -- If any other error is reported, the error will be raised after the
43 -- g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 -- The update 'set' attribute list should be modified if any of your
47 -- attributes are not updateable.
48 --
49 -- Access Status:
50 -- Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml
55 (p_rec in out nocopy ghr_cdt_shd.g_rec_type
56 ) is
57 --
58 l_proc varchar2(72) := g_package||'update_dml';
59 --
60 Begin
61 hr_utility.set_location('Entering:'||l_proc, 5);
62 --
63 -- Increment the object version
64 p_rec.object_version_number := p_rec.object_version_number + 1;
65 --
66 --
67 --
68 -- Update the ghr_compl_ca_details Row
69 --
70 update ghr_compl_ca_details
71 set
72 compl_ca_detail_id = p_rec.compl_ca_detail_id
73 ,compl_ca_header_id = p_rec.compl_ca_header_id
74 --,action = p_rec.action
75 ,amount = p_rec.amount
76 ,order_date = p_rec.order_date
77 ,due_date = p_rec.due_date
78 ,request_date = p_rec.request_date
79 ,complete_date = p_rec.complete_date
80 ,category = p_rec.category
81 --,type = p_rec.type
82 ,phase = p_rec.phase
83 ,action_type = p_rec.action_type
84 ,payment_type = p_rec.payment_type
85 ,object_version_number = p_rec.object_version_number
86 ,description = p_rec.description
87 where compl_ca_detail_id = p_rec.compl_ca_detail_id;
88 --
89 --
90 --
91 hr_utility.set_location(' Leaving:'||l_proc, 10);
92 --
93 Exception
94 When hr_api.check_integrity_violated Then
95 -- A check constraint has been violated
96 --
97 ghr_cdt_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 ghr_cdt_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 ghr_cdt_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 ghr_cdt_shd.g_rec_type
148 ) is
149 --
150 l_proc varchar2(72) := g_package||'pre_update';
151 --
152 Begin
153 hr_utility.set_location('Entering:'||l_proc, 5);
154 --
155 hr_utility.set_location(' Leaving:'||l_proc, 10);
156 End pre_update;
157 --
158 -- ----------------------------------------------------------------------------
159 -- |-----------------------------< post_update >------------------------------|
160 -- ----------------------------------------------------------------------------
161 -- {Start Of Comments}
162 --
163 -- Description:
164 -- This private procedure contains any processing which is required after
165 -- the update dml.
166 --
167 -- Prerequisites:
168 -- This is an internal procedure which is called from the upd procedure.
169 --
170 -- In Parameters:
171 -- A Pl/Sql record structure.
172 --
173 -- Post Success:
174 -- Processing continues.
175 --
176 -- Post Failure:
177 -- If an error has occurred, an error message and exception will be raised
178 -- but not handled.
179 --
180 -- Developer Implementation Notes:
181 -- Any post-processing required after the update dml is issued should be
182 -- coded within this procedure. It is important to note that any 3rd party
183 -- maintenance should be reviewed before placing in this procedure.
184 --
185 -- Access Status:
186 -- Internal Row Handler Use Only.
187 --
188 -- {End Of Comments}
189 -- ----------------------------------------------------------------------------
190 Procedure post_update
191 (p_effective_date in date
192 ,p_rec in ghr_cdt_shd.g_rec_type
193 ) is
194 --
195 l_proc varchar2(72) := g_package||'post_update';
196 --
197 Begin
198 hr_utility.set_location('Entering:'||l_proc, 5);
199 begin
200 --
201 ghr_cdt_rku.after_update
202 (p_effective_date => p_effective_date
203 ,p_compl_ca_detail_id => p_rec.compl_ca_detail_id
204 ,p_compl_ca_header_id => p_rec.compl_ca_header_id
205 --,p_action => p_rec.action
206 ,p_amount => p_rec.amount
207 ,p_order_date => p_rec.order_date
208 ,p_due_date => p_rec.due_date
209 ,p_request_date => p_rec.request_date
210 ,p_complete_date => p_rec.complete_date
211 ,p_category => p_rec.category
212 --,p_type => p_rec.type
213 ,p_phase => p_rec.phase
214 ,p_action_type => p_rec.action_type
215 ,p_payment_type => p_rec.payment_type
216 ,p_object_version_number => p_rec.object_version_number
217 ,p_description => p_rec.description
218 ,p_compl_ca_header_id_o => ghr_cdt_shd.g_old_rec.compl_ca_header_id
219 --,p_action_o => ghr_cdt_shd.g_old_rec.action
220 ,p_amount_o => ghr_cdt_shd.g_old_rec.amount
221 ,p_order_date_o => ghr_cdt_shd.g_old_rec.order_date
222 ,p_due_date_o => ghr_cdt_shd.g_old_rec.due_date
223 ,p_request_date_o => ghr_cdt_shd.g_old_rec.request_date
224 ,p_complete_date_o => ghr_cdt_shd.g_old_rec.complete_date
225 ,p_category_o => ghr_cdt_shd.g_old_rec.category
226 --,p_type_o => ghr_cdt_shd.g_old_rec.type
227 ,p_phase_o => ghr_cdt_shd.g_old_rec.phase
228 ,p_action_type_o => ghr_cdt_shd.g_old_rec.action_type
229 ,p_payment_type_o => ghr_cdt_shd.g_old_rec.payment_type
230 ,p_object_version_number_o => ghr_cdt_shd.g_old_rec.object_version_number
231 ,p_description_o => ghr_cdt_shd.g_old_rec.description
232 );
233 --
234 exception
235 --
236 when hr_api.cannot_find_prog_unit then
237 --
238 hr_api.cannot_find_prog_unit_error
239 (p_module_name => 'GHR_COMPL_CA_DETAILS'
240 ,p_hook_type => 'AU');
241 --
242 end;
243 --
244 hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End post_update;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |-----------------------------< convert_defs >-----------------------------|
249 -- ----------------------------------------------------------------------------
250 -- {Start Of Comments}
251 --
252 -- Description:
253 -- The Convert_Defs procedure has one very important function:
254 -- It must return the record structure for the row with all system defaulted
255 -- values converted into its corresponding parameter value for update. When
256 -- we attempt to update a row through the Upd process , certain
257 -- parameters can be defaulted which enables flexibility in the calling of
258 -- the upd process (e.g. only attributes which need to be updated need to be
259 -- specified). For the upd process to determine which attributes
260 -- have NOT been specified we need to check if the parameter has a reserved
261 -- system default value. Therefore, for all parameters which have a
262 -- corresponding reserved system default mechanism specified we need to
263 -- check if a system default is being used. If a system default is being
264 -- used then we convert the defaulted value into its corresponding attribute
265 -- value held in the g_old_rec data structure.
266 --
267 -- Prerequisites:
268 -- This private function can only be called from the upd process.
269 --
270 -- In Parameters:
271 -- A Pl/Sql record structure.
272 --
273 -- Post Success:
274 -- The record structure will be returned with all system defaulted parameter
275 -- values converted into its current row attribute value.
276 --
277 -- Post Failure:
278 -- No direct error handling is required within this function. Any possible
279 -- errors within this procedure will be a PL/SQL value error due to
280 -- conversion of datatypes or data lengths.
281 --
282 -- Developer Implementation Notes:
283 -- None.
284 --
285 -- Access Status:
286 -- Internal Row Handler Use Only.
287 --
288 -- {End Of Comments}
289 -- ----------------------------------------------------------------------------
290 Procedure convert_defs
291 (p_rec in out nocopy ghr_cdt_shd.g_rec_type
292 ) is
293 --
294 Begin
295 --
296 -- We must now examine each argument value in the
297 -- p_rec plsql record structure
298 -- to see if a system default is being used. If a system default
299 -- is being used then we must set to the 'current' argument value.
300 --
301 If (p_rec.compl_ca_header_id = hr_api.g_number) then
302 p_rec.compl_ca_header_id :=
303 ghr_cdt_shd.g_old_rec.compl_ca_header_id;
304 End If;
305 /*
306 If (p_rec.action = hr_api.g_varchar2) then
307 p_rec.action :=
308 ghr_cdt_shd.g_old_rec.action;
309 End If;
310 */
311 If (p_rec.amount = hr_api.g_number) then
312 p_rec.amount :=
313 ghr_cdt_shd.g_old_rec.amount;
314 End If;
315 If (p_rec.order_date = hr_api.g_date) then
316 p_rec.order_date :=
317 ghr_cdt_shd.g_old_rec.order_date;
318 End If;
319 If (p_rec.due_date = hr_api.g_date) then
320 p_rec.due_date :=
321 ghr_cdt_shd.g_old_rec.due_date;
322 End If;
323 If (p_rec.request_date = hr_api.g_date) then
324 p_rec.request_date :=
325 ghr_cdt_shd.g_old_rec.request_date;
326 End If;
327 If (p_rec.complete_date = hr_api.g_date) then
328 p_rec.complete_date :=
329 ghr_cdt_shd.g_old_rec.complete_date;
330 End If;
331 If (p_rec.category = hr_api.g_varchar2) then
332 p_rec.category :=
333 ghr_cdt_shd.g_old_rec.category;
334 End If;
335 /*
336 If (p_rec.type = hr_api.g_varchar2) then
337 p_rec.type :=
338 ghr_cdt_shd.g_old_rec.type;
339 End If;
340 */
341 If (p_rec.phase = hr_api.g_varchar2) then
342 p_rec.phase :=
343 ghr_cdt_shd.g_old_rec.phase;
344 End If;
345 If (p_rec.action_type = hr_api.g_varchar2) then
346 p_rec.action_type :=
347 ghr_cdt_shd.g_old_rec.action_type;
348 End If;
349 If (p_rec.payment_type = hr_api.g_varchar2) then
350 p_rec.payment_type :=
351 ghr_cdt_shd.g_old_rec.payment_type;
352 End If;
353 If (p_rec.description = hr_api.g_varchar2) then
354 p_rec.description :=
355 ghr_cdt_shd.g_old_rec.description;
356 End If;
357 --
358 End convert_defs;
359 --
360 -- ----------------------------------------------------------------------------
361 -- |---------------------------------< upd >----------------------------------|
362 -- ----------------------------------------------------------------------------
363 Procedure upd
364 (p_effective_date in date
365 ,p_rec in out nocopy ghr_cdt_shd.g_rec_type
366 ) is
367 --
368 l_proc varchar2(72) := g_package||'upd';
369 --
370 Begin
371 hr_utility.set_location('Entering:'||l_proc, 5);
372 --
373 -- We must lock the row which we need to update.
374 --
375 ghr_cdt_shd.lck
376 (p_rec.compl_ca_detail_id
377 ,p_rec.object_version_number
378 );
379 --
380 -- 1. During an update system defaults are used to determine if
381 -- arguments have been defaulted or not. We must therefore
382 -- derive the full record structure values to be updated.
383 --
384 -- 2. Call the supporting update validate operations.
385 --
386 convert_defs(p_rec);
387 ghr_cdt_bus.update_validate
388 (p_effective_date
389 ,p_rec
390 );
391 --
392 -- Call the supporting pre-update operation
393 --
394 ghr_cdt_upd.pre_update(p_rec);
395 --
396 -- Update the row.
397 --
398 ghr_cdt_upd.update_dml(p_rec);
399 --
400 -- Call the supporting post-update operation
401 --
402 ghr_cdt_upd.post_update
403 (p_effective_date
404 ,p_rec
405 );
406 End upd;
407 --
408 -- ----------------------------------------------------------------------------
409 -- |---------------------------------< upd >----------------------------------|
410 -- ----------------------------------------------------------------------------
411 Procedure upd
412 (p_effective_date in date
413 ,p_compl_ca_detail_id in number
414 ,p_object_version_number in out nocopy number
415 ,p_compl_ca_header_id in number
416 --,p_action in varchar2
417 ,p_amount in number
418 ,p_order_date in date
419 ,p_due_date in date
420 ,p_request_date in date
421 ,p_complete_date in date
422 ,p_category in varchar2
423 --,p_type in varchar2
424 ,p_phase in varchar2
425 ,p_action_type in varchar2
426 ,p_payment_type in varchar2
427 ,p_description in varchar2
428 ) is
429 --
430 l_rec ghr_cdt_shd.g_rec_type;
431 l_proc varchar2(72) := g_package||'upd';
432 --
433 Begin
434 hr_utility.set_location('Entering:'||l_proc, 5);
435 --
436 -- Call conversion function to turn arguments into the
437 -- l_rec structure.
438 --
439 l_rec :=
440 ghr_cdt_shd.convert_args
441 (p_compl_ca_detail_id
442 ,p_compl_ca_header_id
443 --,p_action
444 ,p_amount
445 ,p_order_date
446 ,p_due_date
447 ,p_request_date
448 ,p_complete_date
449 ,p_category
450 --,p_type
451 ,p_phase
452 ,p_action_type
453 ,p_payment_type
454 ,p_object_version_number
455 ,p_description
456 );
457 --
458 -- Having converted the arguments into the
459 -- plsql record structure we call the corresponding record
460 -- business process.
461 --
462 ghr_cdt_upd.upd
463 (p_effective_date
464 ,l_rec
465 );
466 p_object_version_number := l_rec.object_version_number;
467 --
468 hr_utility.set_location(' Leaving:'||l_proc, 10);
469 End upd;
470 --
471 end ghr_cdt_upd;