1 Package Body pay_apr_upd as
2 /* $Header: pyaprrhi.pkb 120.0.12000000.1 2007/01/17 15:39:22 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_apr_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_apr_shd.g_api_dml := true; -- Set the api dml status
69 --
70 -- Update the pay_au_processes Row
71 --
72 update pay_au_processes
73 set
74 process_id = p_rec.process_id
75 ,short_name = p_rec.short_name
76 ,name = p_rec.name
77 ,enabled_flag = p_rec.enabled_flag
78 ,business_group_id = p_rec.business_group_id
79 ,legislation_code = p_rec.legislation_code
80 ,description = p_rec.description
81 ,accrual_category = p_rec.accrual_category
82 ,object_version_number = p_rec.object_version_number
83 where process_id = p_rec.process_id;
84 --
85 pay_apr_shd.g_api_dml := false; -- Unset the api dml status
86 --
87 hr_utility.set_location(' Leaving:'||l_proc, 10);
88 --
89 Exception
90 When hr_api.check_integrity_violated Then
91 -- A check constraint has been violated
92 pay_apr_shd.g_api_dml := false; -- Unset the api dml status
93 pay_apr_shd.constraint_error
94 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95 When hr_api.parent_integrity_violated Then
96 -- Parent integrity has been violated
97 pay_apr_shd.g_api_dml := false; -- Unset the api dml status
98 pay_apr_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When hr_api.unique_integrity_violated Then
101 -- Unique integrity has been violated
102 pay_apr_shd.g_api_dml := false; -- Unset the api dml status
103 pay_apr_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When Others Then
106 pay_apr_shd.g_api_dml := false; -- Unset the api dml status
107 Raise;
108 End update_dml;
109 --
110 -- ----------------------------------------------------------------------------
111 -- |------------------------------< pre_update >------------------------------|
112 -- ----------------------------------------------------------------------------
113 -- {Start Of Comments}
114 --
115 -- Description:
116 -- This private procedure contains any processing which is required before
117 -- the update dml.
118 --
119 -- Prerequisites:
120 -- This is an internal procedure which is called from the upd procedure.
121 --
122 -- In Parameters:
123 -- A Pl/Sql record structure.
124 --
125 -- Post Success:
126 -- Processing continues.
127 --
128 -- Post Failure:
129 -- If an error has occurred, an error message and exception wil be raised
130 -- but not handled.
131 --
132 -- Developer Implementation Notes:
133 -- Any pre-processing required before the update dml is issued should be
134 -- coded within this procedure. It is important to note that any 3rd party
135 -- maintenance should be reviewed before placing in this procedure.
136 --
137 -- Access Status:
138 -- Internal Row Handler Use Only.
139 --
140 -- {End Of Comments}
141 -- ----------------------------------------------------------------------------
142 Procedure pre_update
143 (p_rec in pay_apr_shd.g_rec_type
144 ) is
145 --
146 l_proc varchar2(72);
147 --
148 Begin
149 l_proc := g_package||'pre_update';
150 --
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_rec in pay_apr_shd.g_rec_type
190 ) is
191 --
192 l_proc varchar2(72);
193 --
194 Begin
195 l_proc := g_package||'post_update';
196 --
197 hr_utility.set_location('Entering:'||l_proc, 5);
198 --
199 hr_utility.set_location(' Leaving:'||l_proc, 10);
200 End post_update;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |-----------------------------< convert_defs >-----------------------------|
204 -- ----------------------------------------------------------------------------
205 -- {Start Of Comments}
206 --
207 -- Description:
208 -- The Convert_Defs procedure has one very important function:
209 -- It must return the record structure for the row with all system defaulted
210 -- values converted into its corresponding parameter value for update. When
211 -- we attempt to update a row through the Upd process , certain
212 -- parameters can be defaulted which enables flexibility in the calling of
213 -- the upd process (e.g. only attributes which need to be updated need to be
214 -- specified). For the upd process to determine which attributes
215 -- have NOT been specified we need to check if the parameter has a reserved
216 -- system default value. Therefore, for all parameters which have a
217 -- corresponding reserved system default mechanism specified we need to
218 -- check if a system default is being used. If a system default is being
219 -- used then we convert the defaulted value into its corresponding attribute
220 -- value held in the g_old_rec data structure.
221 --
222 -- Prerequisites:
223 -- This private function can only be called from the upd process.
224 --
225 -- In Parameters:
226 -- A Pl/Sql record structure.
227 --
228 -- Post Success:
229 -- The record structure will be returned with all system defaulted parameter
230 -- values converted into its current row attribute value.
231 --
232 -- Post Failure:
233 -- No direct error handling is required within this function. Any possible
234 -- errors within this procedure will be a PL/SQL value error due to
235 -- conversion of datatypes or data lengths.
236 --
237 -- Developer Implementation Notes:
238 -- None.
239 --
240 -- Access Status:
241 -- Internal Row Handler Use Only.
242 --
243 -- {End Of Comments}
244 -- ----------------------------------------------------------------------------
245 Procedure convert_defs
246 (p_rec in out nocopy pay_apr_shd.g_rec_type
247 ) is
248 --
249 Begin
250 --
251 -- We must now examine each argument value in the
252 -- p_rec plsql record structure
253 -- to see if a system default is being used. If a system default
254 -- is being used then we must set to the 'current' argument value.
255 --
256 If (p_rec.short_name = hr_api.g_varchar2) then
257 p_rec.short_name :=
258 pay_apr_shd.g_old_rec.short_name;
259 End If;
260 If (p_rec.name = hr_api.g_varchar2) then
261 p_rec.name :=
262 pay_apr_shd.g_old_rec.name;
263 End If;
264 If (p_rec.enabled_flag = hr_api.g_varchar2) then
265 p_rec.enabled_flag :=
266 pay_apr_shd.g_old_rec.enabled_flag;
267 End If;
268 If (p_rec.business_group_id = hr_api.g_number) then
269 p_rec.business_group_id :=
270 pay_apr_shd.g_old_rec.business_group_id;
271 End If;
272 If (p_rec.legislation_code = hr_api.g_varchar2) then
273 p_rec.legislation_code :=
274 pay_apr_shd.g_old_rec.legislation_code;
275 End If;
276 If (p_rec.description = hr_api.g_varchar2) then
277 p_rec.description :=
278 pay_apr_shd.g_old_rec.description;
279 End If;
280 If (p_rec.accrual_category = hr_api.g_varchar2) then
281 p_rec.accrual_category :=
282 pay_apr_shd.g_old_rec.accrual_category;
283 End If;
284 --
285 End convert_defs;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |---------------------------------< upd >----------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure upd
291 (p_rec in out nocopy pay_apr_shd.g_rec_type
292 ) is
293 --
294 l_proc varchar2(72);
295 --
296 Begin
297 l_proc := g_package||'upd';
298 --
299 hr_utility.set_location('Entering:'||l_proc, 5);
300 --
301 -- We must lock the row which we need to update.
302 --
303 pay_apr_shd.lck
304 (p_rec.process_id
305 ,p_rec.object_version_number
306 );
307 --
308 -- 1. During an update system defaults are used to determine if
309 -- arguments have been defaulted or not. We must therefore
310 -- derive the full record structure values to be updated.
311 --
312 -- 2. Call the supporting update validate operations.
313 --
314 convert_defs(p_rec);
315 pay_apr_bus.update_validate
316 (p_rec
317 );
318 --
319 -- Call to raise any errors on multi-message list
320 hr_multi_message.end_validation_set;
321 --
322 -- Call the supporting pre-update operation
323 --
324 pay_apr_upd.pre_update(p_rec);
325 --
326 -- Update the row.
327 --
328 pay_apr_upd.update_dml(p_rec);
329 --
330 -- Call the supporting post-update operation
331 --
332 pay_apr_upd.post_update
333 (p_rec
334 );
335 --
336 -- Call to raise any errors on multi-message list
337 hr_multi_message.end_validation_set;
338 End upd;
339 --
340 -- ----------------------------------------------------------------------------
341 -- |---------------------------------< upd >----------------------------------|
342 -- ----------------------------------------------------------------------------
343 Procedure upd
344 (p_process_id in number
345 ,p_object_version_number in out nocopy number
346 ,p_short_name in varchar2
347 ,p_name in varchar2
348 ,p_enabled_flag in varchar2
349 ,p_business_group_id in number
350 ,p_legislation_code in varchar2
351 ,p_description in varchar2
352 ,p_accrual_category in varchar2
353 ) is
354 --
355 l_rec pay_apr_shd.g_rec_type;
356 l_proc varchar2(72);
357 --
358 Begin
359 l_proc := g_package||'upd';
360 --
361 hr_utility.set_location('Entering:'||l_proc, 5);
362 --
363 -- Call conversion function to turn arguments into the
364 -- l_rec structure.
365 --
366 l_rec :=
367 pay_apr_shd.convert_args
368 (p_process_id
369 ,p_short_name
370 ,p_name
371 ,p_enabled_flag
372 ,p_business_group_id
373 ,p_legislation_code
374 ,p_description
375 ,p_accrual_category
376 ,p_object_version_number
377 );
378 --
379 -- Having converted the arguments into the
380 -- plsql record structure we call the corresponding record
381 -- business process.
382 --
383 pay_apr_upd.upd
384 (l_rec
385 );
386 p_object_version_number := l_rec.object_version_number;
387 --
388 hr_utility.set_location(' Leaving:'||l_proc, 10);
389 End upd;
390 --
391 begin
392 g_package := ' pay_apr_upd.'; -- Global package name
393 end pay_apr_upd;