1 Package Body pay_seu_upd as
2 /* $Header: pyseurhi.pkb 115.3 2003/02/05 17:11:00 arashid noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_seu_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_seu_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_ele_type_usages Row
69 --
70 update pay_shadow_ele_type_usages
71 set
72 element_type_usage_id = p_rec.element_type_usage_id
73 ,element_type_id = p_rec.element_type_id
74 ,inclusion_flag = p_rec.inclusion_flag
75 ,run_type_name = p_rec.run_type_name
76 ,exclusion_rule_id = p_rec.exclusion_rule_id
77 ,object_version_number = p_rec.object_version_number
78 where element_type_usage_id = p_rec.element_type_usage_id;
79 --
80 --
81 --
82 hr_utility.set_location(' Leaving:'||l_proc, 10);
83 --
84 Exception
85 When hr_api.check_integrity_violated Then
86 -- A check constraint has been violated
87 --
88 pay_seu_shd.constraint_error
89 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90 When hr_api.parent_integrity_violated Then
91 -- Parent integrity has been violated
92 --
93 pay_seu_shd.constraint_error
94 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95 When hr_api.unique_integrity_violated Then
96 -- Unique integrity has been violated
97 --
98 pay_seu_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When Others Then
101 --
102 Raise;
103 End update_dml;
104 --
105 -- ----------------------------------------------------------------------------
106 -- |------------------------------< pre_update >------------------------------|
107 -- ----------------------------------------------------------------------------
108 -- {Start Of Comments}
109 --
110 -- Description:
111 -- This private procedure contains any processing which is required before
112 -- the update dml.
113 --
114 -- Prerequisites:
115 -- This is an internal procedure which is called from the upd procedure.
116 --
117 -- In Parameters:
118 -- A Pl/Sql record structure.
119 --
120 -- Post Success:
121 -- Processing continues.
122 --
123 -- Post Failure:
124 -- If an error has occurred, an error message and exception wil be raised
125 -- but not handled.
126 --
127 -- Developer Implementation Notes:
128 -- Any pre-processing required before the update dml is issued should be
129 -- coded within this procedure. It is important to note that any 3rd party
130 -- maintenance should be reviewed before placing in this procedure.
131 --
132 -- Access Status:
133 -- Internal Row Handler Use Only.
134 --
135 -- {End Of Comments}
136 -- ----------------------------------------------------------------------------
137 Procedure pre_update
138 (p_rec in pay_seu_shd.g_rec_type
139 ) 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 -- Prerequisites:
159 -- This is an internal procedure which is called from the upd procedure.
160 --
161 -- In Parameters:
162 -- A Pl/Sql record structure.
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 Row Handler Use Only.
178 --
179 -- {End Of Comments}
180 -- ----------------------------------------------------------------------------
181 Procedure post_update
182 (p_effective_date in date
183 ,p_rec in pay_seu_shd.g_rec_type
184 ) is
185 --
186 l_proc varchar2(72) := g_package||'post_update';
187 --
188 Begin
189 hr_utility.set_location('Entering:'||l_proc, 5);
190 --
191 hr_utility.set_location(' Leaving:'||l_proc, 10);
192 End post_update;
193 --
194 -- ----------------------------------------------------------------------------
195 -- |-----------------------------< convert_defs >-----------------------------|
196 -- ----------------------------------------------------------------------------
197 -- {Start Of Comments}
198 --
199 -- Description:
200 -- The Convert_Defs procedure has one very important function:
201 -- It must return the record structure for the row with all system defaulted
202 -- values converted into its corresponding parameter value for update. When
203 -- we attempt to update a row through the Upd process , certain
204 -- parameters can be defaulted which enables flexibility in the calling of
205 -- the upd process (e.g. only attributes which need to be updated need to be
206 -- specified). For the upd process to determine which attributes
207 -- have NOT been specified we need to check if the parameter has a reserved
208 -- system default value. Therefore, for all parameters which have a
209 -- corresponding reserved system default mechanism specified we need to
210 -- check if a system default is being used. If a system default is being
211 -- used then we convert the defaulted value into its corresponding attribute
212 -- value held in the g_old_rec data structure.
213 --
214 -- Prerequisites:
215 -- This private function can only be called from the upd process.
216 --
217 -- In Parameters:
218 -- A Pl/Sql record structure.
219 --
220 -- Post Success:
221 -- The record structure will be returned with all system defaulted parameter
222 -- values converted into its current row attribute value.
223 --
224 -- Post Failure:
225 -- No direct error handling is required within this function. Any possible
226 -- errors within this procedure will be a PL/SQL value error due to
227 -- conversion of datatypes or data lengths.
228 --
229 -- Developer Implementation Notes:
230 -- None.
231 --
232 -- Access Status:
233 -- Internal Row Handler Use Only.
234 --
235 -- {End Of Comments}
236 -- ----------------------------------------------------------------------------
237 Procedure convert_defs
238 (p_rec in out nocopy pay_seu_shd.g_rec_type
239 ) is
240 --
241 Begin
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.element_type_id = hr_api.g_number) then
249 p_rec.element_type_id :=
250 pay_seu_shd.g_old_rec.element_type_id;
251 End If;
252 If (p_rec.inclusion_flag = hr_api.g_varchar2) then
253 p_rec.inclusion_flag :=
254 pay_seu_shd.g_old_rec.inclusion_flag;
255 End If;
256 If (p_rec.run_type_name = hr_api.g_varchar2) then
257 p_rec.run_type_name :=
258 pay_seu_shd.g_old_rec.run_type_name;
259 End If;
260 If (p_rec.exclusion_rule_id = hr_api.g_number) then
261 p_rec.exclusion_rule_id :=
262 pay_seu_shd.g_old_rec.exclusion_rule_id;
263 End If;
264 --
265 End convert_defs;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------------< upd >----------------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure upd
271 (p_effective_date in date
272 ,p_rec in out nocopy pay_seu_shd.g_rec_type
273 ) is
274 --
275 l_proc varchar2(72) := g_package||'upd';
276 --
277 Begin
278 hr_utility.set_location('Entering:'||l_proc, 5);
279 --
280 -- We must lock the row which we need to update.
281 --
282 pay_seu_shd.lck
283 (p_rec.element_type_usage_id
284 ,p_rec.object_version_number
285 );
286 --
287 -- 1. During an update system defaults are used to determine if
288 -- arguments have been defaulted or not. We must therefore
289 -- derive the full record structure values to be updated.
290 --
291 -- 2. Call the supporting update validate operations.
292 --
293 convert_defs(p_rec);
294 pay_seu_bus.update_validate
295 (p_effective_date
296 ,p_rec
297 );
298 --
299 -- Call the supporting pre-update operation
300 --
301 pay_seu_upd.pre_update(p_rec);
302 --
303 -- Update the row.
304 --
305 pay_seu_upd.update_dml(p_rec);
306 --
307 -- Call the supporting post-update operation
308 --
309 pay_seu_upd.post_update
310 (p_effective_date
311 ,p_rec
312 );
313 End upd;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |---------------------------------< upd >----------------------------------|
317 -- ----------------------------------------------------------------------------
318 Procedure upd
319 (p_effective_date in date
320 ,p_element_type_usage_id in number
321 ,p_object_version_number in out nocopy number
322 ,p_element_type_id in number default hr_api.g_number
323 ,p_inclusion_flag in varchar2 default hr_api.g_varchar2
324 ,p_run_type_name in varchar2 default hr_api.g_varchar2
325 ,p_exclusion_rule_id in number default hr_api.g_number
326 ) is
327 --
328 l_rec pay_seu_shd.g_rec_type;
329 l_proc varchar2(72) := g_package||'upd';
330 --
331 Begin
332 hr_utility.set_location('Entering:'||l_proc, 5);
333 --
334 -- Call conversion function to turn arguments into the
335 -- l_rec structure.
336 --
337 l_rec :=
338 pay_seu_shd.convert_args
339 (p_element_type_usage_id
340 ,p_element_type_id
341 ,p_inclusion_flag
342 ,p_run_type_name
343 ,p_exclusion_rule_id
344 ,p_object_version_number
345 );
346 --
347 -- Having converted the arguments into the
348 -- plsql record structure we call the corresponding record
349 -- business process.
350 --
351 pay_seu_upd.upd
352 (p_effective_date
353 ,l_rec
354 );
355 p_object_version_number := l_rec.object_version_number;
356 --
357 hr_utility.set_location(' Leaving:'||l_proc, 10);
358 End upd;
359 --
360 end pay_seu_upd;