[Home] [Help]
PACKAGE BODY: APPS.PER_ASN_INS
Source
1 Package Body per_asn_ins as
2 /* $Header: peasnrhi.pkb 115.11 2003/09/01 08:19:06 bdivvela ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_asn_ins.'; -- Global package name
9 --
10 g_assessment_id_i number default null;
11 --
12 --
13 -- ----------------------------------------------------------------------------
14 -- |------------------------< set_base_key_value >----------------------------|
15 -- ----------------------------------------------------------------------------
16 procedure set_base_key_value
17 (p_assessment_id in number) is
18 --
19 l_proc varchar2(72) := g_package||'set_base_key_value';
20 --
21 Begin
22 hr_utility.set_location('Entering:'||l_proc, 10);
23 --
24 per_asn_ins.g_assessment_id_i := p_assessment_id;
25 --
26 hr_utility.set_location(' Leaving:'||l_proc, 20);
27 End set_base_key_value;
28 --
29 --
30
31 -- ----------------------------------------------------------------------------
32 -- |------------------------------< insert_dml >------------------------------|
33 -- ----------------------------------------------------------------------------
34 -- {Start Of Comments}
35 --
36 -- Description:
37 -- This procedure controls the actual dml insert logic. The processing of
38 -- this procedure are as follows:
39 -- 1) Initialise the object_version_number to 1 if the object_version_number
40 -- is defined as an attribute for this entity.
41 -- 2) To insert the row into the schema.
42 -- 3) To trap any constraint violations that may have occurred.
43 -- 4) To raise any other errors.
44 --
45 -- Pre Conditions:
46 -- This is an internal private procedure which must be called from the ins
47 -- procedure and must have all mandatory attributes set (except the
48 -- object_version_number which is initialised within this procedure).
49 --
50 -- In Parameters:
51 -- A Pl/Sql record structre.
52 --
53 -- Post Success:
54 -- The specified row will be inserted into the schema.
55 --
56 -- Post Failure:
57 -- If a check, unique or parent integrity constraint violation is raised the
58 -- constraint_error procedure will be called.
59 -- If any other error is reported, the error will be raised.
60 --
61 -- Developer Implementation Notes:
62 -- None.
63 --
64 -- Access Status:
65 -- Internal Table Handler Use Only.
66 --
67 -- {End Of Comments}
68 -- ----------------------------------------------------------------------------
69 Procedure insert_dml(p_rec in out nocopy per_asn_shd.g_rec_type) is
70 --
71 l_proc varchar2(72) := g_package||'insert_dml';
72 --
73 Begin
74 hr_utility.set_location('Entering:'||l_proc, 5);
75 p_rec.object_version_number := 1; -- Initialise the object version
76 --
77 -- Insert the row into: per_assessments
78 --
79 insert into per_assessments
80 ( assessment_id,
81 assessment_type_id,
82 business_group_id,
83 person_id,
84 assessment_group_id,
85 assessment_period_start_date,
86 assessment_period_end_date,
87 assessment_date,
88 assessor_person_id,
89 appraisal_id,
90 group_date,
91 group_initiator_id,
92 comments,
93 total_score,
94 status,
95 attribute_category,
96 attribute1,
97 attribute2,
98 attribute3,
99 attribute4,
100 attribute5,
101 attribute6,
102 attribute7,
103 attribute8,
104 attribute9,
105 attribute10,
106 attribute11,
107 attribute12,
108 attribute13,
109 attribute14,
110 attribute15,
111 attribute16,
112 attribute17,
113 attribute18,
114 attribute19,
115 attribute20,
116 object_version_number
117 )
118 Values
119 ( p_rec.assessment_id,
120 p_rec.assessment_type_id,
121 p_rec.business_group_id,
122 p_rec.person_id,
123 p_rec.assessment_group_id,
124 p_rec.assessment_period_start_date,
125 p_rec.assessment_period_end_date,
126 p_rec.assessment_date,
127 p_rec.assessor_person_id,
128 p_rec.appraisal_id,
129 p_rec.group_date,
130 p_rec.group_initiator_id,
131 p_rec.comments,
132 p_rec.total_score,
133 p_rec.status,
134 p_rec.attribute_category,
135 p_rec.attribute1,
136 p_rec.attribute2,
137 p_rec.attribute3,
138 p_rec.attribute4,
139 p_rec.attribute5,
140 p_rec.attribute6,
141 p_rec.attribute7,
142 p_rec.attribute8,
143 p_rec.attribute9,
144 p_rec.attribute10,
145 p_rec.attribute11,
146 p_rec.attribute12,
147 p_rec.attribute13,
148 p_rec.attribute14,
149 p_rec.attribute15,
150 p_rec.attribute16,
151 p_rec.attribute17,
152 p_rec.attribute18,
153 p_rec.attribute19,
154 p_rec.attribute20,
155 p_rec.object_version_number
156 );
157 --
158 hr_utility.set_location(' Leaving:'||l_proc, 10);
159 Exception
160 When hr_api.check_integrity_violated Then
161 -- A check constraint has been violated
162 per_asn_shd.constraint_error
163 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
164 When hr_api.parent_integrity_violated Then
165 -- Parent integrity has been violated
166 per_asn_shd.constraint_error
167 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
168 When hr_api.unique_integrity_violated Then
169 -- Unique integrity has been violated
170 per_asn_shd.constraint_error
171 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
172 When Others Then
173 Raise;
174 End insert_dml;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |------------------------------< pre_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 -- This private procedure contains any processing which is required before
183 -- the insert dml. Presently, if the entity has a corresponding primary
184 -- key which is maintained by an associating sequence, the primary key for
185 -- the entity will be populated with the next sequence value in
186 -- preparation for the insert dml.
187 --
188 -- Pre Conditions:
189 -- This is an internal procedure which is called from the ins procedure.
190 --
191 -- In Parameters:
192 -- A Pl/Sql record structre.
193 --
194 -- Post Success:
195 -- Processing continues.
196 --
197 -- Post Failure:
201 -- Developer Implementation Notes:
198 -- If an error has occurred, an error message and exception will be raised
199 -- but not handled.
200 --
202 -- Any pre-processing required before the insert dml is issued should be
203 -- coded within this procedure. As stated above, a good example is the
204 -- generation of a primary key number via a corresponding sequence.
205 -- It is important to note that any 3rd party maintenance should be reviewed
206 -- before placing in this procedure.
207 --
208 -- Access Status:
209 -- Internal Table Handler Use Only.
210 --
211 -- {End Of Comments}
212 -- ----------------------------------------------------------------------------
213 Procedure pre_insert(p_rec in out nocopy per_asn_shd.g_rec_type) is
214 --
215 l_proc varchar2(72) := g_package||'pre_insert';
216 l_exists varchar2(1);
217 --
218 Cursor C_Sel1 is select per_assessments_s.nextval from sys.dual;
219 --
220 --
221 Cursor C_Sel2 is
222 Select null
223 from per_assessments
224 where assessment_id =
225 per_asn_ins.g_assessment_id_i;
226 --
227
228 Begin
229 hr_utility.set_location('Entering:'||l_proc, 5);
230 --
231 --
232 -- Select the next sequence number
233 --
234 -- Select the next sequence number
235 If (per_asn_ins.g_assessment_id_i is not null)
236 then
237 --
238 -- Verify registered primary key values not already in use
239 --
240 Open C_Sel2;
241 Fetch C_Sel2 into l_exists;
242 If C_Sel2%found Then
243 Close C_Sel2;
244 --
245 -- The primary key values are already in use.
246 --
247 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
248 fnd_message.set_token('TABLE_NAME','PER_ASSESSMENTS');
249 fnd_message.raise_error;
250 End If;
251 Close C_Sel2;
252 --
253 -- Use registered key values and clear globals
254 --
255 p_rec.assessment_id := per_asn_ins.g_assessment_id_i;
256 per_asn_ins.g_assessment_id_i := null;
257 Else
258
259 Open C_Sel1;
260 Fetch C_Sel1 Into p_rec.assessment_id;
261 Close C_Sel1;
262
263 End if;
264 --
265
266
267
268 hr_utility.set_location(' Leaving:'||l_proc, 10);
269 End pre_insert;
270 --
271 -- ----------------------------------------------------------------------------
272 -- |-----------------------------< post_insert >------------------------------|
273 -- ----------------------------------------------------------------------------
274 -- {Start Of Comments}
275 --
276 -- Description:
277 -- This private procedure contains any processing which is required after the
278 -- insert dml.
279 --
280 -- Pre Conditions:
281 -- This is an internal procedure which is called from the ins procedure.
282 --
283 -- In Parameters:
284 -- A Pl/Sql record structre.
285 --
286 -- Post Success:
287 -- Processing continues.
288 --
289 -- Post Failure:
290 -- If an error has occurred, an error message and exception will be raised
291 -- but not handled.
292 --
293 -- Developer Implementation Notes:
294 -- Any post-processing required after the insert dml is issued should be
295 -- coded within this procedure. It is important to note that any 3rd party
296 -- maintenance should be reviewed before placing in this procedure.
297 --
298 -- Access Status:
299 -- Internal Table Handler Use Only.
300 --
301 -- {End Of Comments}
302 -- ----------------------------------------------------------------------------
303 Procedure post_insert(p_rec in per_asn_shd.g_rec_type) is
304 --
305 l_proc varchar2(72) := g_package||'post_insert';
306 --
307 Begin
308 hr_utility.set_location('Entering:'||l_proc, 5);
309 --
310 -- This is a hook point and the user hook for post_insert is called here.
311 --
312 begin
313 per_asn_rki.after_insert (
314 p_assessment_id => p_rec.assessment_id ,
315 p_business_group_id => p_rec.business_group_id ,
316 p_object_version_number => p_rec.object_version_number ,
317 p_person_id => p_rec.person_id ,
318 p_assessment_type_id => p_rec.assessment_type_id ,
319 p_group_date => p_rec.group_date ,
320 p_group_initiator_id => p_rec.group_initiator_id ,
321 p_assessor_person_id => p_rec.assessor_person_id ,
322 p_assessment_group_id => p_rec.assessment_group_id ,
323 p_assessment_date => p_rec.assessment_date ,
324 p_status => p_rec.status ,
325 p_assessment_period_start_date => p_rec.assessment_period_start_date ,
326 p_assessment_period_end_date => p_rec.assessment_period_end_date ,
327 p_comments => p_rec.comments ,
328 p_total_score => p_rec.total_score ,
329 p_appraisal_id => p_rec.appraisal_id ,
330 p_attribute_category => p_rec.attribute_category ,
331 p_attribute1 => p_rec.attribute1 ,
332 p_attribute2 => p_rec.attribute2 ,
333 p_attribute3 => p_rec.attribute3 ,
334 p_attribute4 => p_rec.attribute4 ,
335 p_attribute5 => p_rec.attribute5 ,
336 p_attribute6 => p_rec.attribute6 ,
337 p_attribute7 => p_rec.attribute7 ,
338 p_attribute8 => p_rec.attribute8 ,
339 p_attribute9 => p_rec.attribute9 ,
340 p_attribute10 => p_rec.attribute10 ,
341 p_attribute11 => p_rec.attribute11 ,
342 p_attribute12 => p_rec.attribute12 ,
343 p_attribute13 => p_rec.attribute13 ,
344 p_attribute14 => p_rec.attribute14 ,
345 p_attribute15 => p_rec.attribute15 ,
346 p_attribute16 => p_rec.attribute16 ,
347 p_attribute17 => p_rec.attribute17 ,
348 p_attribute18 => p_rec.attribute18 ,
349 p_attribute19 => p_rec.attribute19 ,
350 p_attribute20 => p_rec.attribute20 );
351 exception
352 when hr_api.cannot_find_prog_unit then
353 hr_api.cannot_find_prog_unit_error
354 ( p_module_name => 'PER_ASSESSMENTS'
355 ,p_hook_type => 'AI'
356 );
357 end;
358 -- End of API User Hook for post_insert.
359 --
360 hr_utility.set_location(' Leaving:'||l_proc, 10);
361 End post_insert;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |---------------------------------< ins >----------------------------------|
365 -- ----------------------------------------------------------------------------
366 Procedure ins
367 (
368 p_rec in out nocopy per_asn_shd.g_rec_type
369 ,p_validate in boolean default false
370 ,p_effective_date in date
371 ) is
372 --
373 l_proc varchar2(72) := g_package||'ins';
374 --
375 Begin
376 hr_utility.set_location('Entering:'||l_proc, 5);
377 --
378 -- Determine if the business process is to be validated.
379 --
380 If p_validate then
381 --
382 -- Issue the savepoint.
383 --
384 SAVEPOINT ins_per_asn;
385 End If;
386 --
387 -- Call the supporting insert validate operations
388 --
389 per_asn_bus.insert_validate(p_rec
390 ,p_effective_date);
391
392 --
393 hr_multi_message.end_validation_set;
394 --
395
396 --
397 -- Call the supporting pre-insert operation
398 --
399 pre_insert(p_rec);
400 --
401 -- Insert the row
402 --
403 insert_dml(p_rec);
404 --
405 -- Call the supporting post-insert operation
406 --
407 post_insert(p_rec);
408 --
409
410 --
411 hr_multi_message.end_validation_set;
412 --
413
414 -- If we are validating then raise the Validate_Enabled exception
415 --
416 --
417 If p_validate then
418 Raise HR_Api.Validate_Enabled;
419 End If;
420 --
421 hr_utility.set_location(' Leaving:'||l_proc, 10);
422 Exception
423 When HR_Api.Validate_Enabled Then
424 --
425 -- As the Validate_Enabled exception has been raised
426 -- we must rollback to the savepoint
427 --
428 ROLLBACK TO ins_per_asn;
429 end ins;
430 --
431 -- ----------------------------------------------------------------------------
432 -- |---------------------------------< ins >----------------------------------|
433 -- ----------------------------------------------------------------------------
434 Procedure ins
435 (
436 p_assessment_id out nocopy number,
437 p_assessment_type_id in number,
438 p_business_group_id in number,
439 p_person_id in number,
440 p_assessment_group_id in number default null,
441 p_assessment_period_start_date in date default null,
442 p_assessment_period_end_date in date default null,
443 p_assessment_date in date,
444 p_assessor_person_id in number,
445 p_appraisal_id in number default null,
446 p_group_date in date default null,
447 p_group_initiator_id in number default null,
448 p_comments in varchar2 default null,
449 p_total_score in number default null,
450 p_status in varchar2 default null,
451 p_attribute_category in varchar2 default null,
452 p_attribute1 in varchar2 default null,
453 p_attribute2 in varchar2 default null,
454 p_attribute3 in varchar2 default null,
455 p_attribute4 in varchar2 default null,
456 p_attribute5 in varchar2 default null,
457 p_attribute6 in varchar2 default null,
458 p_attribute7 in varchar2 default null,
459 p_attribute8 in varchar2 default null,
460 p_attribute9 in varchar2 default null,
461 p_attribute10 in varchar2 default null,
462 p_attribute11 in varchar2 default null,
463 p_attribute12 in varchar2 default null,
464 p_attribute13 in varchar2 default null,
465 p_attribute14 in varchar2 default null,
466 p_attribute15 in varchar2 default null,
467 p_attribute16 in varchar2 default null,
468 p_attribute17 in varchar2 default null,
469 p_attribute18 in varchar2 default null,
470 p_attribute19 in varchar2 default null,
471 p_attribute20 in varchar2 default null,
472 p_object_version_number out nocopy number,
473 p_validate in boolean default false,
474 p_effective_date in date
475 ) is
476 --
477 l_rec per_asn_shd.g_rec_type;
478 l_proc varchar2(72) := g_package||'ins';
479 --
480 Begin
481 hr_utility.set_location('Entering:'||l_proc, 5);
482 --
483 -- Call conversion function to turn arguments into the
484 -- p_rec structure.
485 --
486 l_rec :=
487 per_asn_shd.convert_args
488 (
489 null,
490 p_assessment_type_id,
491 p_business_group_id,
492 p_person_id,
493 p_assessment_group_id,
494 p_assessment_period_start_date,
495 p_assessment_period_end_date,
496 p_assessment_date,
497 p_assessor_person_id,
498 p_appraisal_id,
499 p_group_date,
500 p_group_initiator_id,
501 p_comments,
502 p_total_score,
503 p_status,
504 p_attribute_category,
505 p_attribute1,
506 p_attribute2,
507 p_attribute3,
508 p_attribute4,
509 p_attribute5,
510 p_attribute6,
511 p_attribute7,
512 p_attribute8,
513 p_attribute9,
514 p_attribute10,
515 p_attribute11,
516 p_attribute12,
517 p_attribute13,
518 p_attribute14,
519 p_attribute15,
520 p_attribute16,
521 p_attribute17,
522 p_attribute18,
523 p_attribute19,
524 p_attribute20,
525 null
526 );
527 --
528 -- Having converted the arguments into the per_asn_rec
529 -- plsql record structure we call the corresponding record business process.
530 --
531 ins(l_rec
532 ,p_validate
533 ,p_effective_date);
534 --
535 -- As the primary key argument(s)
536 -- are specified as an OUT's we must set these values.
537 --
538 p_assessment_id := l_rec.assessment_id;
539 p_object_version_number := l_rec.object_version_number;
540 --
541 hr_utility.set_location(' Leaving:'||l_proc, 10);
542 End ins;
543 --
544 end per_asn_ins;