1 Package Body pqh_txh_upd as
2 /* $Header: pqtxhrhi.pkb 120.2 2005/12/21 11:29:59 hpandya noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_txh_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_txh_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 --
64 --
65 --
66 -- Update the pqh_ss_transaction_history Row
67 --
68 update pqh_ss_transaction_history
69 set
70 transaction_history_id = p_rec.transaction_history_id
71 ,creator_person_id = p_rec.creator_person_id
72 ,assignment_id = p_rec.assignment_id
73 ,selected_person_id = p_rec.selected_person_id
74 ,item_type = p_rec.item_type
75 ,item_key = p_rec.item_key
76 ,process_name = p_rec.process_name
77 ,approval_item_type = p_rec.approval_item_type
78 ,approval_item_key = p_rec.approval_item_key
79 ,function_id = p_rec.function_id
80 ,rptg_grp_id = p_rec.rptg_grp_id
81 ,plan_id = p_rec.plan_id
82 ,transaction_group = p_rec.transaction_group
83 ,transaction_identifier = p_rec.transaction_identifier
84 where transaction_history_id = p_rec.transaction_history_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 pqh_txh_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 pqh_txh_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 pqh_txh_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 pqh_txh_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
162 -- the 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 pqh_txh_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 null;
198 --
199 exception
200 --
201 when hr_api.cannot_find_prog_unit then
202 --
203 hr_api.cannot_find_prog_unit_error
204 (p_module_name => 'PQH_SS_TRANSACTION_HISTORY'
205 ,p_hook_type => 'AU');
206 --
207 end;
208 --
209 hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End post_update;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |-----------------------------< convert_defs >-----------------------------|
214 -- ----------------------------------------------------------------------------
215 -- {Start Of Comments}
216 --
217 -- Description:
218 -- The Convert_Defs procedure has one very important function:
219 -- It must return the record structure for the row with all system defaulted
220 -- values converted into its corresponding parameter value for update. When
221 -- we attempt to update a row through the Upd process , certain
222 -- parameters can be defaulted which enables flexibility in the calling of
223 -- the upd process (e.g. only attributes which need to be updated need to be
224 -- specified). For the upd process to determine which attributes
225 -- have NOT been specified we need to check if the parameter has a reserved
226 -- system default value. Therefore, for all parameters which have a
227 -- corresponding reserved system default mechanism specified we need to
228 -- check if a system default is being used. If a system default is being
229 -- used then we convert the defaulted value into its corresponding attribute
230 -- value held in the g_old_rec data structure.
231 --
232 -- Prerequisites:
233 -- This private function can only be called from the upd process.
234 --
235 -- In Parameters:
236 -- A Pl/Sql record structure.
237 --
238 -- Post Success:
239 -- The record structure will be returned with all system defaulted parameter
240 -- values converted into its current row attribute value.
241 --
242 -- Post Failure:
243 -- No direct error handling is required within this function. Any possible
244 -- errors within this procedure will be a PL/SQL value error due to
245 -- conversion of datatypes or data lengths.
246 --
247 -- Developer Implementation Notes:
248 -- None.
249 --
250 -- Access Status:
251 -- Internal Row Handler Use Only.
252 --
253 -- {End Of Comments}
254 -- ----------------------------------------------------------------------------
255 Procedure convert_defs
256 (p_rec in out nocopy pqh_txh_shd.g_rec_type
257 ) is
258 --
259 Begin
260 --
261 -- We must now examine each argument value in the
262 -- p_rec plsql record structure
263 -- to see if a system default is being used. If a system default
264 -- is being used then we must set to the 'current' argument value.
265 --
266 If (p_rec.creator_person_id = hr_api.g_number) then
267 p_rec.creator_person_id :=
268 pqh_txh_shd.g_old_rec.creator_person_id;
269 End If;
270 If (p_rec.assignment_id = hr_api.g_number) then
271 p_rec.assignment_id :=
272 pqh_txh_shd.g_old_rec.assignment_id;
273 End If;
274 If (p_rec.selected_person_id = hr_api.g_number) then
275 p_rec.selected_person_id :=
276 pqh_txh_shd.g_old_rec.selected_person_id;
277 End If;
278 If (p_rec.item_type = hr_api.g_varchar2) then
279 p_rec.item_type :=
280 pqh_txh_shd.g_old_rec.item_type;
281 End If;
282 If (p_rec.item_key = hr_api.g_varchar2) then
283 p_rec.item_key :=
284 pqh_txh_shd.g_old_rec.item_key;
285 End If;
286 If (p_rec.process_name = hr_api.g_varchar2) then
287 p_rec.process_name :=
288 pqh_txh_shd.g_old_rec.process_name;
289 End If;
290 If (p_rec.approval_item_type = hr_api.g_varchar2) then
291 p_rec.approval_item_type :=
292 pqh_txh_shd.g_old_rec.approval_item_type;
293 End If;
294 If (p_rec.approval_item_key = hr_api.g_varchar2) then
295 p_rec.approval_item_key :=
296 pqh_txh_shd.g_old_rec.approval_item_key;
297 End If;
298 If (p_rec.function_id = hr_api.g_number) then
299 p_rec.function_id :=
300 pqh_txh_shd.g_old_rec.function_id;
301 End If;
302 If (p_rec.rptg_grp_id = hr_api.g_number) then
303 p_rec.rptg_grp_id :=
304 pqh_txh_shd.g_old_rec.rptg_grp_id;
305 End If;
306 If (p_rec.plan_id = hr_api.g_number) then
307 p_rec.plan_id :=
308 pqh_txh_shd.g_old_rec.plan_id;
309 End If;
310 If (p_rec.transaction_group = hr_api.g_varchar2) then
311 p_rec.transaction_group :=
312 pqh_txh_shd.g_old_rec.transaction_group;
313 End If;
314 If (p_rec.transaction_identifier = hr_api.g_varchar2) then
315 p_rec.transaction_identifier :=
316 pqh_txh_shd.g_old_rec.transaction_identifier;
317 End If;
318 --
319 End convert_defs;
320 --
321 -- ----------------------------------------------------------------------------
322 -- |---------------------------------< upd >----------------------------------|
323 -- ----------------------------------------------------------------------------
324 Procedure upd
325 (p_rec in out nocopy pqh_txh_shd.g_rec_type
326 ) is
327 --
328 l_proc varchar2(72) := g_package||'upd';
329 --
330 Begin
331 hr_utility.set_location('Entering:'||l_proc, 5);
332 --
333 -- We must lock the row which we need to update.
334 --
335 pqh_txh_shd.lck
336 (p_rec.transaction_history_id
337 );
338 --
339 -- 1. During an update system defaults are used to determine if
340 -- arguments have been defaulted or not. We must therefore
341 -- derive the full record structure values to be updated.
342 --
343 -- 2. Call the supporting update validate operations.
344 --
345 convert_defs(p_rec);
346 pqh_txh_bus.update_validate
347 (p_rec
348 );
349 --
350 -- Call to raise any errors on multi-message list
351 hr_multi_message.end_validation_set;
352 --
353 -- Call the supporting pre-update operation
354 --
355 pqh_txh_upd.pre_update(p_rec);
356 --
357 -- Update the row.
358 --
359 pqh_txh_upd.update_dml(p_rec);
360 --
361 -- Call the supporting post-update operation
362 --
363 pqh_txh_upd.post_update
364 (p_rec
365 );
366 --
367 -- Call to raise any errors on multi-message list
368 hr_multi_message.end_validation_set;
369 End upd;
370 --
371 -- ----------------------------------------------------------------------------
372 -- |---------------------------------< upd >----------------------------------|
373 -- ----------------------------------------------------------------------------
374 Procedure upd
375 (p_transaction_history_id in number
376 ,p_creator_person_id in number default hr_api.g_number
377 ,p_assignment_id in number default hr_api.g_number
378 ,p_selected_person_id in number default hr_api.g_number
379 ,p_item_type in varchar2 default hr_api.g_varchar2
380 ,p_item_key in varchar2 default hr_api.g_varchar2
381 ,p_process_name in varchar2 default hr_api.g_varchar2
382 ,p_approval_item_type in varchar2 default hr_api.g_varchar2
383 ,p_approval_item_key in varchar2 default hr_api.g_varchar2
384 ,p_function_id in number default hr_api.g_number
385 ,p_rptg_grp_id in number default hr_api.g_number
386 ,p_plan_id in number default hr_api.g_number
387 ,p_transaction_group in varchar2 default hr_api.g_varchar2
388 ,p_transaction_identifier in varchar2 default hr_api.g_varchar2
389 ) is
390 --
391 l_rec pqh_txh_shd.g_rec_type;
392 l_proc varchar2(72) := g_package||'upd';
393 --
394 Begin
395 hr_utility.set_location('Entering:'||l_proc, 5);
396 --
397 -- Call conversion function to turn arguments into the
398 -- l_rec structure.
399 --
400 l_rec :=
401 pqh_txh_shd.convert_args
402 (p_transaction_history_id
403 ,p_creator_person_id
404 ,p_assignment_id
405 ,p_selected_person_id
406 ,p_item_type
407 ,p_item_key
408 ,p_process_name
409 ,p_approval_item_type
410 ,p_approval_item_key
411 ,p_function_id
412 ,p_rptg_grp_id
413 ,p_plan_id
414 ,p_transaction_group
415 ,p_transaction_identifier
416 );
417 --
418 -- Having converted the arguments into the
419 -- plsql record structure we call the corresponding record
420 -- business process.
421 --
422 pqh_txh_upd.upd
423 (l_rec
424 );
425 --
426 --
427 hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End upd;
429 --
430 end pqh_txh_upd;