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