1 Package Body per_apl_ins as
2 /* $Header: peaplrhi.pkb 120.2.12020000.3 2013/01/18 06:52:05 srannama ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_apl_ins.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml insert logic. The processing of
17 -- this procedure are as follows:
18 -- 1) Initialise the object_version_number to 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 insert the row into the schema.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Pre Conditions:
27 -- This is an internal private procedure which must be called from the ins
28 -- procedure and must have all mandatory attributes set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 -- On the insert 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 -- None.
47 --
48 -- Access Status:
49 -- Internal Table Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_apl_shd.g_rec_type) is
54 --
55 l_proc varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58 hr_utility.set_location('Entering:'||l_proc, 5);
59 p_rec.object_version_number := 1; -- Initialise the object version
60 --
61 per_apl_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: per_applications
64 --
65 insert into per_applications
66 ( application_id,
67 business_group_id,
68 person_id,
69 date_received,
70 comments,
71 current_employer,
72 projected_hire_date,
73 successful_flag,
74 termination_reason,
75 request_id,
76 program_application_id,
77 program_id,
78 program_update_date,
79 appl_attribute_category,
80 appl_attribute1,
81 appl_attribute2,
82 appl_attribute3,
83 appl_attribute4,
84 appl_attribute5,
85 appl_attribute6,
86 appl_attribute7,
87 appl_attribute8,
88 appl_attribute9,
89 appl_attribute10,
90 appl_attribute11,
91 appl_attribute12,
92 appl_attribute13,
93 appl_attribute14,
94 appl_attribute15,
95 appl_attribute16,
96 appl_attribute17,
97 appl_attribute18,
98 appl_attribute19,
99 appl_attribute20,
100 object_version_number
101 )
102 Values
103 ( p_rec.application_id,
104 p_rec.business_group_id,
105 p_rec.person_id,
106 p_rec.date_received,
107 p_rec.comments,
108 p_rec.current_employer,
109 p_rec.projected_hire_date,
110 p_rec.successful_flag,
111 p_rec.termination_reason,
112 p_rec.request_id,
113 p_rec.program_application_id,
114 p_rec.program_id,
115 p_rec.program_update_date,
116 p_rec.appl_attribute_category,
117 p_rec.appl_attribute1,
118 p_rec.appl_attribute2,
119 p_rec.appl_attribute3,
120 p_rec.appl_attribute4,
121 p_rec.appl_attribute5,
122 p_rec.appl_attribute6,
123 p_rec.appl_attribute7,
124 p_rec.appl_attribute8,
125 p_rec.appl_attribute9,
126 p_rec.appl_attribute10,
127 p_rec.appl_attribute11,
128 p_rec.appl_attribute12,
129 p_rec.appl_attribute13,
130 p_rec.appl_attribute14,
131 p_rec.appl_attribute15,
132 p_rec.appl_attribute16,
133 p_rec.appl_attribute17,
134 p_rec.appl_attribute18,
135 p_rec.appl_attribute19,
136 p_rec.appl_attribute20,
137 p_rec.object_version_number
138 );
139 --
140 per_apl_shd.g_api_dml := false; -- Unset the api dml status
141 --
142 hr_utility.set_location(' Leaving:'||l_proc, 10);
143 Exception
144 When hr_api.check_integrity_violated Then
145 -- A check constraint has been violated
146 per_apl_shd.g_api_dml := false; -- Unset the api dml status
147 per_apl_shd.constraint_error
148 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
149 When hr_api.parent_integrity_violated Then
150 -- Parent integrity has been violated
151 per_apl_shd.g_api_dml := false; -- Unset the api dml status
152 per_apl_shd.constraint_error
153 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
154 When hr_api.unique_integrity_violated Then
155 -- Unique integrity has been violated
156 per_apl_shd.g_api_dml := false; -- Unset the api dml status
157 per_apl_shd.constraint_error
158 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
159 When Others Then
160 per_apl_shd.g_api_dml := false; -- Unset the api dml status
161 Raise;
162 End insert_dml;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |------------------------------< pre_insert >------------------------------|
166 -- ----------------------------------------------------------------------------
167 -- {Start Of Comments}
168 --
169 -- Description:
170 -- This private procedure contains any processing which is required before
171 -- the insert dml. Presently, if the entity has a corresponding primary
172 -- key which is maintained by an associating sequence, the primary key for
173 -- the entity will be populated with the next sequence value in
174 -- preparation for the insert dml.
175 --
176 -- Pre Conditions:
177 -- This is an internal procedure which is called from the ins procedure.
178 --
179 -- In Parameters:
180 -- A Pl/Sql record structre.
181 --
182 -- Post Success:
183 -- Processing continues.
184 --
185 -- Post Failure:
186 -- If an error has occurred, an error message and exception will be raised
187 -- but not handled.
188 --
189 -- Developer Implementation Notes:
190 -- Any pre-processing required before the insert dml is issued should be
191 -- coded within this procedure. As stated above, a good example is the
192 -- generation of a primary key number via a corresponding sequence.
193 -- It is important to note that any 3rd party maintenance should be reviewed
194 -- before placing in this procedure.
195 --
196 -- Access Status:
197 -- Internal Table Handler Use Only.
198 --
199 -- {End Of Comments}
200 -- ----------------------------------------------------------------------------
201 Procedure pre_insert(p_rec in out nocopy per_apl_shd.g_rec_type) is
202 --
203 l_proc varchar2(72) := g_package||'pre_insert';
204 --
205 Cursor C_Sel1 is select per_applications_s.nextval from sys.dual;
206 --
207 Begin
208 hr_utility.set_location('Entering:'||l_proc, 5);
209 --
210 --
211 -- Select the next sequence number
212 --
213 Open C_Sel1;
214 Fetch C_Sel1 Into p_rec.application_id;
215 Close C_Sel1;
216 --
217 hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End pre_insert;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |-----------------------------< post_insert >------------------------------|
222 -- ----------------------------------------------------------------------------
223 -- {Start Of Comments}
224 --
225 -- Description:
226 -- This private procedure contains any processing which is required after the
227 -- insert dml.
228 --
229 -- Pre Conditions:
230 -- This is an internal procedure which is called from the ins procedure.
231 --
232 -- In Parameters:
233 -- A Pl/Sql record structre.
234 --
235 -- Post Success:
236 -- Processing continues.
237 --
238 -- Post Failure:
239 -- If an error has occurred, an error message and exception will be raised
240 -- but not handled.
241 --
242 -- Developer Implementation Notes:
243 -- Any post-processing required after the insert dml is issued should be
244 -- coded within this procedure. It is important to note that any 3rd party
245 -- maintenance should be reviewed before placing in this procedure.
246 --
247 -- Access Status:
248 -- Internal Table Handler Use Only.
249 --
250 -- {End Of Comments}
251 -- ----------------------------------------------------------------------------
252 Procedure post_insert(p_rec in per_apl_shd.g_rec_type
253 ,p_effective_date in date) is
254 --
255 l_proc varchar2(72) := g_package||'post_insert';
256 --
257 Begin
258 hr_utility.set_location('Entering:'||l_proc, 5);
259 --
260 -- Start of API User Hook for post_insert.
261 begin
262 per_apl_rki.after_insert
263 (p_application_id => p_rec.application_id
264 ,p_business_group_id => p_rec.business_group_id
265 ,p_person_id => p_rec.person_id
266 ,p_date_received => p_rec.date_received
267 ,p_comments => p_rec.comments
268 ,p_current_employer => p_rec.current_employer
269 ,p_projected_hire_date => p_rec.projected_hire_date
270 ,p_successful_flag => p_rec.successful_flag
271 ,p_termination_reason => p_rec.termination_reason
272 ,p_request_id => p_rec.request_id
273 ,p_program_application_id => p_rec.program_application_id
274 ,p_program_id => p_rec.program_id
275 ,p_program_update_date => p_rec.program_update_date
276 ,p_appl_attribute_category => p_rec.appl_attribute_category
277 ,p_appl_attribute1 => p_rec.appl_attribute1
278 ,p_appl_attribute2 => p_rec.appl_attribute2
279 ,p_appl_attribute3 => p_rec.appl_attribute3
280 ,p_appl_attribute4 => p_rec.appl_attribute4
281 ,p_appl_attribute5 => p_rec.appl_attribute5
282 ,p_appl_attribute6 => p_rec.appl_attribute6
283 ,p_appl_attribute7 => p_rec.appl_attribute7
284 ,p_appl_attribute8 => p_rec.appl_attribute8
285 ,p_appl_attribute9 => p_rec.appl_attribute9
286 ,p_appl_attribute10 => p_rec.appl_attribute10
287 ,p_appl_attribute11 => p_rec.appl_attribute11
288 ,p_appl_attribute12 => p_rec.appl_attribute12
289 ,p_appl_attribute13 => p_rec.appl_attribute13
290 ,p_appl_attribute14 => p_rec.appl_attribute14
291 ,p_appl_attribute15 => p_rec.appl_attribute15
292 ,p_appl_attribute16 => p_rec.appl_attribute16
293 ,p_appl_attribute17 => p_rec.appl_attribute17
294 ,p_appl_attribute18 => p_rec.appl_attribute18
295 ,p_appl_attribute19 => p_rec.appl_attribute19
296 ,p_appl_attribute20 => p_rec.appl_attribute20
297 ,p_object_version_number => p_rec.object_version_number
298 ,p_effective_date => p_effective_date
299 );
300 exception
301 when hr_api.cannot_find_prog_unit then
302 hr_api.cannot_find_prog_unit_error
303 (p_module_name => 'PER_APPLICATIONS'
304 ,p_hook_type => 'AI'
305 );
306 end;
307 -- End of API User Hook for post_insert.
308 --
309 hr_utility.set_location(' Leaving:'||l_proc, 10);
310 End post_insert;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< ins >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure ins
316 (
317 p_rec in out nocopy per_apl_shd.g_rec_type,
318 p_effective_date in date,
319 p_validate in boolean default false,
320 p_validate_df_flex in boolean default true --4689836
321 ) is
322 --
323 l_proc varchar2(72) := g_package||'ins';
324 --
325 Begin
326 hr_utility.set_location('Entering:'||l_proc, 5);
327 --
328 -- Determine if the business process is to be validated.
329 --
330 If p_validate then
331 --
332 -- Issue the savepoint.
333 --
334 SAVEPOINT ins_per_apl;
335 End If;
336 --
337 -- Call the supporting insert validate operations
338 --
339 per_apl_bus.insert_validate(p_rec
340 ,p_effective_date
341 ,false); --risgupta
342 --
343 -- Call to raise any errors on multi-message list
344 --
345 hr_multi_message.end_validation_set;
346 --
347 -- Call the supporting pre-insert operation
348 --
349 pre_insert(p_rec);
350 --
351 -- Insert the row
352 --
353 insert_dml(p_rec);
354 --
355 -- Call the supporting post-insert operation
356 --
357 post_insert(p_rec
358 ,p_effective_date);
359 --
360 -- Call to raise any errors on multi-message list
361 --
362 hr_multi_message.end_validation_set;
363 --
364 -- If we are validating then raise the Validate_Enabled exception
365 --
366 If p_validate then
367 Raise HR_Api.Validate_Enabled;
368 End If;
369 --
370 hr_utility.set_location(' Leaving:'||l_proc, 10);
371 Exception
372 When HR_Api.Validate_Enabled Then
373 --
374 -- As the Validate_Enabled exception has been raised
375 -- we must rollback to the savepoint
376 --
377 ROLLBACK TO ins_per_apl;
378 end ins;
379 --
380 -- ----------------------------------------------------------------------------
381 -- |---------------------------------< ins >----------------------------------|
382 -- ----------------------------------------------------------------------------
383 Procedure ins
384 (
385 p_application_id out nocopy number,
386 p_business_group_id in number,
387 p_person_id in number,
388 p_date_received in date,
389 p_comments in varchar2 default null,
390 p_current_employer in varchar2 default null,
391 p_projected_hire_date in date default null,
392 p_successful_flag in varchar2 default null,
393 p_termination_reason in varchar2 default null,
394 p_request_id in number default null,
395 p_program_application_id in number default null,
396 p_program_id in number default null,
397 p_program_update_date in date default null,
398 p_appl_attribute_category in varchar2 default null,
399 p_appl_attribute1 in varchar2 default null,
400 p_appl_attribute2 in varchar2 default null,
401 p_appl_attribute3 in varchar2 default null,
402 p_appl_attribute4 in varchar2 default null,
403 p_appl_attribute5 in varchar2 default null,
404 p_appl_attribute6 in varchar2 default null,
405 p_appl_attribute7 in varchar2 default null,
406 p_appl_attribute8 in varchar2 default null,
407 p_appl_attribute9 in varchar2 default null,
408 p_appl_attribute10 in varchar2 default null,
409 p_appl_attribute11 in varchar2 default null,
410 p_appl_attribute12 in varchar2 default null,
411 p_appl_attribute13 in varchar2 default null,
412 p_appl_attribute14 in varchar2 default null,
413 p_appl_attribute15 in varchar2 default null,
414 p_appl_attribute16 in varchar2 default null,
415 p_appl_attribute17 in varchar2 default null,
416 p_appl_attribute18 in varchar2 default null,
417 p_appl_attribute19 in varchar2 default null,
418 p_appl_attribute20 in varchar2 default null,
419 p_object_version_number out nocopy number,
420 p_effective_date in date,
421 p_validate in boolean default false,
422 p_validate_df_flex in boolean default true --4689836
423 ) is
424 --
425 l_rec per_apl_shd.g_rec_type;
426 l_proc varchar2(72) := g_package||'ins';
427 --
428 Begin
429 hr_utility.set_location('Entering:'||l_proc, 5);
430 --
431 -- Call conversion function to turn arguments into the
432 -- p_rec structure.
433 --
434 l_rec :=
435 per_apl_shd.convert_args
436 (
437 null,
438 p_business_group_id,
439 p_person_id,
440 p_date_received,
441 p_comments,
442 p_current_employer,
443 null,
444 p_projected_hire_date,
445 p_successful_flag,
446 p_termination_reason,
447 p_request_id,
448 p_program_application_id,
449 p_program_id,
450 p_program_update_date,
451 p_appl_attribute_category,
452 p_appl_attribute1,
453 p_appl_attribute2,
454 p_appl_attribute3,
455 p_appl_attribute4,
456 p_appl_attribute5,
457 p_appl_attribute6,
458 p_appl_attribute7,
459 p_appl_attribute8,
460 p_appl_attribute9,
461 p_appl_attribute10,
462 p_appl_attribute11,
463 p_appl_attribute12,
464 p_appl_attribute13,
465 p_appl_attribute14,
466 p_appl_attribute15,
467 p_appl_attribute16,
468 p_appl_attribute17,
469 p_appl_attribute18,
470 p_appl_attribute19,
471 p_appl_attribute20,
472 null
473 );
474 --
475 -- Having converted the arguments into the per_apl_rec
476 -- plsql record structure we call the corresponding record business process.
477 --
478 ins(l_rec, p_effective_date, p_validate);
479 --
480 -- As the primary key argument(s)
481 -- are specified as an OUT's we must set these values.
482 --
483 p_application_id := l_rec.application_id;
484 p_object_version_number := l_rec.object_version_number;
485 --
486 hr_utility.set_location(' Leaving:'||l_proc, 10);
487 End ins;
488 --
489 end per_apl_ins;