1 Package Body pqh_rct_upd as
2 /* $Header: pqrctrhi.pkb 115.24 2004/02/19 13:29:18 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rct_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 update the specified row in the schema using the primary key in
21 -- the predicates.
22 -- 3) To trap any constraint violations that may have occurred.
23 -- 4) To raise any other errors.
24 --
25 -- Prerequisites:
26 -- This is an internal private procedure which must be called from the upd
27 -- procedure.
28 --
29 -- In Parameters:
30 -- A Pl/Sql record structre.
31 --
32 -- Post Success:
33 -- The specified row will be updated in the schema.
34 --
35 -- Post Failure:
36 -- If a check, unique or parent integrity constraint violation is raised the
37 -- constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 -- The update 'set' attribute list should be modified if any of your
41 -- attributes are not updateable.
42 --
43 -- Access Status:
44 -- Internal Row Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out nocopy pqh_rct_shd.g_rec_type) is
49 --
50 l_proc varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53 hr_utility.set_location('Entering:'||l_proc, 5);
54 --
55 -- Increment the object version
56 --
57 p_rec.object_version_number := p_rec.object_version_number + 1;
58 --
59 --
60 -- Update the pqh_routing_categories Row
61 --
62 update pqh_routing_categories
63 set
64 routing_category_id = p_rec.routing_category_id,
65 transaction_category_id = p_rec.transaction_category_id,
66 enable_flag = p_rec.enable_flag,
67 default_flag = p_rec.default_flag,
68 delete_flag = p_rec.delete_flag,
69 routing_list_id = p_rec.routing_list_id,
70 position_structure_id = p_rec.position_structure_id,
71 override_position_id = p_rec.override_position_id,
72 override_assignment_id = p_rec.override_assignment_id,
73 override_role_id = p_rec.override_role_id,
74 override_user_id = p_rec.override_user_id,
75 object_version_number = p_rec.object_version_number
76 where routing_category_id = p_rec.routing_category_id;
77 --
78 --
79 hr_utility.set_location(' Leaving:'||l_proc, 10);
80 --
81 Exception
82 When hr_api.check_integrity_violated Then
83 -- A check constraint has been violated
84 pqh_rct_shd.constraint_error
85 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86 When hr_api.parent_integrity_violated Then
87 -- Parent integrity has been violated
88 pqh_rct_shd.constraint_error
89 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90 When hr_api.unique_integrity_violated Then
91 -- Unique integrity has been violated
92 pqh_rct_shd.constraint_error
93 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94 When Others Then
95 Raise;
96 End update_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- |------------------------------< pre_update >------------------------------|
100 -- ----------------------------------------------------------------------------
101 -- {Start Of Comments}
102 --
103 -- Description:
104 -- This private procedure contains any processing which is required before
105 -- the update dml.
106 --
107 -- Prerequisites:
108 -- This is an internal procedure which is called from the upd procedure.
109 --
110 -- In Parameters:
111 -- A Pl/Sql record structre.
112 --
113 -- Post Success:
114 -- Processing continues.
115 --
116 -- Post Failure:
117 -- If an error has occurred, an error message and exception will be raised
118 -- but not handled.
119 --
120 -- Developer Implementation Notes:
121 -- Any pre-processing required before the update dml is issued should be
122 -- coded within this procedure. It is important to note that any 3rd party
123 -- maintenance should be reviewed before placing in this procedure.
124 --
125 -- Access Status:
126 -- Internal Row Handler Use Only.
127 --
128 -- {End Of Comments}
129 -- ----------------------------------------------------------------------------
130 Procedure pre_update(p_rec in pqh_rct_shd.g_rec_type) is
131 --
132 l_proc varchar2(72) := g_package||'pre_update';
133 --
134 Begin
135 hr_utility.set_location('Entering:'||l_proc, 5);
136 --
137 hr_utility.set_location(' Leaving:'||l_proc, 10);
138 End pre_update;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |-----------------------------< post_update >------------------------------|
142 -- ----------------------------------------------------------------------------
143 -- {Start Of Comments}
144 --
145 -- Description:
146 -- This private procedure contains any processing which is required after the
147 -- update dml.
148 --
149 -- Prerequisites:
150 -- This is an internal procedure which is called from the upd procedure.
151 --
152 -- In Parameters:
153 -- A Pl/Sql record structre.
154 --
155 -- Post Success:
156 -- Processing continues.
157 --
158 -- Post Failure:
159 -- If an error has occurred, an error message and exception will be raised
160 -- but not handled.
161 --
162 -- Developer Implementation Notes:
163 -- Any post-processing required after the update dml is issued should be
164 -- coded within this procedure. It is important to note that any 3rd party
165 -- maintenance should be reviewed before placing in this procedure.
166 --
167 -- Access Status:
168 -- Internal Row Handler Use Only.
169 --
170 -- {End Of Comments}
171 -- ----------------------------------------------------------------------------
172 Procedure post_update(p_effective_date in date,p_rec in pqh_rct_shd.g_rec_type) is
173 --
174 l_proc varchar2(72) := g_package||'post_update';
175 --
176 Begin
177 hr_utility.set_location('Entering:'||l_proc, 5);
178 --
179 --
180 -- Start of API User Hook for post_update.
181 --
182 begin
183 --
184 pqh_rct_rku.after_update
185 (
186 p_routing_category_id =>p_rec.routing_category_id
187 ,p_transaction_category_id =>p_rec.transaction_category_id
188 ,p_enable_flag =>p_rec.enable_flag
189 ,p_default_flag =>p_rec.default_flag
190 ,p_delete_flag =>p_rec.delete_flag
191 ,p_routing_list_id =>p_rec.routing_list_id
192 ,p_position_structure_id =>p_rec.position_structure_id
193 ,p_override_position_id =>p_rec.override_position_id
194 ,p_override_assignment_id =>p_rec.override_assignment_id
195 ,p_override_role_id =>p_rec.override_role_id
196 ,p_override_user_id =>p_rec.override_user_id
197 ,p_object_version_number =>p_rec.object_version_number
198 ,p_effective_date =>p_effective_date
199 ,p_transaction_category_id_o =>pqh_rct_shd.g_old_rec.transaction_category_id
200 ,p_enable_flag_o =>pqh_rct_shd.g_old_rec.enable_flag
201 ,p_default_flag_o =>pqh_rct_shd.g_old_rec.default_flag
202 ,p_delete_flag_o =>pqh_rct_shd.g_old_rec.delete_flag
203 ,p_routing_list_id_o =>pqh_rct_shd.g_old_rec.routing_list_id
204 ,p_position_structure_id_o =>pqh_rct_shd.g_old_rec.position_structure_id
205 ,p_override_position_id_o =>pqh_rct_shd.g_old_rec.override_position_id
206 ,p_override_assignment_id_o =>pqh_rct_shd.g_old_rec.override_assignment_id
207 ,p_override_role_id_o =>pqh_rct_shd.g_old_rec.override_role_id
208 ,p_override_user_id_o =>pqh_rct_shd.g_old_rec.override_user_id
209 ,p_object_version_number_o =>pqh_rct_shd.g_old_rec.object_version_number
210 );
211 --
212 exception
213 --
214 when hr_api.cannot_find_prog_unit then
215 --
216 hr_api.cannot_find_prog_unit_error
217 (p_module_name => 'pqh_routing_categories'
218 ,p_hook_type => 'AU');
219 --
220 end;
221 --
222 -- End of API User Hook for post_update.
223 --
224 --
225 hr_utility.set_location(' Leaving:'||l_proc, 10);
226 End post_update;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |-----------------------------< convert_defs >-----------------------------|
230 -- ----------------------------------------------------------------------------
231 -- {Start Of Comments}
232 --
233 -- Description:
234 -- The Convert_Defs procedure has one very important function:
235 -- It must return the record structure for the row with all system defaulted
236 -- values converted into its corresponding parameter value for update. When
237 -- we attempt to update a row through the Upd process , certain
238 -- parameters can be defaulted which enables flexibility in the calling of
239 -- the upd process (e.g. only attributes which need to be updated need to be
240 -- specified). For the upd process to determine which attributes
241 -- have NOT been specified we need to check if the parameter has a reserved
242 -- system default value. Therefore, for all parameters which have a
243 -- corresponding reserved system default mechanism specified we need to
244 -- check if a system default is being used. If a system default is being
245 -- used then we convert the defaulted value into its corresponding attribute
246 -- value held in the g_old_rec data structure.
247 --
248 -- Prerequisites:
249 -- This private function can only be called from the upd process.
250 --
251 -- In Parameters:
252 -- A Pl/Sql record structre.
253 --
254 -- Post Success:
255 -- The record structure will be returned with all system defaulted parameter
256 -- values converted into its current row attribute value.
257 --
258 -- Post Failure:
259 -- No direct error handling is required within this function. Any possible
260 -- errors within this procedure will be a PL/SQL value error due to conversion
261 -- of datatypes or data lengths.
262 --
263 -- Developer Implementation Notes:
264 -- None.
265 --
266 -- Access Status:
267 -- Internal Row Handler Use Only.
268 --
269 -- {End Of Comments}
270 -- ----------------------------------------------------------------------------
271 Procedure convert_defs(p_rec in out nocopy pqh_rct_shd.g_rec_type) is
272 --
273 l_proc varchar2(72) := g_package||'convert_defs';
274 --
275 Begin
276 --
277 hr_utility.set_location('Entering:'||l_proc, 5);
278 --
279 -- We must now examine each argument value in the
280 -- p_rec plsql record structure
281 -- to see if a system default is being used. If a system default
282 -- is being used then we must set to the 'current' argument value.
283 --
284 If (p_rec.transaction_category_id = hr_api.g_number) then
285 p_rec.transaction_category_id :=
286 pqh_rct_shd.g_old_rec.transaction_category_id;
287 End If;
288 If (p_rec.enable_flag = hr_api.g_varchar2) then
289 p_rec.enable_flag :=
290 pqh_rct_shd.g_old_rec.enable_flag;
291 End If;
292 If (p_rec.default_flag = hr_api.g_varchar2) then
293 p_rec.default_flag :=
294 pqh_rct_shd.g_old_rec.default_flag;
295 End If;
296 If (p_rec.delete_flag = hr_api.g_varchar2) then
297 p_rec.delete_flag :=
298 pqh_rct_shd.g_old_rec.delete_flag;
299 End If;
300 If (p_rec.routing_list_id = hr_api.g_number) then
301 p_rec.routing_list_id :=
302 pqh_rct_shd.g_old_rec.routing_list_id;
303 End If;
304 If (p_rec.position_structure_id = hr_api.g_number) then
305 p_rec.position_structure_id :=
306 pqh_rct_shd.g_old_rec.position_structure_id;
307 End If;
308 If (p_rec.override_position_id = hr_api.g_number) then
309 p_rec.override_position_id :=
310 pqh_rct_shd.g_old_rec.override_position_id;
311 End If;
312 If (p_rec.override_assignment_id = hr_api.g_number) then
313 p_rec.override_assignment_id :=
314 pqh_rct_shd.g_old_rec.override_assignment_id;
315 End If;
316 If (p_rec.override_role_id = hr_api.g_number) then
317 p_rec.override_role_id :=
318 pqh_rct_shd.g_old_rec.override_role_id;
319 End If;
320 If (p_rec.override_user_id = hr_api.g_number) then
321 p_rec.override_user_id :=
322 pqh_rct_shd.g_old_rec.override_user_id;
323 End If;
324
325 --
326 hr_utility.set_location(' Leaving:'||l_proc, 10);
327 --
328 End convert_defs;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------------< upd >----------------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure upd
334 (
335 p_effective_date in date,
336 p_rec in out nocopy pqh_rct_shd.g_rec_type
337 ) is
338 --
339 l_proc varchar2(72) := g_package||'upd';
340 --
341 Begin
342 hr_utility.set_location('Entering:'||l_proc, 5);
343 --
344 -- We must lock the row which we need to update.
345 --
346 pqh_rct_shd.lck
347 (
348 p_rec.routing_category_id,
349 p_rec.object_version_number
350 );
351 --
352 -- 1. During an update system defaults are used to determine if
353 -- arguments have been defaulted or not. We must therefore
354 -- derive the full record structure values to be updated.
355 --
356 -- 2. Call the supporting update validate operations.
357 --
358 convert_defs(p_rec);
359 pqh_rct_bus.update_validate(p_rec,p_effective_date);
360 --
361 -- Call the supporting pre-update operation
362 --
363 pre_update(p_rec);
364 --
365 -- Update the row.
366 --
367 update_dml(p_rec);
368 --
369 -- Call the supporting post-update operation
370 --
371 post_update(p_effective_date,p_rec);
372 End upd;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------------< upd >----------------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure upd
378 (
379 p_effective_date in date,
380 p_routing_category_id in number,
381 p_transaction_category_id in number default hr_api.g_number,
382 p_enable_flag in varchar2 default hr_api.g_varchar2,
383 p_default_flag in varchar2 default hr_api.g_varchar2,
384 p_delete_flag in varchar2 default hr_api.g_varchar2,
385 p_routing_list_id in number default hr_api.g_number,
386 p_position_structure_id in number default hr_api.g_number,
387 p_override_position_id in number default hr_api.g_number,
388 p_override_assignment_id in number default hr_api.g_number,
389 p_override_role_id in number default hr_api.g_number,
390 p_override_user_id in number default hr_api.g_number,
391 p_object_version_number in out nocopy number
392 ) is
393 --
394 l_rec pqh_rct_shd.g_rec_type;
395 l_proc varchar2(72) := g_package||'upd';
396 --
397 Begin
398 hr_utility.set_location('Entering:'||l_proc, 5);
399 --
400 -- Call conversion function to turn arguments into the
401 -- l_rec structure.
402 --
403 l_rec :=
404 pqh_rct_shd.convert_args
405 (
406 p_routing_category_id,
407 p_transaction_category_id,
408 p_enable_flag,
409 p_default_flag,
410 p_delete_flag,
411 p_routing_list_id,
412 p_position_structure_id,
413 p_override_position_id,
414 p_override_assignment_id,
415 p_override_role_id,
416 p_override_user_id,
417 p_object_version_number
418 );
419 --
420 -- Having converted the arguments into the
421 -- plsql record structure we call the corresponding record
422 -- business process.
423 --
424 upd(p_effective_date,l_rec);
425 p_object_version_number := l_rec.object_version_number;
426 --
427 hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End upd;
429 --
430 end pqh_rct_upd;