1 Package Body pqh_tem_upd as
2 /* $Header: pqtemrhi.pkb 120.2.12000000.2 2007/04/19 12:48:53 brsinha noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_tem_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 pqh_tem_shd.g_rec_type) is
49 --
50 l_proc varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53 hr_utility.set_location('Entering:'||l_proc, 5);
54 --
55 -- Increment the object version
56 --
57 p_rec.object_version_number := p_rec.object_version_number + 1;
58 --
59 --
60 -- Update the pqh_templates Row
61 --
62 update pqh_templates
63 set
64 template_name = p_rec.template_name,
65 short_name = p_rec.short_name,
66 template_id = p_rec.template_id,
67 attribute_only_flag = p_rec.attribute_only_flag,
68 enable_flag = p_rec.enable_flag,
69 create_flag = p_rec.create_flag,
70 transaction_category_id = p_rec.transaction_category_id,
71 under_review_flag = p_rec.under_review_flag,
72 object_version_number = p_rec.object_version_number,
73 freeze_status_cd = p_rec.freeze_status_cd,
74 template_type_cd = p_rec.template_type_cd,
75 legislation_code = p_rec.legislation_code
76 where template_id = p_rec.template_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 pqh_tem_shd.constraint_error
85 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86 When hr_api.parent_integrity_violated Then
87 -- Parent integrity has been violated
88 pqh_tem_shd.constraint_error
89 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90 When hr_api.unique_integrity_violated Then
91 -- Unique integrity has been violated
92 pqh_tem_shd.constraint_error
93 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94 When Others Then
95 Raise;
96 End update_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- |------------------------------< pre_update >------------------------------|
100 -- ----------------------------------------------------------------------------
101 -- {Start Of Comments}
102 --
103 -- Description:
104 -- This private procedure contains any processing which is required before
105 -- the update dml.
106 --
107 -- Prerequisites:
108 -- This is an internal procedure which is called from the upd procedure.
109 --
110 -- In Parameters:
111 -- A Pl/Sql record structre.
112 --
113 -- Post Success:
114 -- Processing continues.
115 --
116 -- Post Failure:
117 -- If an error has occurred, an error message and exception will be raised
118 -- but not handled.
119 --
120 -- Developer Implementation Notes:
121 -- Any pre-processing required before the update dml is issued should be
122 -- coded within this procedure. It is important to note that any 3rd party
123 -- maintenance should be reviewed before placing in this procedure.
124 --
125 -- Access Status:
126 -- Internal Row Handler Use Only.
127 --
128 -- {End Of Comments}
129 -- ----------------------------------------------------------------------------
130 Procedure pre_update(p_rec in pqh_tem_shd.g_rec_type) is
131 --
132 l_proc varchar2(72) := g_package||'pre_update';
133 --
134 Begin
135 hr_utility.set_location('Entering:'||l_proc, 5);
136 --
137 hr_utility.set_location(' Leaving:'||l_proc, 10);
138 End pre_update;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |-----------------------------< post_update >------------------------------|
142 -- ----------------------------------------------------------------------------
143 -- {Start Of Comments}
144 --
145 -- Description:
146 -- This private procedure contains any processing which is required after the
147 -- update dml.
148 --
149 -- Prerequisites:
150 -- This is an internal procedure which is called from the upd procedure.
151 --
152 -- In Parameters:
153 -- A Pl/Sql record structre.
154 --
155 -- Post Success:
156 -- Processing continues.
157 --
158 -- Post Failure:
159 -- If an error has occurred, an error message and exception will be raised
160 -- but not handled.
161 --
162 -- Developer Implementation Notes:
163 -- Any post-processing required after the update dml is issued should be
164 -- coded within this procedure. It is important to note that any 3rd party
165 -- maintenance should be reviewed before placing in this procedure.
166 --
167 -- Access Status:
168 -- Internal Row Handler Use Only.
169 --
170 -- {End Of Comments}
171 -- ----------------------------------------------------------------------------
172 Procedure post_update(
173 p_effective_date in date,p_rec in pqh_tem_shd.g_rec_type) is
174 --
175 l_proc varchar2(72) := g_package||'post_update';
176 --
177 Begin
178 hr_utility.set_location('Entering:'||l_proc, 5);
179 --
180 --
181 -- Start of API User Hook for post_update.
182 --
183 begin
184 --
185 pqh_tem_rku.after_update
186 (
187 p_template_name =>p_rec.template_name
188 ,p_short_name =>p_rec.short_name
189 ,p_template_id =>p_rec.template_id
190 ,p_attribute_only_flag =>p_rec.attribute_only_flag
191 ,p_enable_flag =>p_rec.enable_flag
192 ,p_create_flag =>p_rec.create_flag
193 ,p_transaction_category_id =>p_rec.transaction_category_id
194 ,p_under_review_flag =>p_rec.under_review_flag
195 ,p_object_version_number =>p_rec.object_version_number
196 ,p_freeze_status_cd =>p_rec.freeze_status_cd
197 ,p_template_type_cd =>p_rec.template_type_cd
198 ,p_legislation_code =>p_rec.legislation_code
199 ,p_effective_date =>p_effective_date
200 ,p_template_name_o =>pqh_tem_shd.g_old_rec.template_name
201 ,p_short_name_o =>pqh_tem_shd.g_old_rec.short_name
202 ,p_attribute_only_flag_o =>pqh_tem_shd.g_old_rec.attribute_only_flag
203 ,p_enable_flag_o =>pqh_tem_shd.g_old_rec.enable_flag
204 ,p_create_flag_o =>pqh_tem_shd.g_old_rec.create_flag
205 ,p_transaction_category_id_o =>pqh_tem_shd.g_old_rec.transaction_category_id
206 ,p_under_review_flag_o =>pqh_tem_shd.g_old_rec.under_review_flag
207 ,p_object_version_number_o =>pqh_tem_shd.g_old_rec.object_version_number
208 ,p_freeze_status_cd_o =>pqh_tem_shd.g_old_rec.freeze_status_cd
209 ,p_template_type_cd_o =>pqh_tem_shd.g_old_rec.template_type_cd
210 ,p_legislation_code_o =>pqh_tem_shd.g_old_rec.legislation_code
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 => 'pqh_templates'
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 pqh_tem_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.template_name = hr_api.g_varchar2) then
286 p_rec.template_name :=
287 pqh_tem_shd.g_old_rec.template_name;
288 End If;
289 If (p_rec.short_name = hr_api.g_varchar2) then
290 p_rec.short_name :=
291 pqh_tem_shd.g_old_rec.short_name;
292 End If;
293 If (p_rec.attribute_only_flag = hr_api.g_varchar2) then
294 p_rec.attribute_only_flag :=
295 pqh_tem_shd.g_old_rec.attribute_only_flag;
296 End If;
297 If (p_rec.enable_flag = hr_api.g_varchar2) then
298 p_rec.enable_flag :=
299 pqh_tem_shd.g_old_rec.enable_flag;
300 End If;
301 If (p_rec.create_flag = hr_api.g_varchar2) then
302 p_rec.create_flag :=
303 pqh_tem_shd.g_old_rec.create_flag;
304 End If;
305 If (p_rec.transaction_category_id = hr_api.g_number) then
306 p_rec.transaction_category_id :=
307 pqh_tem_shd.g_old_rec.transaction_category_id;
308 End If;
309 If (p_rec.under_review_flag = hr_api.g_varchar2) then
310 p_rec.under_review_flag :=
311 pqh_tem_shd.g_old_rec.under_review_flag;
312 End If;
313 If (p_rec.freeze_status_cd = hr_api.g_varchar2) then
314 p_rec.freeze_status_cd :=
315 pqh_tem_shd.g_old_rec.freeze_status_cd;
316 End If;
317 If (p_rec.template_type_cd = hr_api.g_varchar2) then
318 p_rec.template_type_cd :=
319 pqh_tem_shd.g_old_rec.template_type_cd;
320 End If;
321 If (p_rec.legislation_code = hr_api.g_varchar2) then
322 p_rec.legislation_code :=
323 pqh_tem_shd.g_old_rec.legislation_code;
324 End If;
325 --
326 hr_utility.set_location(' Leaving:'||l_proc, 10);
327 --
328 End convert_defs;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------------< upd >----------------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure upd
334 (
335 p_effective_date in date,
336 p_rec in out nocopy pqh_tem_shd.g_rec_type
337 ) is
338 --
339 l_proc varchar2(72) := g_package||'upd';
340 --
341 Begin
342 hr_utility.set_location('Entering:'||l_proc, 5);
343 --
344 -- We must lock the row which we need to update.
345 --
346 pqh_tem_shd.lck
347 (
348 p_rec.template_id,
349 p_rec.object_version_number
350 );
351 --
352 -- 1. During an update system defaults are used to determine if
353 -- arguments have been defaulted or not. We must therefore
354 -- derive the full record structure values to be updated.
355 --
356 -- 2. Call the supporting update validate operations.
357 --
358 convert_defs(p_rec);
359 pqh_tem_bus.update_validate(p_rec
360 ,p_effective_date);
361 --
362 -- Call the supporting pre-update operation
363 --
364 pre_update(p_rec);
365 --
366 -- Update the row.
367 --
368 update_dml(p_rec);
369 --
370 -- Call the supporting post-update operation
371 --
372 post_update(
373 p_effective_date,p_rec);
374 End upd;
375 --
376 -- ----------------------------------------------------------------------------
377 -- |---------------------------------< upd >----------------------------------|
378 -- ----------------------------------------------------------------------------
379 Procedure upd
380 (
381 p_effective_date in date,
382 p_template_name in varchar2 default hr_api.g_varchar2,
383 p_short_name in varchar2 default hr_api.g_varchar2,
384 p_template_id in number,
385 p_attribute_only_flag in varchar2 default hr_api.g_varchar2,
386 p_enable_flag in varchar2 default hr_api.g_varchar2,
387 p_create_flag in varchar2 default hr_api.g_varchar2,
388 p_transaction_category_id in number default hr_api.g_number,
389 p_under_review_flag in varchar2 default hr_api.g_varchar2,
390 p_object_version_number in out nocopy number,
391 p_freeze_status_cd in varchar2 default hr_api.g_varchar2,
392 p_template_type_cd in varchar2 default hr_api.g_varchar2,
393 p_legislation_code in varchar2 default hr_api.g_varchar2
394 ) is
395 --
396 l_rec pqh_tem_shd.g_rec_type;
397 l_proc varchar2(72) := g_package||'upd';
398 --
399 Begin
400 hr_utility.set_location('Entering:'||l_proc, 5);
401 --
402 -- Call conversion function to turn arguments into the
403 -- l_rec structure.
404 --
405 l_rec :=
406 pqh_tem_shd.convert_args
407 (
408 p_template_name,
409 p_short_name,
410 p_template_id,
411 p_attribute_only_flag,
412 p_enable_flag,
413 p_create_flag,
414 p_transaction_category_id,
415 p_under_review_flag,
416 p_object_version_number,
417 p_freeze_status_cd ,
418 p_template_type_cd,
419 p_legislation_code
420 );
421 --
422 -- Having converted the arguments into the
423 -- plsql record structure we call the corresponding record
424 -- business process.
425 --
426 upd(
427 p_effective_date,l_rec);
428 p_object_version_number := l_rec.object_version_number;
429 --
430 hr_utility.set_location(' Leaving:'||l_proc, 10);
431 End upd;
432 --
433 end pqh_tem_upd;