1 Package Body per_rcf_upd as
2 /* $Header: percfrhi.pkb 120.2 2006/04/07 04:33:51 cnholmes noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_rcf_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_rcf_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_recruitment_activity_for Row
69 --
70 update per_recruitment_activity_for
71 set
72 recruitment_activity_for_id = p_rec.rec_activity_for_id
73 ,business_group_id = p_rec.business_group_id
74 ,vacancy_id = p_rec.vacancy_id
75 ,recruitment_activity_id = p_rec.rec_activity_id
76 ,request_id = p_rec.request_id
77 ,program_application_id = p_rec.program_application_id
78 ,program_id = p_rec.program_id
79 ,program_update_date = p_rec.program_update_date
80 ,object_version_number = p_rec.object_version_number
81 where recruitment_activity_for_id = p_rec.rec_activity_for_id;
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_rcf_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_rcf_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_rcf_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_rcf_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_rcf_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_rcf_rku.after_update
195 (p_rec_activity_for_id
196 => p_rec.rec_activity_for_id
197 ,p_business_group_id
198 => p_rec.business_group_id
199 ,p_vacancy_id
200 => p_rec.vacancy_id
201 ,p_rec_activity_id
202 => p_rec.rec_activity_id
203 ,p_request_id
204 => p_rec.request_id
205 ,p_program_application_id
206 => p_rec.program_application_id
207 ,p_program_id
208 => p_rec.program_id
209 ,p_program_update_date
210 => p_rec.program_update_date
211 ,p_object_version_number
212 => p_rec.object_version_number
213 ,p_business_group_id_o
214 => per_rcf_shd.g_old_rec.business_group_id
215 ,p_vacancy_id_o
216 => per_rcf_shd.g_old_rec.vacancy_id
217 ,p_rec_activity_id_o
218 => per_rcf_shd.g_old_rec.rec_activity_id
219 ,p_request_id_o
220 => per_rcf_shd.g_old_rec.request_id
221 ,p_program_application_id_o
222 => per_rcf_shd.g_old_rec.program_application_id
223 ,p_program_id_o
224 => per_rcf_shd.g_old_rec.program_id
225 ,p_program_update_date_o
226 => per_rcf_shd.g_old_rec.program_update_date
227 ,p_object_version_number_o
228 => per_rcf_shd.g_old_rec.object_version_number
229 );
230 --
231 exception
232 --
233 when hr_api.cannot_find_prog_unit then
234 --
235 hr_api.cannot_find_prog_unit_error
236 (p_module_name => 'PER_RECRUITMENT_ACTIVITY_FOR'
237 ,p_hook_type => 'AU');
238 --
239 end;
240 --
241 hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End post_update;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |-----------------------------< convert_defs >-----------------------------|
246 -- ----------------------------------------------------------------------------
247 -- {Start Of Comments}
248 --
249 -- Description:
250 -- The Convert_Defs procedure has one very important function:
251 -- It must return the record structure for the row with all system defaulted
252 -- values converted into its corresponding parameter value for update. When
253 -- we attempt to update a row through the Upd process , certain
254 -- parameters can be defaulted which enables flexibility in the calling of
255 -- the upd process (e.g. only attributes which need to be updated need to be
256 -- specified). For the upd process to determine which attributes
257 -- have NOT been specified we need to check if the parameter has a reserved
258 -- system default value. Therefore, for all parameters which have a
259 -- corresponding reserved system default mechanism specified we need to
260 -- check if a system default is being used. If a system default is being
261 -- used then we convert the defaulted value into its corresponding attribute
262 -- value held in the g_old_rec data structure.
263 --
264 -- Prerequisites:
265 -- This private function can only be called from the upd process.
266 --
267 -- In Parameters:
268 -- A Pl/Sql record structure.
269 --
270 -- Post Success:
271 -- The record structure will be returned with all system defaulted parameter
272 -- values converted into its current row attribute value.
273 --
274 -- Post Failure:
275 -- No direct error handling is required within this function. Any possible
276 -- errors within this procedure will be a PL/SQL value error due to
277 -- conversion of datatypes or data lengths.
278 --
279 -- Developer Implementation Notes:
280 -- None.
281 --
282 -- Access Status:
283 -- Internal Row Handler Use Only.
284 --
285 -- {End Of Comments}
286 -- ----------------------------------------------------------------------------
287 Procedure convert_defs
288 (p_rec in out nocopy per_rcf_shd.g_rec_type
289 ) is
290 --
291 Begin
292 --
293 -- We must now examine each argument value in the
294 -- p_rec plsql record structure
295 -- to see if a system default is being used. If a system default
296 -- is being used then we must set to the 'current' argument value.
297 --
298 If (p_rec.business_group_id = hr_api.g_number) then
299 p_rec.business_group_id :=
300 per_rcf_shd.g_old_rec.business_group_id;
301 End If;
302 If (p_rec.vacancy_id = hr_api.g_number) then
303 p_rec.vacancy_id :=
304 per_rcf_shd.g_old_rec.vacancy_id;
305 End If;
306 If (p_rec.rec_activity_id = hr_api.g_number) then
307 p_rec.rec_activity_id :=
308 per_rcf_shd.g_old_rec.rec_activity_id;
309 End If;
310 If (p_rec.request_id = hr_api.g_number) then
311 p_rec.request_id :=
312 per_rcf_shd.g_old_rec.request_id;
313 End If;
314 If (p_rec.program_application_id = hr_api.g_number) then
315 p_rec.program_application_id :=
316 per_rcf_shd.g_old_rec.program_application_id;
317 End If;
318 If (p_rec.program_id = hr_api.g_number) then
319 p_rec.program_id :=
320 per_rcf_shd.g_old_rec.program_id;
321 End If;
322 If (p_rec.program_update_date = hr_api.g_date) then
323 p_rec.program_update_date :=
324 per_rcf_shd.g_old_rec.program_update_date;
325 End If;
326 --
327 End convert_defs;
328 --
329 -- ----------------------------------------------------------------------------
330 -- |---------------------------------< upd >----------------------------------|
331 -- ----------------------------------------------------------------------------
332 Procedure upd
333 (p_rec in out nocopy per_rcf_shd.g_rec_type
334 ) is
335 --
336 l_proc varchar2(72) := g_package||'upd';
337 --
338 Begin
339 hr_utility.set_location('Entering:'||l_proc, 5);
340 --
341 -- We must lock the row which we need to update.
342 --
343 per_rcf_shd.lck
344 (p_rec.rec_activity_for_id
345 ,p_rec.object_version_number
346 );
347 --
348 -- 1. During an update system defaults are used to determine if
349 -- arguments have been defaulted or not. We must therefore
350 -- derive the full record structure values to be updated.
351 --
355 per_rcf_bus.update_validate
352 -- 2. Call the supporting update validate operations.
353 --
354 convert_defs(p_rec);
356 (p_rec
357 );
358 -- Call to raise any errors on multi-message list
359 hr_multi_message.end_validation_set;
360 --
361 -- Call the supporting pre-update operation
362 --
363 per_rcf_upd.pre_update(p_rec);
364 --
365 -- Update the row.
366 --
367 per_rcf_upd.update_dml(p_rec);
368 --
369 -- Call the supporting post-update operation
370 --
371 per_rcf_upd.post_update
372 (p_rec
373 );
374 -- Call to raise any errors on multi-message list
375 hr_multi_message.end_validation_set;
376 End upd;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------------< upd >----------------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure upd
382 (p_rec_activity_for_id in number
383 ,p_object_version_number in out nocopy number
384 ,p_business_group_id in number default hr_api.g_number
385 ,p_vacancy_id in number default hr_api.g_number
386 ,p_rec_activity_id in number default hr_api.g_number
387 ,p_request_id in number default hr_api.g_number
388 ,p_program_application_id in number default hr_api.g_number
389 ,p_program_id in number default hr_api.g_number
390 ,p_program_update_date in date default hr_api.g_date
391 ) is
392 --
393 l_rec per_rcf_shd.g_rec_type;
394 l_proc varchar2(72) := g_package||'upd';
395 --
396 Begin
397 hr_utility.set_location('Entering:'||l_proc, 5);
398 --
399 -- Call conversion function to turn arguments into the
400 -- l_rec structure.
401 --
402 l_rec :=
403 per_rcf_shd.convert_args
404 (p_rec_activity_for_id
405 ,p_business_group_id
406 ,p_vacancy_id
407 ,p_rec_activity_id
408 ,p_request_id
409 ,p_program_application_id
410 ,p_program_id
411 ,p_program_update_date
412 ,p_object_version_number
413 );
414 --
415 -- Having converted the arguments into the
416 -- plsql record structure we call the corresponding record
417 -- business process.
418 --
419 per_rcf_upd.upd
420 (l_rec
421 );
422 p_object_version_number := l_rec.object_version_number;
423 --
424 hr_utility.set_location(' Leaving:'||l_proc, 10);
425 End upd;
426 --
427 end per_rcf_upd;