1 Package Body ben_xct_upd as
2 /* $Header: bexctrhi.pkb 115.12 2002/12/31 20:39:06 stee ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xct_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(p_rec in out nocopy ben_xct_shd.g_rec_type) is
55 --
56 l_proc varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59 hr_utility.set_location('Entering:'||l_proc, 5);
60 --
61 -- Increment the object version
62 --
63 p_rec.object_version_number := p_rec.object_version_number + 1;
64 --
65 ben_xct_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_ext_crit_typ Row
68 --
69 update ben_ext_crit_typ
70 set
71 ext_crit_typ_id = p_rec.ext_crit_typ_id,
72 crit_typ_cd = p_rec.crit_typ_cd,
73 ext_crit_prfl_id = p_rec.ext_crit_prfl_id,
74 business_group_id = p_rec.business_group_id,
75 legislation_code = p_rec.legislation_code,
76 last_update_date = p_rec.last_update_date,
77 last_updated_by = p_rec.last_updated_by,
78 last_update_login = p_rec.last_update_login,
79 object_version_number = p_rec.object_version_number,
80 excld_flag = p_rec.excld_flag
81 where ext_crit_typ_id = p_rec.ext_crit_typ_id;
82 --
83 ben_xct_shd.g_api_dml := false; -- Unset the api dml status
84 --
85 hr_utility.set_location(' Leaving:'||l_proc, 10);
86 --
87 Exception
88 When hr_api.check_integrity_violated Then
89 -- A check constraint has been violated
90 ben_xct_shd.g_api_dml := false; -- Unset the api dml status
91 ben_xct_shd.constraint_error
92 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93 When hr_api.parent_integrity_violated Then
94 -- Parent integrity has been violated
95 ben_xct_shd.g_api_dml := false; -- Unset the api dml status
96 ben_xct_shd.constraint_error
97 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98 When hr_api.unique_integrity_violated Then
99 -- Unique integrity has been violated
100 ben_xct_shd.g_api_dml := false; -- Unset the api dml status
101 ben_xct_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When Others Then
104 ben_xct_shd.g_api_dml := false; -- Unset the api dml status
105 Raise;
106 End update_dml;
107 --
108 -- ----------------------------------------------------------------------------
109 -- |------------------------------< pre_update >------------------------------|
110 -- ----------------------------------------------------------------------------
111 -- {Start Of Comments}
112 --
113 -- Description:
114 -- This private procedure contains any processing which is required before
115 -- the update dml.
116 --
117 -- Prerequisites:
118 -- This is an internal procedure which is called from the upd procedure.
119 --
120 -- In Parameters:
121 -- A Pl/Sql record structre.
122 --
123 -- Post Success:
124 -- Processing continues.
125 --
126 -- Post Failure:
127 -- If an error has occurred, an error message and exception will be raised
128 -- but not handled.
129 --
130 -- Developer Implementation Notes:
131 -- Any pre-processing required before the update dml is issued should be
132 -- coded within this procedure. It is important to note that any 3rd party
133 -- maintenance should be reviewed before placing in this procedure.
134 --
135 -- Access Status:
136 -- Internal Row Handler Use Only.
137 --
138 -- {End Of Comments}
139 -- ----------------------------------------------------------------------------
140 Procedure pre_update(p_rec in ben_xct_shd.g_rec_type) is
141 --
142 l_proc varchar2(72) := g_package||'pre_update';
143 --
144 Begin
145 hr_utility.set_location('Entering:'||l_proc, 5);
146 --
147 hr_utility.set_location(' Leaving:'||l_proc, 10);
148 End pre_update;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |-----------------------------< post_update >------------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 -- This private procedure contains any processing which is required after the
157 -- update dml.
158 --
159 -- Prerequisites:
160 -- This is an internal procedure which is called from the upd procedure.
161 --
162 -- In Parameters:
163 -- A Pl/Sql record structre.
164 --
165 -- Post Success:
166 -- Processing continues.
167 --
168 -- Post Failure:
169 -- If an error has occurred, an error message and exception will be raised
170 -- but not handled.
171 --
172 -- Developer Implementation Notes:
173 -- Any post-processing required after the update dml is issued should be
174 -- coded within this procedure. It is important to note that any 3rd party
175 -- maintenance should be reviewed before placing in this procedure.
176 --
177 -- Access Status:
178 -- Internal Row Handler Use Only.
179 --
180 -- {End Of Comments}
181 -- ----------------------------------------------------------------------------
182 Procedure post_update(
183 p_effective_date in date,p_rec in ben_xct_shd.g_rec_type) is
184 --
185 l_proc varchar2(72) := g_package||'post_update';
186 --
187 Begin
188 hr_utility.set_location('Entering:'||l_proc, 5);
189 --
190 --
191 -- Start of API User Hook for post_update.
192 --
193 begin
194 --
195 ben_xct_rku.after_update
196 (
197 p_ext_crit_typ_id =>p_rec.ext_crit_typ_id
198 ,p_crit_typ_cd =>p_rec.crit_typ_cd
199 ,p_ext_crit_prfl_id =>p_rec.ext_crit_prfl_id
200 ,p_business_group_id =>p_rec.business_group_id
201 ,p_legislation_code =>p_rec.legislation_code
202 ,p_object_version_number =>p_rec.object_version_number
203 ,p_effective_date =>p_effective_date
204 ,p_excld_flag =>p_rec.excld_flag
205 ,p_crit_typ_cd_o =>ben_xct_shd.g_old_rec.crit_typ_cd
206 ,p_ext_crit_prfl_id_o =>ben_xct_shd.g_old_rec.ext_crit_prfl_id
207 ,p_business_group_id_o =>ben_xct_shd.g_old_rec.business_group_id
208 ,p_legislation_code_o =>ben_xct_shd.g_old_rec.legislation_code
209 ,p_object_version_number_o =>ben_xct_shd.g_old_rec.object_version_number
210 ,p_excld_flag_o =>ben_xct_shd.g_old_rec.excld_flag
211 );
212 --
213 exception
214 --
215 when hr_api.cannot_find_prog_unit then
216 --
217 hr_api.cannot_find_prog_unit_error
218 (p_module_name => 'ben_ext_crit_typ'
219 ,p_hook_type => 'AU');
220 --
221 end;
222 --
223 -- End of API User Hook for post_update.
224 --
225 --
226 hr_utility.set_location(' Leaving:'||l_proc, 10);
227 End post_update;
228 --
229 -- ----------------------------------------------------------------------------
230 -- |-----------------------------< convert_defs >-----------------------------|
231 -- ----------------------------------------------------------------------------
232 -- {Start Of Comments}
233 --
234 -- Description:
235 -- The Convert_Defs procedure has one very important function:
236 -- It must return the record structure for the row with all system defaulted
237 -- values converted into its corresponding parameter value for update. When
238 -- we attempt to update a row through the Upd process , certain
239 -- parameters can be defaulted which enables flexibility in the calling of
240 -- the upd process (e.g. only attributes which need to be updated need to be
241 -- specified). For the upd process to determine which attributes
242 -- have NOT been specified we need to check if the parameter has a reserved
243 -- system default value. Therefore, for all parameters which have a
244 -- corresponding reserved system default mechanism specified we need to
245 -- check if a system default is being used. If a system default is being
246 -- used then we convert the defaulted value into its corresponding attribute
247 -- value held in the g_old_rec data structure.
248 --
249 -- Prerequisites:
250 -- This private function can only be called from the upd process.
251 --
252 -- In Parameters:
253 -- A Pl/Sql record structre.
254 --
255 -- Post Success:
256 -- The record structure will be returned with all system defaulted parameter
257 -- values converted into its current row attribute value.
258 --
259 -- Post Failure:
260 -- No direct error handling is required within this function. Any possible
261 -- errors within this procedure will be a PL/SQL value error due to conversion
262 -- of datatypes or data lengths.
263 --
264 -- Developer Implementation Notes:
265 -- None.
266 --
267 -- Access Status:
268 -- Internal Row Handler Use Only.
269 --
270 -- {End Of Comments}
271 -- ----------------------------------------------------------------------------
272 Procedure convert_defs(p_rec in out nocopy ben_xct_shd.g_rec_type) is
273 --
274 l_proc varchar2(72) := g_package||'convert_defs';
275 --
276 Begin
277 --
278 hr_utility.set_location('Entering:'||l_proc, 5);
279 --
280 -- We must now examine each argument value in the
281 -- p_rec plsql record structure
282 -- to see if a system default is being used. If a system default
283 -- is being used then we must set to the 'current' argument value.
284 --
285 If (p_rec.crit_typ_cd = hr_api.g_varchar2) then
286 p_rec.crit_typ_cd :=
287 ben_xct_shd.g_old_rec.crit_typ_cd;
288 End If;
289 If (p_rec.ext_crit_prfl_id = hr_api.g_number) then
290 p_rec.ext_crit_prfl_id :=
291 ben_xct_shd.g_old_rec.ext_crit_prfl_id;
292 End If;
293 If (p_rec.business_group_id = hr_api.g_number) then
294 p_rec.business_group_id :=
295 ben_xct_shd.g_old_rec.business_group_id;
296 End If;
297 If (p_rec.legislation_code = hr_api.g_varchar2) then
298 p_rec.legislation_code :=
299 ben_xct_shd.g_old_rec.legislation_code;
300 End If;
301 If (p_rec.excld_flag = hr_api.g_varchar2) then
302 p_rec.excld_flag :=
303 ben_xct_shd.g_old_rec.excld_flag;
304 End If;
305
306 --
307 hr_utility.set_location(' Leaving:'||l_proc, 10);
308 --
309 End convert_defs;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |---------------------------------< upd >----------------------------------|
313 -- ----------------------------------------------------------------------------
314 Procedure upd
315 (
316 p_effective_date in date,
317 p_rec in out nocopy ben_xct_shd.g_rec_type
318 ) is
319 --
320 l_proc varchar2(72) := g_package||'upd';
321 --
322 Begin
323 hr_utility.set_location('Entering:'||l_proc, 5);
324 --
325 -- We must lock the row which we need to update.
326 --
327 ben_xct_shd.lck
328 (
329 p_rec.ext_crit_typ_id,
330 p_rec.object_version_number
331 );
332 --
333 -- 1. During an update system defaults are used to determine if
334 -- arguments have been defaulted or not. We must therefore
335 -- derive the full record structure values to be updated.
336 --
337 -- 2. Call the supporting update validate operations.
338 --
339 convert_defs(p_rec);
340 ben_xct_bus.update_validate(p_rec
341 ,p_effective_date);
342 --
343 -- Call the supporting pre-update operation
344 --
345 pre_update(p_rec);
346 --
347 -- Update the row.
348 --
349 update_dml(p_rec);
350 --
351 -- Call the supporting post-update operation
352 --
353 post_update(
354 p_effective_date,p_rec);
355 End upd;
356 --
357 -- ----------------------------------------------------------------------------
358 -- |---------------------------------< upd >----------------------------------|
359 -- ----------------------------------------------------------------------------
360 Procedure upd
361 (
362 p_effective_date in date,
363 p_ext_crit_typ_id in number,
364 p_crit_typ_cd in varchar2 default hr_api.g_varchar2,
365 p_ext_crit_prfl_id in number default hr_api.g_number,
366 p_business_group_id in number default hr_api.g_number,
367 p_legislation_code in varchar2 default hr_api.g_varchar2,
368 p_last_update_date in date default hr_api.g_date,
369 p_creation_date in date default hr_api.g_date,
370 p_last_updated_by in number default hr_api.g_number,
371 p_last_update_login in number default hr_api.g_number,
372 p_created_by in number default hr_api.g_number,
373 p_object_version_number in out nocopy number,
374 p_excld_flag in varchar2 default hr_api.g_varchar2
375 ) is
376 --
377 l_rec ben_xct_shd.g_rec_type;
378 l_proc varchar2(72) := g_package||'upd';
379 --
380 Begin
381 hr_utility.set_location('Entering:'||l_proc, 5);
382 --
383 -- Call conversion function to turn arguments into the
384 -- l_rec structure.
385 --
386 l_rec :=
387 ben_xct_shd.convert_args
388 (
389 p_ext_crit_typ_id,
390 p_crit_typ_cd,
391 p_ext_crit_prfl_id,
392 p_business_group_id,
393 p_legislation_code,
394 p_last_update_date ,
395 p_creation_date ,
396 p_last_updated_by ,
397 p_last_update_login,
398 p_created_by ,
399 p_object_version_number,
400 p_excld_flag
401 );
402 --
403 -- Having converted the arguments into the
404 -- plsql record structure we call the corresponding record
405 -- business process.
406 --
407 upd(
408 p_effective_date,l_rec);
409 p_object_version_number := l_rec.object_version_number;
410 --
411 hr_utility.set_location(' Leaving:'||l_proc, 10);
412 End upd;
413 --
414 end ben_xct_upd;