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