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