1 Package Body pay_amo_upd as
2 /* $Header: pyamorhi.pkb 120.0.12000000.1 2007/01/17 15:29:33 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33); -- 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_amo_shd.g_rec_type
56 ) is
57 --
58 l_proc varchar2(72);
59 --
60 Begin
61 l_proc := g_package||'update_dml';
62 --
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 --
65 -- Increment the object version
66 p_rec.object_version_number := p_rec.object_version_number + 1;
67 --
68 pay_amo_shd.g_api_dml := true; -- Set the api dml status
69 --
70 -- Update the pay_au_modules Row
71 --
72 update pay_au_modules
73 set
74 module_id = p_rec.module_id
75 ,name = p_rec.name
76 ,enabled_flag = p_rec.enabled_flag
77 ,module_type_id = p_rec.module_type_id
78 ,business_group_id = p_rec.business_group_id
79 ,legislation_code = p_rec.legislation_code
80 ,description = p_rec.description
81 ,package_name = p_rec.package_name
82 ,procedure_function_name = p_rec.procedure_function_name
83 ,formula_name = p_rec.formula_name
84 ,object_version_number = p_rec.object_version_number
85 where module_id = p_rec.module_id;
86 --
87 pay_amo_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 pay_amo_shd.g_api_dml := false; -- Unset the api dml status
95 pay_amo_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 pay_amo_shd.g_api_dml := false; -- Unset the api dml status
100 pay_amo_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 pay_amo_shd.g_api_dml := false; -- Unset the api dml status
105 pay_amo_shd.constraint_error
106 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107 When Others Then
108 pay_amo_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 pay_amo_shd.g_rec_type
146 ) is
147 --
148 l_proc varchar2(72);
149 --
150 Begin
151 l_proc := g_package||'pre_update';
152 --
153 hr_utility.set_location('Entering:'||l_proc, 5);
154 --
155 hr_utility.set_location(' Leaving:'||l_proc, 10);
156 End pre_update;
157 --
158 -- ----------------------------------------------------------------------------
159 -- |-----------------------------< post_update >------------------------------|
160 -- ----------------------------------------------------------------------------
161 -- {Start Of Comments}
162 --
163 -- Description:
164 -- This private procedure contains any processing which is required after
165 -- the update dml.
166 --
167 -- Prerequisites:
168 -- This is an internal procedure which is called from the upd procedure.
169 --
170 -- In Parameters:
171 -- A Pl/Sql record structure.
172 --
173 -- Post Success:
174 -- Processing continues.
175 --
176 -- Post Failure:
177 -- If an error has occurred, an error message and exception will be raised
178 -- but not handled.
179 --
180 -- Developer Implementation Notes:
181 -- Any post-processing required after the update dml is issued should be
182 -- coded within this procedure. It is important to note that any 3rd party
183 -- maintenance should be reviewed before placing in this procedure.
184 --
185 -- Access Status:
186 -- Internal Row Handler Use Only.
187 --
188 -- {End Of Comments}
189 -- ----------------------------------------------------------------------------
190 Procedure post_update
191 (p_rec in pay_amo_shd.g_rec_type
192 ) is
193 --
194 l_proc varchar2(72);
195 --
196 Begin
197 l_proc := g_package||'post_update';
198 --
199 hr_utility.set_location('Entering:'||l_proc, 5);
200 --
201 hr_utility.set_location(' Leaving:'||l_proc, 10);
202 End post_update;
203 --
204 -- ----------------------------------------------------------------------------
205 -- |-----------------------------< convert_defs >-----------------------------|
206 -- ----------------------------------------------------------------------------
207 -- {Start Of Comments}
208 --
209 -- Description:
210 -- The Convert_Defs procedure has one very important function:
211 -- It must return the record structure for the row with all system defaulted
212 -- values converted into its corresponding parameter value for update. When
213 -- we attempt to update a row through the Upd process , certain
214 -- parameters can be defaulted which enables flexibility in the calling of
215 -- the upd process (e.g. only attributes which need to be updated need to be
216 -- specified). For the upd process to determine which attributes
217 -- have NOT been specified we need to check if the parameter has a reserved
218 -- system default value. Therefore, for all parameters which have a
219 -- corresponding reserved system default mechanism specified we need to
220 -- check if a system default is being used. If a system default is being
221 -- used then we convert the defaulted value into its corresponding attribute
222 -- value held in the g_old_rec data structure.
223 --
224 -- Prerequisites:
225 -- This private function can only be called from the upd process.
226 --
227 -- In Parameters:
228 -- A Pl/Sql record structure.
229 --
230 -- Post Success:
231 -- The record structure will be returned with all system defaulted parameter
232 -- values converted into its current row attribute value.
233 --
234 -- Post Failure:
235 -- No direct error handling is required within this function. Any possible
236 -- errors within this procedure will be a PL/SQL value error due to
237 -- conversion of datatypes or data lengths.
238 --
239 -- Developer Implementation Notes:
240 -- None.
241 --
242 -- Access Status:
243 -- Internal Row Handler Use Only.
244 --
245 -- {End Of Comments}
246 -- ----------------------------------------------------------------------------
247 Procedure convert_defs
248 (p_rec in out nocopy pay_amo_shd.g_rec_type
249 ) is
250 --
251 Begin
252 --
253 -- We must now examine each argument value in the
254 -- p_rec plsql record structure
255 -- to see if a system default is being used. If a system default
256 -- is being used then we must set to the 'current' argument value.
257 --
258 If (p_rec.name = hr_api.g_varchar2) then
259 p_rec.name :=
260 pay_amo_shd.g_old_rec.name;
261 End If;
262 If (p_rec.enabled_flag = hr_api.g_varchar2) then
263 p_rec.enabled_flag :=
264 pay_amo_shd.g_old_rec.enabled_flag;
265 End If;
266 If (p_rec.module_type_id = hr_api.g_number) then
267 p_rec.module_type_id :=
268 pay_amo_shd.g_old_rec.module_type_id;
269 End If;
270 If (p_rec.business_group_id = hr_api.g_number) then
271 p_rec.business_group_id :=
272 pay_amo_shd.g_old_rec.business_group_id;
273 End If;
274 If (p_rec.legislation_code = hr_api.g_varchar2) then
275 p_rec.legislation_code :=
276 pay_amo_shd.g_old_rec.legislation_code;
277 End If;
278 If (p_rec.description = hr_api.g_varchar2) then
279 p_rec.description :=
280 pay_amo_shd.g_old_rec.description;
281 End If;
282 If (p_rec.package_name = hr_api.g_varchar2) then
283 p_rec.package_name :=
284 pay_amo_shd.g_old_rec.package_name;
285 End If;
286 If (p_rec.procedure_function_name = hr_api.g_varchar2) then
287 p_rec.procedure_function_name :=
288 pay_amo_shd.g_old_rec.procedure_function_name;
289 End If;
290 If (p_rec.formula_name = hr_api.g_varchar2) then
291 p_rec.formula_name :=
292 pay_amo_shd.g_old_rec.formula_name;
293 End If;
294 --
295 End convert_defs;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |---------------------------------< upd >----------------------------------|
299 -- ----------------------------------------------------------------------------
300 Procedure upd
301 (p_rec in out nocopy pay_amo_shd.g_rec_type
302 ) is
303 --
304 l_proc varchar2(72);
305 --
306 Begin
307 l_proc := g_package||'upd';
308 --
309 hr_utility.set_location('Entering:'||l_proc, 5);
310 --
311 -- We must lock the row which we need to update.
312 --
313 pay_amo_shd.lck
314 (p_rec.module_id
315 ,p_rec.object_version_number
316 );
317 --
318 -- 1. During an update system defaults are used to determine if
319 -- arguments have been defaulted or not. We must therefore
320 -- derive the full record structure values to be updated.
321 --
322 -- 2. Call the supporting update validate operations.
323 --
324 convert_defs(p_rec);
325 pay_amo_bus.update_validate
326 (p_rec
327 );
328 --
329 -- Call to raise any errors on multi-message list
330 hr_multi_message.end_validation_set;
331 --
332 -- Call the supporting pre-update operation
333 --
334 pay_amo_upd.pre_update(p_rec);
335 --
336 -- Update the row.
337 --
338 pay_amo_upd.update_dml(p_rec);
339 --
340 -- Call the supporting post-update operation
341 --
342 pay_amo_upd.post_update
343 (p_rec
344 );
345 --
346 -- Call to raise any errors on multi-message list
347 hr_multi_message.end_validation_set;
348 End upd;
349 --
350 -- ----------------------------------------------------------------------------
351 -- |---------------------------------< upd >----------------------------------|
352 -- ----------------------------------------------------------------------------
353 Procedure upd
354 (p_module_id in number
355 ,p_object_version_number in out nocopy number
356 ,p_name in varchar2
357 ,p_enabled_flag in varchar2
358 ,p_module_type_id in number
359 ,p_business_group_id in number
360 ,p_legislation_code in varchar2
361 ,p_description in varchar2
362 ,p_package_name in varchar2
363 ,p_procedure_function_name in varchar2
364 ,p_formula_name in varchar2
365 ) is
366 --
367 l_rec pay_amo_shd.g_rec_type;
368 l_proc varchar2(72);
369 --
370 Begin
371 l_proc := g_package||'upd';
372 hr_utility.set_location('Entering:'||l_proc, 5);
373 --
374 -- Call conversion function to turn arguments into the
375 -- l_rec structure.
376 --
377 l_rec :=
378 pay_amo_shd.convert_args
379 (p_module_id
380 ,p_name
381 ,p_enabled_flag
382 ,p_module_type_id
383 ,p_business_group_id
384 ,p_legislation_code
385 ,p_description
386 ,p_package_name
387 ,p_procedure_function_name
388 ,p_formula_name
389 ,p_object_version_number
390 );
391 --
392 -- Having converted the arguments into the
393 -- plsql record structure we call the corresponding record
394 -- business process.
395 --
396 pay_amo_upd.upd
397 (l_rec
398 );
399 p_object_version_number := l_rec.object_version_number;
400 --
401 hr_utility.set_location(' Leaving:'||l_proc, 10);
402 End upd;
403 --
404 begin
405 g_package := ' pay_amo_upd.'; -- Global package name
406 end pay_amo_upd;