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