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