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