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