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