1 Package Body per_wbi_upd as
2 /* $Header: pewbirhi.pkb 115.0 2003/07/03 05:55:25 kavenkat noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_wbi_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_wbi_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_ri_workbench_items Row
69 --
70 update per_ri_workbench_items
71 set
72 workbench_item_code = p_rec.workbench_item_code
73 ,menu_id = p_rec.menu_id
74 ,workbench_item_sequence = p_rec.workbench_item_sequence
75 ,workbench_parent_item_code = p_rec.workbench_parent_item_code
76 ,workbench_item_creation_date = p_rec.workbench_item_creation_date
77 ,workbench_item_type = p_rec.workbench_item_type
78 ,object_version_number = p_rec.object_version_number
79 where workbench_item_code = p_rec.workbench_item_code;
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 per_wbi_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 per_wbi_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 per_wbi_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 per_wbi_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 per_wbi_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 per_wbi_rku.after_update
194 (p_effective_date => p_effective_date
195 ,p_workbench_item_code => p_rec.workbench_item_code
196 ,p_menu_id => p_rec.menu_id
197 ,p_workbench_item_sequence => p_rec.workbench_item_sequence
198 ,p_workbench_parent_item_code => p_rec.workbench_parent_item_code
199 ,p_workbench_item_creation_date => p_rec.workbench_item_creation_date
200 ,p_workbench_item_type => p_rec.workbench_item_type
201 ,p_object_version_number => p_rec.object_version_number
202 ,p_menu_id_o => per_wbi_shd.g_old_rec.menu_id
203 ,p_workbench_item_sequence_o => per_wbi_shd.g_old_rec.workbench_item_sequence
204 ,p_workbench_parent_item_code_o => per_wbi_shd.g_old_rec.workbench_parent_item_code
205 ,p_workbench_item_creation_da_o => per_wbi_shd.g_old_rec.workbench_item_creation_date
206 ,p_workbench_item_type_o => per_wbi_shd.g_old_rec.workbench_item_type
207 ,p_object_version_number_o => per_wbi_shd.g_old_rec.object_version_number
208 );
209 --
210 exception
211 --
212 when hr_api.cannot_find_prog_unit then
213 --
214 hr_api.cannot_find_prog_unit_error
215 (p_module_name => 'PER_RI_WORKBENCH_ITEMS'
216 ,p_hook_type => 'AU');
217 --
218 end;
219 --
220 hr_utility.set_location(' Leaving:'||l_proc, 10);
221 End post_update;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |-----------------------------< convert_defs >-----------------------------|
225 -- ----------------------------------------------------------------------------
226 -- {Start Of Comments}
227 --
228 -- Description:
229 -- The Convert_Defs procedure has one very important function:
230 -- It must return the record structure for the row with all system defaulted
231 -- values converted into its corresponding parameter value for update. When
232 -- we attempt to update a row through the Upd process , certain
233 -- parameters can be defaulted which enables flexibility in the calling of
234 -- the upd process (e.g. only attributes which need to be updated need to be
235 -- specified). For the upd process to determine which attributes
236 -- have NOT been specified we need to check if the parameter has a reserved
237 -- system default value. Therefore, for all parameters which have a
238 -- corresponding reserved system default mechanism specified we need to
239 -- check if a system default is being used. If a system default is being
240 -- used then we convert the defaulted value into its corresponding attribute
241 -- value held in the g_old_rec data structure.
242 --
243 -- Prerequisites:
244 -- This private function can only be called from the upd process.
245 --
246 -- In Parameters:
247 -- A Pl/Sql record structure.
248 --
249 -- Post Success:
250 -- The record structure will be returned with all system defaulted parameter
251 -- values converted into its current row attribute value.
252 --
253 -- Post Failure:
254 -- No direct error handling is required within this function. Any possible
255 -- errors within this procedure will be a PL/SQL value error due to
256 -- conversion of datatypes or data lengths.
257 --
258 -- Developer Implementation Notes:
259 -- None.
260 --
261 -- Access Status:
262 -- Internal Row Handler Use Only.
263 --
264 -- {End Of Comments}
265 -- ----------------------------------------------------------------------------
266 Procedure convert_defs
267 (p_rec in out nocopy per_wbi_shd.g_rec_type
268 ) is
269 --
270 Begin
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.menu_id = hr_api.g_number) then
278 p_rec.menu_id := per_wbi_shd.g_old_rec.menu_id;
279 End If;
280 If (p_rec.workbench_item_sequence = hr_api.g_number) then
281 p_rec.workbench_item_sequence := per_wbi_shd.g_old_rec.workbench_item_sequence;
282 End If;
283 If (p_rec.workbench_parent_item_code = hr_api.g_varchar2) then
284 p_rec.workbench_parent_item_code := per_wbi_shd.g_old_rec.workbench_parent_item_code;
285 End If;
286 If (p_rec.workbench_item_creation_date = hr_api.g_date) then
287 p_rec.workbench_item_creation_date := per_wbi_shd.g_old_rec.workbench_item_creation_date;
288 End If;
289 If (p_rec.workbench_item_type = hr_api.g_varchar2) then
290 p_rec.workbench_item_type := per_wbi_shd.g_old_rec.workbench_item_type;
291 End If;
292 --
293 End convert_defs;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |---------------------------------< upd >----------------------------------|
297 -- ----------------------------------------------------------------------------
298 Procedure upd
299 (p_effective_date in date
300 ,p_rec in out nocopy per_wbi_shd.g_rec_type
301 ) is
302 --
303 l_proc varchar2(72) := g_package||'upd';
304 --
305 Begin
306 hr_utility.set_location('Entering:'||l_proc, 5);
307 --
308 -- We must lock the row which we need to update.
309 --
310 per_wbi_shd.lck
311 (p_rec.workbench_item_code
312 ,p_rec.object_version_number
313 );
314 --
315 -- 1. During an update system defaults are used to determine if
316 -- arguments have been defaulted or not. We must therefore
317 -- derive the full record structure values to be updated.
318 --
319 -- 2. Call the supporting update validate operations.
320 --
321 convert_defs(p_rec);
322 per_wbi_bus.update_validate
323 (p_effective_date
324 ,p_rec
325 );
326 --
327 -- Call to raise any errors on multi-message list
328 hr_multi_message.end_validation_set;
329 --
330 -- Call the supporting pre-update operation
331 --
332 per_wbi_upd.pre_update(p_rec);
333 --
334 -- Update the row.
335 --
336 per_wbi_upd.update_dml(p_rec);
337 --
338 -- Call the supporting post-update operation
339 --
340 per_wbi_upd.post_update
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 End upd;
348 --
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------------< upd >----------------------------------|
351 -- ----------------------------------------------------------------------------
352 Procedure upd
353 (p_effective_date in date
354 ,p_workbench_item_code in varchar2
355 ,p_object_version_number in out nocopy number
356 ,p_menu_id in number default hr_api.g_number
357 ,p_workbench_item_sequence in number default hr_api.g_number
358 ,p_workbench_parent_item_code in varchar2 default hr_api.g_varchar2
359 ,p_workbench_item_creation_date in date default hr_api.g_date
360 ,p_workbench_item_type in varchar2 default hr_api.g_varchar2
361 ) is
362 --
363 l_rec per_wbi_shd.g_rec_type;
364 l_proc varchar2(72) := g_package||'upd';
365 --
366 Begin
367
368 hr_utility.set_location('Entering:'||l_proc, 5);
369 --
370 -- Call conversion function to turn arguments into the
371 -- l_rec structure.
372 --
373 l_rec :=
374 per_wbi_shd.convert_args
375 (p_workbench_item_code
376 ,p_menu_id
377 ,p_workbench_item_sequence
378 ,p_workbench_parent_item_code
379 ,p_workbench_item_creation_date
380 ,p_workbench_item_type
381 ,p_object_version_number
382 );
383
384
385 --
386 -- Having converted the arguments into the
387 -- plsql record structure we call the corresponding record
388 -- business process.
389 --
390 per_wbi_upd.upd
391 (p_effective_date
392 ,l_rec
393 );
394 p_object_version_number := l_rec.object_version_number;
395 --
396 hr_utility.set_location(' Leaving:'||l_proc, 10);
397 End upd;
398 --
399 end per_wbi_upd;