1 Package Body ben_ctk_upd as
2 /* $Header: bectkrhi.pkb 120.0 2005/05/28 01:25 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_ctk_upd.'; -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- This procedure controls the actual dml update logic. The processing of
18 -- this procedure is:
19 -- 1) Increment the object_version_number by 1 if the object_version_number
20 -- is defined as an attribute for this entity.
21 -- 2) To set and unset the g_api_dml status as required (as we are about to
22 -- perform dml).
23 -- 3) To update the specified row in the schema using the primary key in
24 -- the predicates.
25 -- 4) To trap any constraint violations that may have occurred.
26 -- 5) To raise any other errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the upd
30 -- procedure.
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be updated in the schema.
37 --
38 -- Post Failure:
39 -- On the update dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If a check, unique or parent integrity constraint violation is raised the
42 -- constraint_error procedure will be called.
43 -- If any other error is reported, the error will be raised after the
44 -- g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 -- The update 'set' attribute list should be modified if any of your
48 -- attributes are not updateable.
49 --
50 -- Access Status:
51 -- Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure update_dml
56 (p_rec in out nocopy ben_ctk_shd.g_rec_type
57 ) is
58 --
59 l_proc varchar2(72) := g_package||'update_dml';
60 --
61 Begin
62 if g_debug then
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 end if;
65 --
66 -- Increment the object version
67 p_rec.object_version_number := p_rec.object_version_number + 1;
68 --
69 ben_ctk_shd.g_api_dml := true; -- Set the api dml status
70 --
71 -- Update the ben_cwb_person_tasks Row
72 --
73 update ben_cwb_person_tasks
74 set
75 group_pl_id = p_rec.group_pl_id
76 ,lf_evt_ocrd_dt = p_rec.lf_evt_ocrd_dt
77 ,status_cd = p_rec.status_cd
78 ,access_cd = p_rec.access_cd
79 ,task_last_update_date = p_rec.task_last_update_date
80 ,task_last_update_by = p_rec.task_last_update_by
81 ,object_version_number = p_rec.object_version_number
82 where group_per_in_ler_id = p_rec.group_per_in_ler_id
83 and task_id = p_rec.task_id;
84 --
85 ben_ctk_shd.g_api_dml := false; -- Unset the api dml status
86 --
87 if g_debug then
88 hr_utility.set_location(' Leaving:'||l_proc, 10);
89 end if;
90 --
91 Exception
92 When hr_api.check_integrity_violated Then
93 -- A check constraint has been violated
94 ben_ctk_shd.g_api_dml := false; -- Unset the api dml status
95 ben_ctk_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When hr_api.parent_integrity_violated Then
98 -- Parent integrity has been violated
99 ben_ctk_shd.g_api_dml := false; -- Unset the api dml status
100 ben_ctk_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When hr_api.unique_integrity_violated Then
103 -- Unique integrity has been violated
104 ben_ctk_shd.g_api_dml := false; -- Unset the api dml status
105 ben_ctk_shd.constraint_error
106 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107 When Others Then
108 ben_ctk_shd.g_api_dml := false; -- Unset the api dml status
109 Raise;
110 End update_dml;
111 --
112 -- ----------------------------------------------------------------------------
113 -- |------------------------------< pre_update >------------------------------|
114 -- ----------------------------------------------------------------------------
115 -- {Start Of Comments}
116 --
117 -- Description:
118 -- This private procedure contains any processing which is required before
119 -- the update dml.
120 --
121 -- Prerequisites:
122 -- This is an internal procedure which is called from the upd procedure.
123 --
124 -- In Parameters:
125 -- A Pl/Sql record structure.
126 --
127 -- Post Success:
128 -- Processing continues.
129 --
130 -- Post Failure:
131 -- If an error has occurred, an error message and exception wil be raised
132 -- but not handled.
133 --
134 -- Developer Implementation Notes:
135 -- Any pre-processing required before the update dml is issued should be
136 -- coded within this procedure. It is important to note that any 3rd party
137 -- maintenance should be reviewed before placing in this procedure.
138 --
139 -- Access Status:
140 -- Internal Row Handler Use Only.
141 --
142 -- {End Of Comments}
143 -- ----------------------------------------------------------------------------
144 Procedure pre_update
145 (p_rec in ben_ctk_shd.g_rec_type
146 ) is
147 --
148 l_proc varchar2(72) := g_package||'pre_update';
149 --
150 Begin
151 if g_debug then
152 hr_utility.set_location('Entering:'||l_proc, 5);
153 end if;
154 --
155 if g_debug then
156 hr_utility.set_location(' Leaving:'||l_proc, 10);
157 end if;
158 End pre_update;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------------< post_update >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- This private procedure contains any processing which is required after
167 -- the update dml.
168 --
169 -- Prerequisites:
170 -- This is an internal procedure which is called from the upd procedure.
171 --
172 -- In Parameters:
173 -- A Pl/Sql record structure.
174 --
175 -- Post Success:
176 -- Processing continues.
177 --
178 -- Post Failure:
179 -- If an error has occurred, an error message and exception will be raised
180 -- but not handled.
181 --
182 -- Developer Implementation Notes:
183 -- Any post-processing required after the update dml is issued should be
184 -- coded within this procedure. It is important to note that any 3rd party
185 -- maintenance should be reviewed before placing in this procedure.
186 --
187 -- Access Status:
188 -- Internal Row Handler Use Only.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure post_update
193 (p_rec in ben_ctk_shd.g_rec_type
194 ) is
195 --
196 l_proc varchar2(72) := g_package||'post_update';
197 --
198 Begin
199 if g_debug then
200 hr_utility.set_location('Entering:'||l_proc, 5);
201 end if;
202 begin
203 --
204 ben_ctk_rku.after_update
205 (p_group_per_in_ler_id
206 => p_rec.group_per_in_ler_id
207 ,p_task_id
208 => p_rec.task_id
209 ,p_group_pl_id
210 => p_rec.group_pl_id
211 ,p_lf_evt_ocrd_dt
212 => p_rec.lf_evt_ocrd_dt
213 ,p_status_cd
214 => p_rec.status_cd
215 ,p_access_cd
216 => p_rec.access_cd
217 ,p_task_last_update_date
218 => p_rec.task_last_update_date
219 ,p_task_last_update_by
220 => p_rec.task_last_update_by
221 ,p_object_version_number
222 => p_rec.object_version_number
223 ,p_group_pl_id_o
224 => ben_ctk_shd.g_old_rec.group_pl_id
225 ,p_lf_evt_ocrd_dt_o
226 => ben_ctk_shd.g_old_rec.lf_evt_ocrd_dt
227 ,p_status_cd_o
228 => ben_ctk_shd.g_old_rec.status_cd
229 ,p_access_cd_o
230 => ben_ctk_shd.g_old_rec.access_cd
231 ,p_task_last_update_date_o
232 => ben_ctk_shd.g_old_rec.task_last_update_date
233 ,p_task_last_update_by_o
234 => ben_ctk_shd.g_old_rec.task_last_update_by
235 ,p_object_version_number_o
236 => ben_ctk_shd.g_old_rec.object_version_number
237 );
238 --
239 exception
240 --
241 when hr_api.cannot_find_prog_unit then
242 --
243 hr_api.cannot_find_prog_unit_error
244 (p_module_name => 'BEN_CWB_PERSON_TASKS'
245 ,p_hook_type => 'AU');
246 --
247 end;
248 --
249 if g_debug then
250 hr_utility.set_location(' Leaving:'||l_proc, 10);
251 end if;
252 End post_update;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< convert_defs >-----------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 -- The Convert_Defs procedure has one very important function:
261 -- It must return the record structure for the row with all system defaulted
262 -- values converted into its corresponding parameter value for update. When
263 -- we attempt to update a row through the Upd process , certain
264 -- parameters can be defaulted which enables flexibility in the calling of
265 -- the upd process (e.g. only attributes which need to be updated need to be
266 -- specified). For the upd process to determine which attributes
267 -- have NOT been specified we need to check if the parameter has a reserved
268 -- system default value. Therefore, for all parameters which have a
269 -- corresponding reserved system default mechanism specified we need to
270 -- check if a system default is being used. If a system default is being
271 -- used then we convert the defaulted value into its corresponding attribute
272 -- value held in the g_old_rec data structure.
273 --
274 -- Prerequisites:
275 -- This private function can only be called from the upd process.
276 --
277 -- In Parameters:
278 -- A Pl/Sql record structure.
279 --
280 -- Post Success:
281 -- The record structure will be returned with all system defaulted parameter
282 -- values converted into its current row attribute value.
283 --
284 -- Post Failure:
285 -- No direct error handling is required within this function. Any possible
286 -- errors within this procedure will be a PL/SQL value error due to
287 -- conversion of datatypes or data lengths.
288 --
289 -- Developer Implementation Notes:
290 -- None.
291 --
292 -- Access Status:
293 -- Internal Row Handler Use Only.
294 --
295 -- {End Of Comments}
296 -- ----------------------------------------------------------------------------
297 Procedure convert_defs
298 (p_rec in out nocopy ben_ctk_shd.g_rec_type
299 ) is
300 --
301 Begin
302 --
303 -- We must now examine each argument value in the
304 -- p_rec plsql record structure
305 -- to see if a system default is being used. If a system default
306 -- is being used then we must set to the 'current' argument value.
307 --
308 If (p_rec.group_pl_id = hr_api.g_number) then
309 p_rec.group_pl_id :=
310 ben_ctk_shd.g_old_rec.group_pl_id;
311 End If;
312 If (p_rec.lf_evt_ocrd_dt = hr_api.g_date) then
313 p_rec.lf_evt_ocrd_dt :=
314 ben_ctk_shd.g_old_rec.lf_evt_ocrd_dt;
315 End If;
316 If (p_rec.status_cd = hr_api.g_varchar2) then
317 p_rec.status_cd :=
318 ben_ctk_shd.g_old_rec.status_cd;
319 End If;
320 If (p_rec.access_cd = hr_api.g_varchar2) then
321 p_rec.access_cd :=
322 ben_ctk_shd.g_old_rec.access_cd;
323 End If;
324 If (p_rec.task_last_update_date = hr_api.g_date) then
325 p_rec.task_last_update_date :=
326 ben_ctk_shd.g_old_rec.task_last_update_date;
327 End If;
328 If (p_rec.task_last_update_by = hr_api.g_number) then
329 p_rec.task_last_update_by :=
330 ben_ctk_shd.g_old_rec.task_last_update_by;
331 End If;
332 --
333 End convert_defs;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |---------------------------------< upd >----------------------------------|
337 -- ----------------------------------------------------------------------------
338 Procedure upd
339 (p_rec in out nocopy ben_ctk_shd.g_rec_type
340 ) is
341 --
342 l_proc varchar2(72) := g_package||'upd';
343 --
344 Begin
345 if g_debug then
346 hr_utility.set_location('Entering:'||l_proc, 5);
347 end if;
348 --
349 -- We must lock the row which we need to update.
350 --
351 ben_ctk_shd.lck
352 (p_rec.group_per_in_ler_id
353 ,p_rec.task_id
354 ,p_rec.object_version_number
355 );
356 --
357 -- 1. During an update system defaults are used to determine if
358 -- arguments have been defaulted or not. We must therefore
359 -- derive the full record structure values to be updated.
360 --
361 -- 2. Call the supporting update validate operations.
362 --
363 convert_defs(p_rec);
364 ben_ctk_bus.update_validate
365 (p_rec
366 );
367 --
368 -- Call to raise any errors on multi-message list
369 hr_multi_message.end_validation_set;
370 --
371 -- Call the supporting pre-update operation
372 --
373 ben_ctk_upd.pre_update(p_rec);
374 --
375 -- Update the row.
376 --
377 ben_ctk_upd.update_dml(p_rec);
378 --
379 -- Call the supporting post-update operation
380 --
381 ben_ctk_upd.post_update
382 (p_rec
383 );
384 --
385 -- Call to raise any errors on multi-message list
386 hr_multi_message.end_validation_set;
387 End upd;
388 --
389 -- ----------------------------------------------------------------------------
390 -- |---------------------------------< upd >----------------------------------|
391 -- ----------------------------------------------------------------------------
392 Procedure upd
393 (p_group_per_in_ler_id in number
394 ,p_task_id in number
395 ,p_object_version_number in out nocopy number
396 ,p_group_pl_id in number default hr_api.g_number
397 ,p_lf_evt_ocrd_dt in date default hr_api.g_date
398 ,p_status_cd in varchar2 default hr_api.g_varchar2
399 ,p_access_cd in varchar2 default hr_api.g_varchar2
400 ,p_task_last_update_date in date default hr_api.g_date
401 ,p_task_last_update_by in number default hr_api.g_number
402 ) is
403 --
404 l_rec ben_ctk_shd.g_rec_type;
405 l_proc varchar2(72) := g_package||'upd';
406 --
407 Begin
408 if g_debug then
409 hr_utility.set_location('Entering:'||l_proc, 5);
410 end if;
411 --
412 -- Call conversion function to turn arguments into the
413 -- l_rec structure.
414 --
415 l_rec :=
416 ben_ctk_shd.convert_args
417 (p_group_per_in_ler_id
418 ,p_task_id
419 ,p_group_pl_id
420 ,p_lf_evt_ocrd_dt
421 ,p_status_cd
422 ,p_access_cd
423 ,p_task_last_update_date
424 ,p_task_last_update_by
425 ,p_object_version_number
426 );
427 --
428 -- Having converted the arguments into the
429 -- plsql record structure we call the corresponding record
430 -- business process.
431 --
432 ben_ctk_upd.upd
433 (l_rec
434 );
435 p_object_version_number := l_rec.object_version_number;
436 --
437 if g_debug then
438 hr_utility.set_location(' Leaving:'||l_proc, 10);
439 end if;
440 End upd;
441 --
442 end ben_ctk_upd;