1 Package Body pay_ssr_upd as
2 /* $Header: pyssrrhi.pkb 120.0 2005/05/29 08:55:13 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_ssr_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_ssr_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_sub_classi_rules Row
64 --
65 update pay_shadow_sub_classi_rules
66 set
67 element_classification = p_rec.element_classification,
68 object_version_number = p_rec.object_version_number
69 ,exclusion_rule_id = p_rec.exclusion_rule_id
70 where sub_classification_rule_id = p_rec.sub_classification_rule_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_ssr_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_ssr_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_ssr_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_ssr_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_ssr_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_ssr_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.element_type_id = hr_api.g_number) then
234 p_rec.element_type_id :=
235 pay_ssr_shd.g_old_rec.element_type_id;
236 End If;
237 If (p_rec.element_classification = hr_api.g_varchar2) then
238 p_rec.element_classification :=
239 pay_ssr_shd.g_old_rec.element_classification;
240 End If;
241 If (p_rec.exclusion_rule_id = hr_api.g_number) then
242 p_rec.exclusion_rule_id :=
243 pay_ssr_shd.g_old_rec.exclusion_rule_id;
244 End If;
245 --
246 hr_utility.set_location(' Leaving:'||l_proc, 10);
247 --
248 End convert_defs;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< upd >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure upd
254 (
255 p_effective_date in date,
256 p_rec in out nocopy pay_ssr_shd.g_rec_type
257 ) is
258 --
259 l_proc varchar2(72) := g_package||'upd';
260 --
261 Begin
262 hr_utility.set_location('Entering:'||l_proc, 5);
263 --
264 -- We must lock the row which we need to update.
265 --
266 pay_ssr_shd.lck
267 (
268 p_rec.sub_classification_rule_id,
269 p_rec.object_version_number
270 );
271 --
272 -- 1. During an update system defaults are used to determine if
273 -- arguments have been defaulted or not. We must therefore
274 -- derive the full record structure values to be updated.
275 --
276 -- 2. Call the supporting update validate operations.
277 --
278 convert_defs(p_rec);
279 pay_ssr_bus.update_validate(p_rec);
280 --
281 -- Call the supporting pre-update operation
282 --
283 pre_update(p_rec);
284 --
285 -- Update the row.
286 --
287 update_dml(p_rec);
288 --
289 -- Call the supporting post-update operation
290 --
291 post_update(p_rec);
292 End upd;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |---------------------------------< upd >----------------------------------|
296 -- ----------------------------------------------------------------------------
297 Procedure upd
298 (
299 p_effective_date in date,
300 p_sub_classification_rule_id in number,
301 p_element_classification in varchar2 default hr_api.g_varchar2,
302 p_object_version_number in out nocopy number
303 ,p_exclusion_rule_id in number default hr_api.g_number
304 ) is
305 --
306 l_rec pay_ssr_shd.g_rec_type;
307 l_proc varchar2(72) := g_package||'upd';
308 --
309 Begin
310 hr_utility.set_location('Entering:'||l_proc, 5);
311 --
312 -- Call conversion function to turn arguments into the
313 -- l_rec structure.
314 --
315 l_rec :=
316 pay_ssr_shd.convert_args
317 (
318 p_sub_classification_rule_id,
319 hr_api.g_number,
320 p_element_classification,
321 p_object_version_number
322 ,p_exclusion_rule_id
323 );
324 --
325 -- Having converted the arguments into the
326 -- plsql record structure we call the corresponding record
327 -- business process.
328 --
329 upd(p_effective_date, l_rec);
330 p_object_version_number := l_rec.object_version_number;
331 --
332 hr_utility.set_location(' Leaving:'||l_proc, 10);
333 End upd;
334 --
335 end pay_ssr_upd;