1 Package Body pay_sir_upd as
2 /* $Header: pysirrhi.pkb 115.4 2003/02/05 17:11:09 arashid noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_sir_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 pay_sir_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 --
67 --
68 -- Update the pay_shadow_iterative_rules Row
69 --
70 update pay_shadow_iterative_rules
71 set
72 iterative_rule_id = p_rec.iterative_rule_id
73 ,element_type_id = p_rec.element_type_id
74 ,result_name = p_rec.result_name
75 ,iterative_rule_type = p_rec.iterative_rule_type
76 ,input_value_id = p_rec.input_value_id
77 ,severity_level = p_rec.severity_level
78 ,exclusion_rule_id = p_rec.exclusion_rule_id
79 ,object_version_number = p_rec.object_version_number
80 where iterative_rule_id = p_rec.iterative_rule_id;
81 --
82 --
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 --
90 pay_sir_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 --
95 pay_sir_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 --
100 pay_sir_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When Others Then
103 --
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 -- Prerequisites:
117 -- This is an internal procedure which is called from the upd procedure.
118 --
119 -- In Parameters:
120 -- A Pl/Sql record structure.
121 --
122 -- Post Success:
123 -- Processing continues.
124 --
125 -- Post Failure:
126 -- If an error has occurred, an error message and exception wil 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 Row Handler Use Only.
136 --
137 -- {End Of Comments}
138 -- ----------------------------------------------------------------------------
139 Procedure pre_update
140 (p_rec in pay_sir_shd.g_rec_type
141 ) is
142 --
143 l_proc varchar2(72) := g_package||'pre_update';
144 --
145 Begin
146 hr_utility.set_location('Entering:'||l_proc, 5);
147 --
148 hr_utility.set_location(' Leaving:'||l_proc, 10);
149 End pre_update;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |-----------------------------< post_update >------------------------------|
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 -- This private procedure contains any processing which is required after the
158 -- update dml.
159 --
160 -- Prerequisites:
161 -- This is an internal procedure which is called from the upd procedure.
162 --
163 -- In Parameters:
164 -- A Pl/Sql record structure.
165 --
166 -- Post Success:
167 -- Processing continues.
168 --
169 -- Post Failure:
170 -- If an error has occurred, an error message and exception will be raised
171 -- but not handled.
172 --
173 -- Developer Implementation Notes:
174 -- Any post-processing required after the update dml is issued should be
175 -- coded within this procedure. It is important to note that any 3rd party
176 -- maintenance should be reviewed before placing in this procedure.
177 --
178 -- Access Status:
179 -- Internal Row Handler Use Only.
180 --
181 -- {End Of Comments}
182 -- ----------------------------------------------------------------------------
183 Procedure post_update
184 (p_rec in pay_sir_shd.g_rec_type
185 ) is
186 --
187 l_proc varchar2(72) := g_package||'post_update';
188 --
189 Begin
190 --
191 hr_utility.set_location('Entering:'||l_proc, 5);
192 --
193 hr_utility.set_location(' Leaving:'||l_proc, 10);
194 End post_update;
195 --
196 -- ----------------------------------------------------------------------------
197 -- |-----------------------------< convert_defs >-----------------------------|
198 -- ----------------------------------------------------------------------------
199 -- {Start Of Comments}
200 --
201 -- Description:
202 -- The Convert_Defs procedure has one very important function:
203 -- It must return the record structure for the row with all system defaulted
204 -- values converted into its corresponding parameter value for update. When
205 -- we attempt to update a row through the Upd process , certain
206 -- parameters can be defaulted which enables flexibility in the calling of
207 -- the upd process (e.g. only attributes which need to be updated need to be
208 -- specified). For the upd process to determine which attributes
209 -- have NOT been specified we need to check if the parameter has a reserved
210 -- system default value. Therefore, for all parameters which have a
211 -- corresponding reserved system default mechanism specified we need to
212 -- check if a system default is being used. If a system default is being
213 -- used then we convert the defaulted value into its corresponding attribute
214 -- value held in the g_old_rec data structure.
215 --
216 -- Prerequisites:
217 -- This private function can only be called from the upd process.
218 --
219 -- In Parameters:
220 -- A Pl/Sql record structure.
221 --
222 -- Post Success:
223 -- The record structure will be returned with all system defaulted parameter
224 -- values converted into its current row attribute value.
225 --
226 -- Post Failure:
227 -- No direct error handling is required within this function. Any possible
228 -- errors within this procedure will be a PL/SQL value error due to
229 -- conversion of datatypes or data lengths.
230 --
231 -- Developer Implementation Notes:
232 -- None.
233 --
234 -- Access Status:
235 -- Internal Row Handler Use Only.
236 --
237 -- {End Of Comments}
238 -- ----------------------------------------------------------------------------
239 Procedure convert_defs
240 (p_rec in out nocopy pay_sir_shd.g_rec_type
241 ) is
242 --
243 l_proc varchar2(72) := g_package||'convert_defs';
244 --
245 Begin
246 --
247 -- We must now examine each argument value in the
248 -- p_rec plsql record structure
249 -- to see if a system default is being used. If a system default
250 -- is being used then we must set to the 'current' argument value.
251 --
252 If (p_rec.element_type_id = hr_api.g_number) then
253 p_rec.element_type_id :=
254 pay_sir_shd.g_old_rec.element_type_id;
255 End If;
256 If (p_rec.result_name = hr_api.g_varchar2) then
257 p_rec.result_name :=
258 pay_sir_shd.g_old_rec.result_name;
259 End If;
260 If (p_rec.iterative_rule_type = hr_api.g_varchar2) then
261 p_rec.iterative_rule_type :=
262 pay_sir_shd.g_old_rec.iterative_rule_type;
263 End If;
264 If (p_rec.input_value_id = hr_api.g_number) then
265 p_rec.input_value_id :=
266 pay_sir_shd.g_old_rec.input_value_id;
267 End If;
268 If (p_rec.severity_level = hr_api.g_varchar2) then
269 p_rec.severity_level :=
270 pay_sir_shd.g_old_rec.severity_level;
271 End If;
272 If (p_rec.exclusion_rule_id = hr_api.g_number) then
273 p_rec.exclusion_rule_id :=
274 pay_sir_shd.g_old_rec.exclusion_rule_id;
275 End If;
276 --
277 End convert_defs;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------------< upd >----------------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure upd
283 (p_effective_date in date
284 ,p_rec in out nocopy pay_sir_shd.g_rec_type
285 ) is
286 --
287 l_proc varchar2(72) := g_package||'upd';
288 --
289 Begin
290 hr_utility.set_location('Entering:'||l_proc, 5);
291 --
292 -- We must lock the row which we need to update.
293 --
294 pay_sir_shd.lck
295 (p_rec.iterative_rule_id
296 ,p_rec.object_version_number
297 );
298 --
299 -- 1. During an update system defaults are used to determine if
300 -- arguments have been defaulted or not. We must therefore
301 -- derive the full record structure values to be updated.
302 --
303 -- 2. Call the supporting update validate operations.
304 --
305 convert_defs(p_rec);
306 pay_sir_bus.update_validate
307 (p_effective_date
308 ,p_rec
309 );
310 --
311 -- Call the supporting pre-update operation
312 --
313 pay_sir_upd.pre_update(p_rec);
314 --
315 -- Update the row.
316 --
317 pay_sir_upd.update_dml(p_rec);
318 --
319 -- Call the supporting post-update operation
320 --
321 pay_sir_upd.post_update(p_rec);
322 End upd;
323 --
324 -- ----------------------------------------------------------------------------
325 -- |---------------------------------< upd >----------------------------------|
326 -- ----------------------------------------------------------------------------
327 Procedure upd
328 (p_effective_date in date
329 ,p_iterative_rule_id in number
330 ,p_object_version_number in out nocopy number
331 ,p_element_type_id in number default hr_api.g_number
332 ,p_result_name in varchar2 default hr_api.g_varchar2
333 ,p_iterative_rule_type in varchar2 default hr_api.g_varchar2
334 ,p_input_value_id in number default hr_api.g_number
335 ,p_severity_level in varchar2 default hr_api.g_varchar2
336 ,p_exclusion_rule_id in number default hr_api.g_number
337 ) is
338 --
339 l_rec pay_sir_shd.g_rec_type;
340 l_proc varchar2(72) := g_package||'upd';
341 --
342 Begin
343 hr_utility.set_location('Entering:'||l_proc, 5);
344 --
345 -- Call conversion function to turn arguments into the
346 -- l_rec structure.
347 --
348 l_rec :=
349 pay_sir_shd.convert_args
350 (p_iterative_rule_id
351 ,p_element_type_id
352 ,p_result_name
353 ,p_iterative_rule_type
354 ,p_input_value_id
355 ,p_severity_level
356 ,p_exclusion_rule_id
357 ,p_object_version_number
358 );
359 --
360 -- Having converted the arguments into the
361 -- plsql record structure we call the corresponding record
362 -- business process.
363 --
364 pay_sir_upd.upd
365 (p_effective_date
366 ,l_rec
367 );
368 p_object_version_number := l_rec.object_version_number;
369 --
370 hr_utility.set_location(' Leaving:'||l_proc, 10);
371 End upd;
372 --
373 end pay_sir_upd;