1 Package Body pay_sf_upd as
2 /* $Header: pysfrhi.pkb 120.0 2005/05/29 02:17:28 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_sf_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 -- perform dml).
21 -- 3) To update the specified row in the schema using the primary key in
22 -- the predicates.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Prerequisites:
27 -- This is an internal private procedure which must be called from the upd
28 -- procedure.
29 --
30 -- In Parameters:
31 -- A Pl/Sql record structre.
32 --
33 -- Post Success:
34 -- The specified row will be updated in the schema.
35 --
36 -- Post Failure:
37 -- On the update dml failure it is important to note that we always reset the
38 -- If a check, unique or parent integrity constraint violation is raised the
39 -- constraint_error procedure will be called.
40 -- If any other error is reported, the error will be raised after the
41 --
42 -- Developer Implementation Notes:
43 -- The update 'set' attribute list should be modified if any of your
44 -- attributes are not updateable.
45 --
46 -- Access Status:
47 -- Internal Row Handler Use Only.
48 --
49 -- {End Of Comments}
50 -- ----------------------------------------------------------------------------
51 Procedure update_dml(p_rec in out nocopy pay_sf_shd.g_rec_type) is
52 --
53 l_proc varchar2(72) := g_package||'update_dml';
54 --
55 Begin
56 hr_utility.set_location('Entering:'||l_proc, 5);
57 --
58 -- Increment the object version
59 --
60 p_rec.object_version_number := p_rec.object_version_number + 1;
61 --
62 --
63 -- Update the pay_shadow_formulas Row
64 --
65 update pay_shadow_formulas
66 set
67 description = p_rec.description,
68 formula_text = p_rec.formula_text,
69 object_version_number = p_rec.object_version_number
70 where formula_id = p_rec.formula_id;
71 --
72 --
73 hr_utility.set_location(' Leaving:'||l_proc, 10);
74 --
75 Exception
76 When hr_api.check_integrity_violated Then
77 -- A check constraint has been violated
78 pay_sf_shd.constraint_error
79 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
80 When hr_api.parent_integrity_violated Then
81 -- Parent integrity has been violated
82 pay_sf_shd.constraint_error
83 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
84 When hr_api.unique_integrity_violated Then
85 -- Unique integrity has been violated
86 pay_sf_shd.constraint_error
87 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
88 When Others Then
89 Raise;
90 End update_dml;
91 --
92 -- ----------------------------------------------------------------------------
93 -- |------------------------------< pre_update >------------------------------|
94 -- ----------------------------------------------------------------------------
95 -- {Start Of Comments}
96 --
97 -- Description:
98 -- This private procedure contains any processing which is required before
99 -- the update dml.
100 --
101 -- Prerequisites:
102 -- This is an internal procedure which is called from the upd procedure.
103 --
104 -- In Parameters:
105 -- A Pl/Sql record structre.
106 --
107 -- Post Success:
108 -- Processing continues.
109 --
110 -- Post Failure:
111 -- If an error has occurred, an error message and exception will be raised
112 -- but not handled.
113 --
114 -- Developer Implementation Notes:
115 -- Any pre-processing required before the update dml is issued should be
116 -- coded within this procedure. It is important to note that any 3rd party
117 -- maintenance should be reviewed before placing in this procedure.
118 --
119 -- Access Status:
120 -- Internal Row Handler Use Only.
121 --
122 -- {End Of Comments}
123 -- ----------------------------------------------------------------------------
124 Procedure pre_update(p_rec in pay_sf_shd.g_rec_type) is
125 --
126 l_proc varchar2(72) := g_package||'pre_update';
127 --
128 Begin
129 hr_utility.set_location('Entering:'||l_proc, 5);
130 --
131 hr_utility.set_location(' Leaving:'||l_proc, 10);
132 End pre_update;
133 --
134 -- ----------------------------------------------------------------------------
135 -- |-----------------------------< post_update >------------------------------|
136 -- ----------------------------------------------------------------------------
137 -- {Start Of Comments}
138 --
139 -- Description:
140 -- This private procedure contains any processing which is required after the
141 -- update dml.
142 --
143 -- Prerequisites:
144 -- This is an internal procedure which is called from the upd procedure.
145 --
146 -- In Parameters:
147 -- A Pl/Sql record structre.
148 --
149 -- Post Success:
150 -- Processing continues.
151 --
152 -- Post Failure:
153 -- If an error has occurred, an error message and exception will be raised
154 -- but not handled.
155 --
156 -- Developer Implementation Notes:
157 -- Any post-processing required after the update dml is issued should be
158 -- coded within this procedure. It is important to note that any 3rd party
159 -- maintenance should be reviewed before placing in this procedure.
160 --
161 -- Access Status:
162 -- Internal Row Handler Use Only.
163 --
164 -- {End Of Comments}
165 -- ----------------------------------------------------------------------------
166 Procedure post_update(p_rec in pay_sf_shd.g_rec_type) is
167 --
168 l_proc varchar2(72) := g_package||'post_update';
169 --
170 Begin
171 hr_utility.set_location('Entering:'||l_proc, 5);
172 --
173 hr_utility.set_location(' Leaving:'||l_proc, 10);
174 End post_update;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |-----------------------------< convert_defs >-----------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 -- The Convert_Defs procedure has one very important function:
183 -- It must return the record structure for the row with all system defaulted
184 -- values converted into its corresponding parameter value for update. When
185 -- we attempt to update a row through the Upd process , certain
186 -- parameters can be defaulted which enables flexibility in the calling of
187 -- the upd process (e.g. only attributes which need to be updated need to be
188 -- specified). For the upd process to determine which attributes
189 -- have NOT been specified we need to check if the parameter has a reserved
190 -- system default value. Therefore, for all parameters which have a
191 -- corresponding reserved system default mechanism specified we need to
192 -- check if a system default is being used. If a system default is being
193 -- used then we convert the defaulted value into its corresponding attribute
194 -- value held in the g_old_rec data structure.
195 --
196 -- Prerequisites:
197 -- This private function can only be called from the upd process.
198 --
199 -- In Parameters:
200 -- A Pl/Sql record structre.
201 --
202 -- Post Success:
203 -- The record structure will be returned with all system defaulted parameter
204 -- values converted into its current row attribute value.
205 --
206 -- Post Failure:
207 -- No direct error handling is required within this function. Any possible
208 -- errors within this procedure will be a PL/SQL value error due to conversion
209
210 -- of datatypes or data lengths.
211 --
212 -- Developer Implementation Notes:
213 -- None.
214 --
215 -- Access Status:
216 -- Internal Row Handler Use Only.
217 --
218 -- {End Of Comments}
219 -- ----------------------------------------------------------------------------
220 Procedure convert_defs(p_rec in out nocopy pay_sf_shd.g_rec_type) is
221 --
222 l_proc varchar2(72) := g_package||'convert_defs';
223 --
224 Begin
225 --
226 hr_utility.set_location('Entering:'||l_proc, 5);
227 --
228 -- We must now examine each argument value in the
229 -- p_rec plsql record structure
230 -- to see if a system default is being used. If a system default
231 -- is being used then we must set to the 'current' argument value.
232 --
233 If (p_rec.template_type = hr_api.g_varchar2) then
234 p_rec.template_type :=
235 pay_sf_shd.g_old_rec.template_type;
236 End If;
237 If (p_rec.legislation_code = hr_api.g_varchar2) then
238 p_rec.legislation_code :=
239 pay_sf_shd.g_old_rec.legislation_code;
240 End If;
241 If (p_rec.business_group_id = hr_api.g_number) then
242 p_rec.business_group_id :=
243 pay_sf_shd.g_old_rec.business_group_id;
244 End If;
245 If (p_rec.formula_name = hr_api.g_varchar2) then
246 p_rec.formula_name :=
247 pay_sf_shd.g_old_rec.formula_name;
248 End If;
249 If (p_rec.description = hr_api.g_varchar2) then
250 p_rec.description :=
251 pay_sf_shd.g_old_rec.description;
252 End If;
253 If (p_rec.formula_text = hr_api.g_varchar2) then
254 p_rec.formula_text :=
255 pay_sf_shd.g_old_rec.formula_text;
256 End If;
257 If (p_rec.formula_type_name = hr_api.g_varchar2) then
258 p_rec.formula_type_name :=
259 pay_sf_shd.g_old_rec.formula_type_name;
260 End If;
261
262
263 --
264 hr_utility.set_location(' Leaving:'||l_proc, 10);
265 --
266 End convert_defs;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |---------------------------------< upd >----------------------------------|
270 -- ----------------------------------------------------------------------------
271 Procedure upd
272 (p_effective_date in date
273 ,p_rec in out nocopy pay_sf_shd.g_rec_type
274 ) is
275 --
276 l_proc varchar2(72) := g_package||'upd';
277 --
278 Begin
279 hr_utility.set_location('Entering:'||l_proc, 5);
280 --
281 -- We must lock the row which we need to update.
282 --
283 pay_sf_shd.lck
284 (
285 p_rec.formula_id,
286 p_rec.object_version_number
287 );
288 --
289 -- 1. During an update system defaults are used to determine if
290 -- arguments have been defaulted or not. We must therefore
291 -- derive the full record structure values to be updated.
292 --
293 -- 2. Call the supporting update validate operations.
294 --
295 convert_defs(p_rec);
296 pay_sf_bus.update_validate(p_effective_date, p_rec);
297 --
298 -- Call the supporting pre-update operation
299 --
300 pre_update(p_rec);
301 --
302 -- Update the row.
303 --
304 update_dml(p_rec);
305 --
306 -- Call the supporting post-update operation
307 --
308 post_update(p_rec);
309 End upd;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |---------------------------------< upd >----------------------------------|
313 -- ----------------------------------------------------------------------------
314 Procedure upd
315 (
316 p_formula_id in number,
317 p_effective_date in date,
318 p_description in varchar2 default hr_api.g_varchar2,
319 p_formula_text in varchar2 default hr_api.g_varchar2,
320 p_object_version_number in out nocopy number
321 ) is
322 --
323 l_rec pay_sf_shd.g_rec_type;
324 l_proc varchar2(72) := g_package||'upd';
325 --
326 Begin
327 hr_utility.set_location('Entering:'||l_proc, 5);
328 --
329 -- Call conversion function to turn arguments into the
330 -- l_rec structure.
331 --
332 l_rec :=
333 pay_sf_shd.convert_args
334 (
335 p_formula_id,
336 hr_api.g_varchar2,
337 hr_api.g_varchar2,
338 hr_api.g_number,
339 hr_api.g_varchar2,
340 p_description,
341 p_formula_text,
342 hr_api.g_varchar2,
343 p_object_version_number
344 );
345 --
346 -- Having converted the arguments into the
347 -- plsql record structure we call the corresponding record
348 -- business process.
349 --
350 upd(p_effective_date, l_rec);
351 p_object_version_number := l_rec.object_version_number;
352 --
353 hr_utility.set_location(' Leaving:'||l_proc, 10);
354 End upd;
355 --
356 end pay_sf_upd;