1 Package Body ghr_nla_upd as
2 /* $Header: ghnlarhi.pkb 120.1.12010000.1 2009/03/26 10:12:16 utokachi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_nla_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 ghr_nla_shd.g_rec_type) is
49 --
50 l_proc varchar2(72);
51 --
52 l_rec ghr_nla_shd.g_rec_type;
53 Begin
54 l_proc := g_package||'update_dml';
55 l_rec := p_rec;
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 ghr_noac_las Row
64 --
65 update ghr_noac_las
66 set
67 noac_la_id = p_rec.noac_la_id,
68 nature_of_action_id = p_rec.nature_of_action_id,
69 lac_lookup_code = p_rec.lac_lookup_code,
70 enabled_flag = p_rec.enabled_flag,
71 date_from = p_rec.date_from,
72 date_to = p_rec.date_to,
73 object_version_number = p_rec.object_version_number,
74 valid_first_lac_flag = p_rec.valid_first_lac_flag,
75 valid_second_lac_flag = p_rec.valid_second_lac_flag
76 where noac_la_id = p_rec.noac_la_id;
77 --
78 --
79 hr_utility.set_location(' Leaving:'||l_proc, 10);
80 --
81 Exception
82 When hr_api.check_integrity_violated Then
83 -- A check constraint has been violated
84 p_rec := l_rec;
85 ghr_nla_shd.constraint_error
86 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
87 When hr_api.parent_integrity_violated Then
88 -- Parent integrity has been violated
89 p_rec := l_rec;
90 ghr_nla_shd.constraint_error
91 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92 When hr_api.unique_integrity_violated Then
93 -- Unique integrity has been violated
94 p_rec := l_rec;
95 ghr_nla_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When Others Then
98 p_rec := l_rec;
99 Raise;
100 End update_dml;
101 --
102 -- ----------------------------------------------------------------------------
103 -- |------------------------------< pre_update >------------------------------|
104 -- ----------------------------------------------------------------------------
105 -- {Start Of Comments}
106 --
107 -- Description:
108 -- This private procedure contains any processing which is required before
109 -- the update dml.
110 --
111 -- Prerequisites:
112 -- This is an internal procedure which is called from the upd procedure.
113 --
114 -- In Parameters:
115 -- A Pl/Sql record structre.
116 --
117 -- Post Success:
118 -- Processing continues.
119 --
120 -- Post Failure:
121 -- If an error has occurred, an error message and exception will be raised
122 -- but not handled.
123 --
124 -- Developer Implementation Notes:
125 -- Any pre-processing required before the update dml is issued should be
126 -- coded within this procedure. It is important to note that any 3rd party
127 -- maintenance should be reviewed before placing in this procedure.
128 --
129 -- Access Status:
130 -- Internal Row Handler Use Only.
131 --
132 -- {End Of Comments}
133 -- ----------------------------------------------------------------------------
134 Procedure pre_update(p_rec in ghr_nla_shd.g_rec_type) is
135 --
136 l_proc varchar2(72) ;
137 --
138 Begin
139 l_proc := g_package||'pre_update';
140 hr_utility.set_location('Entering:'||l_proc, 5);
141 --
142 hr_utility.set_location(' Leaving:'||l_proc, 10);
143 End pre_update;
144 --
145 -- ----------------------------------------------------------------------------
146 -- |-----------------------------< post_update >------------------------------|
147 -- ----------------------------------------------------------------------------
148 -- {Start Of Comments}
149 --
150 -- Description:
151 -- This private procedure contains any processing which is required after the
152 -- update dml.
153 --
154 -- Prerequisites:
155 -- This is an internal procedure which is called from the upd procedure.
156 --
157 -- In Parameters:
158 -- A Pl/Sql record structre.
159 --
160 -- Post Success:
161 -- Processing continues.
162 --
163 -- Post Failure:
164 -- If an error has occurred, an error message and exception will be raised
165 -- but not handled.
166 --
167 -- Developer Implementation Notes:
168 -- Any post-processing required after the update dml is issued should be
169 -- coded within this procedure. It is important to note that any 3rd party
170 -- maintenance should be reviewed before placing in this procedure.
171 --
172 -- Access Status:
173 -- Internal Row Handler Use Only.
174 --
175 -- {End Of Comments}
176 -- ----------------------------------------------------------------------------
177 Procedure post_update(
178 p_effective_date in date,p_rec in ghr_nla_shd.g_rec_type) is
179 --
180 l_proc varchar2(72) ;
181 --
182 Begin
183 l_proc := g_package||'post_update';
184 hr_utility.set_location('Entering:'||l_proc, 5);
185 --
186 --
187 -- Start of API User Hook for post_update.
188 --
189 begin
190 --
191 ghr_nla_rku.after_update
192 (
193 p_noac_la_id =>p_rec.noac_la_id
194 ,p_nature_of_action_id =>p_rec.nature_of_action_id
195 ,p_lac_lookup_code =>p_rec.lac_lookup_code
196 ,p_enabled_flag =>p_rec.enabled_flag
197 ,p_date_from =>p_rec.date_from
198 ,p_date_to =>p_rec.date_to
199 ,p_object_version_number =>p_rec.object_version_number
200 ,p_valid_first_lac_flag =>p_rec.valid_first_lac_flag
201 ,p_valid_second_lac_flag =>p_rec.valid_second_lac_flag
202 ,p_effective_date =>p_effective_date
203 ,p_nature_of_action_id_o =>ghr_nla_shd.g_old_rec.nature_of_action_id
204 ,p_lac_lookup_code_o =>ghr_nla_shd.g_old_rec.lac_lookup_code
205 ,p_enabled_flag_o =>ghr_nla_shd.g_old_rec.enabled_flag
206 ,p_date_from_o =>ghr_nla_shd.g_old_rec.date_from
207 ,p_date_to_o =>ghr_nla_shd.g_old_rec.date_to
208 ,p_object_version_number_o =>ghr_nla_shd.g_old_rec.object_version_number
209 ,p_valid_first_lac_flag_o =>ghr_nla_shd.g_old_rec.valid_first_lac_flag
210 ,p_valid_second_lac_flag_o =>ghr_nla_shd.g_old_rec.valid_second_lac_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 => 'ghr_noac_las'
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 ghr_nla_shd.g_rec_type) is
273 --
274 l_proc varchar2(72);
275 --
276 l_rec ghr_nla_shd.g_rec_type;
277 Begin
278 --
279 l_proc := g_package||'convert_defs';
280 l_rec := p_rec;
281 hr_utility.set_location('Entering:'||l_proc, 5);
282 --
283 -- We must now examine each argument value in the
284 -- p_rec plsql record structure
285 -- to see if a system default is being used. If a system default
286 -- is being used then we must set to the 'current' argument value.
287 --
288 If (p_rec.nature_of_action_id = hr_api.g_number) then
289 p_rec.nature_of_action_id :=
290 ghr_nla_shd.g_old_rec.nature_of_action_id;
291 End If;
292 If (p_rec.lac_lookup_code = hr_api.g_varchar2) then
293 p_rec.lac_lookup_code :=
294 ghr_nla_shd.g_old_rec.lac_lookup_code;
295 End If;
296 If (p_rec.enabled_flag = hr_api.g_varchar2) then
297 p_rec.enabled_flag :=
298 ghr_nla_shd.g_old_rec.enabled_flag;
299 End If;
300 If (p_rec.date_from = hr_api.g_date) then
301 p_rec.date_from :=
302 ghr_nla_shd.g_old_rec.date_from;
303 End If;
304 If (p_rec.date_to = hr_api.g_date) then
305 p_rec.date_to :=
306 ghr_nla_shd.g_old_rec.date_to;
307 End If;
308 If (p_rec.valid_first_lac_flag = hr_api.g_varchar2) then
309 p_rec.valid_first_lac_flag :=
310 ghr_nla_shd.g_old_rec.valid_first_lac_flag;
311 End If;
312 If (p_rec.valid_second_lac_flag = hr_api.g_varchar2) then
313 p_rec.valid_second_lac_flag :=
314 ghr_nla_shd.g_old_rec.valid_second_lac_flag;
315 End If;
316 --
317 hr_utility.set_location(' Leaving:'||l_proc, 10);
318 --
319 exception
320 when others then
321 p_rec := l_rec;
322 raise;
323 End convert_defs;
324 --
325 -- ----------------------------------------------------------------------------
326 -- |---------------------------------< upd >----------------------------------|
327 -- ----------------------------------------------------------------------------
328 Procedure upd
329 (
330 p_effective_date in date,
331 p_rec in out NOCOPY ghr_nla_shd.g_rec_type
332 ) is
333 --
334 l_proc varchar2(72);
335 l_rec ghr_nla_shd.g_rec_type;
336 --
337 Begin
338 l_proc := g_package||'upd';
339 hr_utility.set_location('Entering:'||l_proc, 5);
340 l_rec := p_rec;
341 --
342 -- We must lock the row which we need to update.
343 --
344 ghr_nla_shd.lck
345 (
346 p_rec.noac_la_id,
347 p_rec.object_version_number
348 );
349 --
350 -- 1. During an update system defaults are used to determine if
351 -- arguments have been defaulted or not. We must therefore
352 -- derive the full record structure values to be updated.
353 --
354 -- 2. Call the supporting update validate operations.
355 --
356 convert_defs(p_rec);
357 ghr_nla_bus.update_validate(p_rec
358 ,p_effective_date);
359 --
360 -- Call the supporting pre-update operation
361 --
362 pre_update(p_rec);
363 --
364 -- Update the row.
365 --
366 update_dml(p_rec);
367 --
368 -- Call the supporting post-update operation
369 --
370 post_update(
371 p_effective_date,p_rec);
372 exception
373 when others then
374 p_rec := l_rec;
375 raise;
376 End upd;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------------< upd >----------------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure upd
382 (
383 p_effective_date in date,
384 p_noac_la_id in number,
385 p_nature_of_action_id in number default hr_api.g_number,
386 p_lac_lookup_code in varchar2 default hr_api.g_varchar2,
387 p_enabled_flag in varchar2 default hr_api.g_varchar2,
388 p_date_from in date default hr_api.g_date,
389 p_date_to in date default hr_api.g_date,
390 p_object_version_number in out NOCOPY number,
391 p_valid_first_lac_flag in varchar2 default hr_api.g_varchar2,
392 p_valid_second_lac_flag in varchar2 default hr_api.g_varchar2
393 ) is
394 --
395 l_rec ghr_nla_shd.g_rec_type;
396 l_proc varchar2(72);
397 l_object_version_number number;
398 --
399 Begin
400 l_proc := g_package||'upd';
401 hr_utility.set_location('Entering:'||l_proc, 5);
402 l_object_version_number := p_object_version_number;
403 --
404 -- Call conversion function to turn arguments into the
405 -- l_rec structure.
406 --
407 l_rec :=
408 ghr_nla_shd.convert_args
409 (
410 p_noac_la_id,
411 p_nature_of_action_id,
412 p_lac_lookup_code,
413 p_enabled_flag,
414 p_date_from,
415 p_date_to,
416 p_object_version_number,
417 p_valid_first_lac_flag,
418 p_valid_second_lac_flag
419 );
420 --
421 -- Having converted the arguments into the
422 -- plsql record structure we call the corresponding record
423 -- business process.
424 --
425 upd(
426 p_effective_date,l_rec);
427 p_object_version_number := l_rec.object_version_number;
428 --
429 hr_utility.set_location(' Leaving:'||l_proc, 10);
430 exception
431 when others then
432 p_object_version_number := l_object_version_number;
433 raise;
434 End upd;
435 --
436 end ghr_nla_upd;