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