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