DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PAC_INS

Source


1 Package Body per_pac_ins as
2 /* $Header: pepacrhi.pkb 120.3 2006/10/19 07:29:26 sturlapa noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := '  per_pac_ins.';  -- Global package name
9 g_debug   boolean      := hr_utility.debug_enabled;
10 --
11 -- The following global variables are only to be used by
12 -- the set_base_key_value and pre_insert procedures.
13 --
14 g_allocated_checklist_id_i  number   default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20   (p_allocated_checklist_id  in  number) is
21 --
22   l_proc       varchar2(72) := g_package||'set_base_key_value';
23 --
24 Begin
25   hr_utility.set_location('Entering:'||l_proc, 10);
26   --
27   per_pac_ins.g_allocated_checklist_id_i := p_allocated_checklist_id;
28   --
29   hr_utility.set_location(' Leaving:'||l_proc, 20);
30 End set_base_key_value;
31 --
32 --
33 -- ----------------------------------------------------------------------------
34 -- |------------------------------< insert_dml >------------------------------|
35 -- ----------------------------------------------------------------------------
36 -- {Start Of Comments}
37 --
38 -- Description:
39 --   This procedure controls the actual dml insert logic. The processing of
40 --   this procedure are as follows:
41 --   1) Initialise the object_version_number to 1 if the object_version_number
42 --      is defined as an attribute for this entity.
43 --   2) To set and unset the g_api_dml status as required (as we are about to
44 --      perform dml).
45 --   3) To insert the row into the schema.
46 --   4) To trap any constraint violations that may have occurred.
47 --   5) To raise any other errors.
48 --
49 -- Prerequisites:
50 --   This is an internal private procedure which must be called from the ins
51 --   procedure and must have all mandatory attributes set (except the
52 --   object_version_number which is initialised within this procedure).
53 --
54 -- In Parameters:
55 --   A Pl/Sql record structre.
56 --
57 -- Post Success:
58 --   The specified row will be inserted into the schema.
59 --
60 -- Post Failure:
61 --   On the insert dml failure it is important to note that we always reset the
62 --   g_api_dml status to false.
63 --   If a check, unique or parent integrity constraint violation is raised the
64 --   constraint_error procedure will be called.
65 --   If any other error is reported, the error will be raised after the
66 --   g_api_dml status is reset.
67 --
68 -- Developer Implementation Notes:
69 --   None.
70 --
71 -- Access Status:
72 --   Internal Row Handler Use Only.
73 --
74 -- {End Of Comments}
75 -- ----------------------------------------------------------------------------
76 Procedure insert_dml
77   (p_rec in out nocopy per_pac_shd.g_rec_type
78   ) is
79 --
80   l_proc  varchar2(72) := g_package||'insert_dml';
81 --
82 Begin
83   hr_utility.set_location('Entering:'||l_proc, 5);
84   p_rec.object_version_number := 1;  -- Initialise the object version
85   --
86   --
87   --
88   -- Insert the row into: per_allocated_checklists
89   --
90   insert into per_allocated_checklists
91       (allocated_checklist_id
92       ,checklist_id
93       ,person_id
94       ,assignment_id
95       ,checklist_name
96       ,description
97       ,checklist_category
98       ,object_version_number
99       ,attribute_category
100       ,attribute1
101       ,attribute2
102       ,attribute3
103       ,attribute4
104       ,attribute5
105       ,attribute6
109       ,attribute10
106       ,attribute7
107       ,attribute8
108       ,attribute9
110       ,attribute11
111       ,attribute12
112       ,attribute13
113       ,attribute14
114       ,attribute15
115       ,attribute16
116       ,attribute17
117       ,attribute18
118       ,attribute19
119       ,attribute20
120       ,information_category
121       ,information1
122       ,information2
123       ,information3
124       ,information4
125       ,information5
126       ,information6
127       ,information7
128       ,information8
129       ,information9
130       ,information10
131       ,information11
132       ,information12
133       ,information13
134       ,information14
135       ,information15
136       ,information16
137       ,information17
138       ,information18
139       ,information19
140       ,information20
141       )
142   Values
143     (p_rec.allocated_checklist_id
144     ,p_rec.checklist_id
145     ,p_rec.person_id
146     ,p_rec.assignment_id
147     ,p_rec.checklist_name
148     ,p_rec.description
149     ,p_rec.checklist_category
150     ,p_rec.object_version_number
151     ,p_rec.attribute_category
152     ,p_rec.attribute1
153     ,p_rec.attribute2
154     ,p_rec.attribute3
155     ,p_rec.attribute4
156     ,p_rec.attribute5
157     ,p_rec.attribute6
158     ,p_rec.attribute7
159     ,p_rec.attribute8
160     ,p_rec.attribute9
161     ,p_rec.attribute10
162     ,p_rec.attribute11
163     ,p_rec.attribute12
164     ,p_rec.attribute13
165     ,p_rec.attribute14
166     ,p_rec.attribute15
167     ,p_rec.attribute16
168     ,p_rec.attribute17
169     ,p_rec.attribute18
170     ,p_rec.attribute19
171     ,p_rec.attribute20
172     ,p_rec.information_category
173     ,p_rec.information1
174     ,p_rec.information2
175     ,p_rec.information3
176     ,p_rec.information4
177     ,p_rec.information5
178     ,p_rec.information6
179     ,p_rec.information7
180     ,p_rec.information8
181     ,p_rec.information9
182     ,p_rec.information10
183     ,p_rec.information11
184     ,p_rec.information12
185     ,p_rec.information13
186     ,p_rec.information14
187     ,p_rec.information15
188     ,p_rec.information16
189     ,p_rec.information17
190     ,p_rec.information18
191     ,p_rec.information19
192     ,p_rec.information20
193     );
194   --
195   --
196   --
197   hr_utility.set_location(' Leaving:'||l_proc, 10);
198 Exception
199   When hr_api.check_integrity_violated Then
200     -- A check constraint has been violated
201     --
202     per_pac_shd.constraint_error
203       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
204   When hr_api.parent_integrity_violated Then
205     -- Parent integrity has been violated
206     --
207     per_pac_shd.constraint_error
208       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
209   When hr_api.unique_integrity_violated Then
210     -- Unique integrity has been violated
211     --
212     per_pac_shd.constraint_error
213       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
214   When Others Then
215     --
216     Raise;
217 End insert_dml;
218 --
219 -- ----------------------------------------------------------------------------
220 -- |------------------------------< pre_insert >------------------------------|
221 -- ----------------------------------------------------------------------------
222 -- {Start Of Comments}
223 --
224 -- Description:
225 --   This private procedure contains any processing which is required before
226 --   the insert dml. Presently, if the entity has a corresponding primary
227 --   key which is maintained by an associating sequence, the primary key for
228 --   the entity will be populated with the next sequence value in
229 --   preparation for the insert dml.
230 --
231 -- Prerequisites:
232 --   This is an internal procedure which is called from the ins procedure.
233 --
234 -- In Parameters:
235 --   A Pl/Sql record structure.
236 --
237 -- Post Success:
238 --   Processing continues.
239 --
240 -- Post Failure:
241 --   If an error has occurred, an error message and exception will be raised
242 --   but not handled.
243 --
244 -- Developer Implementation Notes:
245 --   Any pre-processing required before the insert dml is issued should be
246 --   coded within this procedure. As stated above, a good example is the
247 --   generation of a primary key number via a corresponding sequence.
248 --   It is important to note that any 3rd party maintenance should be reviewed
249 --   before placing in this procedure.
250 --
251 -- Access Status:
252 --   Internal Row Handler Use Only.
253 --
254 -- {End Of Comments}
255 -- ----------------------------------------------------------------------------
256 Procedure pre_insert
257   (p_rec  in out nocopy per_pac_shd.g_rec_type
258   ) is
259 --
260   Cursor C_Sel1 is select per_allocated_checklists_s.nextval from sys.dual;
261 --
262   Cursor C_Sel2 is
263     Select null
264       from per_allocated_checklists
265      where allocated_checklist_id =
266              per_pac_ins.g_allocated_checklist_id_i;
267 --
268   l_proc   varchar2(72) := g_package||'pre_insert';
272   hr_utility.set_location('Entering:'||l_proc, 5);
269   l_exists varchar2(1);
270 --
271 Begin
273   --
274   If (per_pac_ins.g_allocated_checklist_id_i is not null) Then
275     --
276     -- Verify registered primary key values not already in use
277     --
278     Open C_Sel2;
279     Fetch C_Sel2 into l_exists;
280     If C_Sel2%found Then
281        Close C_Sel2;
282        --
283        -- The primary key values are already in use.
284        --
285        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
286        fnd_message.set_token('TABLE_NAME','per_allocated_checklists');
287        fnd_message.raise_error;
288     End If;
289     Close C_Sel2;
290     --
291     -- Use registered key values and clear globals
292     --
293     p_rec.allocated_checklist_id :=
294       per_pac_ins.g_allocated_checklist_id_i;
295     per_pac_ins.g_allocated_checklist_id_i := null;
296   Else
297     --
298     -- No registerd key values, so select the next sequence number
299     --
300     --
301     -- Select the next sequence number
302     --
303     Open C_Sel1;
304     Fetch C_Sel1 Into p_rec.allocated_checklist_id;
305     Close C_Sel1;
306   End If;
307   --
308   hr_utility.set_location(' Leaving:'||l_proc, 10);
309 End pre_insert;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |-----------------------------< post_insert >------------------------------|
313 -- ----------------------------------------------------------------------------
314 -- {Start Of Comments}
315 --
316 -- Description:
317 --   This private procedure contains any processing which is required after
318 --   the insert dml.
319 --
320 -- Prerequisites:
321 --   This is an internal procedure which is called from the ins procedure.
322 --
323 -- In Parameters:
324 --   A Pl/Sql record structre.
325 --
326 -- Post Success:
327 --   Processing continues.
328 --
329 -- Post Failure:
330 --   If an error has occurred, an error message and exception will be raised
331 --   but not handled.
332 --
333 -- Developer Implementation Notes:
334 --   Any post-processing required after the insert dml is issued should be
335 --   coded within this procedure. It is important to note that any 3rd party
336 --   maintenance should be reviewed before placing in this procedure.
337 --
338 -- Access Status:
339 --   Internal Row Handler Use Only.
340 --
341 -- {End Of Comments}
342 -- ----------------------------------------------------------------------------
343 Procedure post_insert
344   (p_effective_date               in date
345   ,p_rec                          in per_pac_shd.g_rec_type
346   ) is
347 --
348   l_proc  varchar2(72) := g_package||'post_insert';
349 --
350 Begin
351   hr_utility.set_location('Entering:'||l_proc, 5);
352   begin
353     --
354     per_pac_rki.after_insert
355       (p_effective_date              => p_effective_date
356       ,p_allocated_checklist_id
357       => p_rec.allocated_checklist_id
358       ,p_checklist_id
359       => p_rec.checklist_id
360       ,p_person_id
361       => p_rec.person_id
362       ,p_assignment_id
363       => p_rec.assignment_id
364       ,p_checklist_name
365       => p_rec.checklist_name
366       ,p_description
367       => p_rec.description
368       ,p_checklist_category
369       => p_rec.checklist_category
370       ,p_object_version_number
371       => p_rec.object_version_number
372       ,p_attribute_category
376       ,p_attribute2
373       => p_rec.attribute_category
374       ,p_attribute1
375       => p_rec.attribute1
377       => p_rec.attribute2
378       ,p_attribute3
379       => p_rec.attribute3
380       ,p_attribute4
381       => p_rec.attribute4
382       ,p_attribute5
383       => p_rec.attribute5
384       ,p_attribute6
385       => p_rec.attribute6
386       ,p_attribute7
387       => p_rec.attribute7
388       ,p_attribute8
389       => p_rec.attribute8
390       ,p_attribute9
391       => p_rec.attribute9
392       ,p_attribute10
393       => p_rec.attribute10
394       ,p_attribute11
395       => p_rec.attribute11
396       ,p_attribute12
397       => p_rec.attribute12
398       ,p_attribute13
402       ,p_attribute15
399       => p_rec.attribute13
400       ,p_attribute14
401       => p_rec.attribute14
403       => p_rec.attribute15
404       ,p_attribute16
405       => p_rec.attribute16
406       ,p_attribute17
407       => p_rec.attribute17
408       ,p_attribute18
409       => p_rec.attribute18
410       ,p_attribute19
411       => p_rec.attribute19
412       ,p_attribute20
413       => p_rec.attribute20
414       ,p_information_category
415       => p_rec.information_category
416       ,p_information1
417       => p_rec.information1
418       ,p_information2
419       => p_rec.information2
420       ,p_information3
421       => p_rec.information3
422       ,p_information4
423       => p_rec.information4
424       ,p_information5
425       => p_rec.information5
426       ,p_information6
427       => p_rec.information6
428       ,p_information7
429       => p_rec.information7
430       ,p_information8
431       => p_rec.information8
432       ,p_information9
433       => p_rec.information9
434       ,p_information10
435       => p_rec.information10
436       ,p_information11
437       => p_rec.information11
438       ,p_information12
439       => p_rec.information12
440       ,p_information13
441       => p_rec.information13
442       ,p_information14
443       => p_rec.information14
444       ,p_information15
445       => p_rec.information15
446       ,p_information16
447       => p_rec.information16
448       ,p_information17
449       => p_rec.information17
450       ,p_information18
451       => p_rec.information18
452       ,p_information19
453       => p_rec.information19
454       ,p_information20
455       => p_rec.information20
456       );
457     --
458   exception
459     --
460     when hr_api.cannot_find_prog_unit then
461       --
462       hr_api.cannot_find_prog_unit_error
463         (p_module_name => 'PER_ALLOCATED_CHECKLISTS'
464         ,p_hook_type   => 'AI');
465       --
466   end;
467   --
468   hr_utility.set_location(' Leaving:'||l_proc, 10);
469 End post_insert;
470 --
471 -- ----------------------------------------------------------------------------
472 -- |---------------------------------< ins >----------------------------------|
473 -- ----------------------------------------------------------------------------
474 Procedure ins
475   (p_effective_date               in date
476   ,p_rec                          in out nocopy per_pac_shd.g_rec_type
477   ) is
478 --
479   l_proc  varchar2(72) := g_package||'ins';
480 --
481 Begin
482   hr_utility.set_location('Entering:'||l_proc, 5);
483   --
484   -- Call the supporting insert validate operations
485   --
486   per_pac_bus.insert_validate
487      (p_effective_date
488      ,p_rec
489      );
490   --
491   -- Call to raise any errors on multi-message list
492   hr_multi_message.end_validation_set;
493   --
494   -- Call the supporting pre-insert operation
495   --
496   per_pac_ins.pre_insert(p_rec);
497   --
498   -- Insert the row
499   --
500   per_pac_ins.insert_dml(p_rec);
501   --
502   -- Call the supporting post-insert operation
503   --
504   per_pac_ins.post_insert
505      (p_effective_date
506      ,p_rec
507      );
508   --
509   -- Call to raise any errors on multi-message list
510   hr_multi_message.end_validation_set;
511   --
512   hr_utility.set_location('Leaving:'||l_proc, 20);
513 end ins;
514 --
515 -- ----------------------------------------------------------------------------
516 -- |---------------------------------< ins >----------------------------------|
517 -- ----------------------------------------------------------------------------
518 Procedure ins
519   (p_effective_date               in     date
520   ,p_checklist_id                   in     number   default null
521   ,p_person_id                      in     number
522   ,p_assignment_id                  in     number   default null
523   ,p_checklist_name                 in     varchar2 default null
524   ,p_description                    in     varchar2 default null
525   ,p_checklist_category             in     varchar2 default null
526   ,p_attribute_category             in     varchar2 default null
527   ,p_attribute1                     in     varchar2 default null
528   ,p_attribute2                     in     varchar2 default null
529   ,p_attribute3                     in     varchar2 default null
530   ,p_attribute4                     in     varchar2 default null
531   ,p_attribute5                     in     varchar2 default null
532   ,p_attribute6                     in     varchar2 default null
533   ,p_attribute7                     in     varchar2 default null
534   ,p_attribute8                     in     varchar2 default null
535   ,p_attribute9                     in     varchar2 default null
536   ,p_attribute10                    in     varchar2 default null
537   ,p_attribute11                    in     varchar2 default null
538   ,p_attribute12                    in     varchar2 default null
539   ,p_attribute13                    in     varchar2 default null
540   ,p_attribute14                    in     varchar2 default null
541   ,p_attribute15                    in     varchar2 default null
545   ,p_attribute19                    in     varchar2 default null
542   ,p_attribute16                    in     varchar2 default null
543   ,p_attribute17                    in     varchar2 default null
544   ,p_attribute18                    in     varchar2 default null
546   ,p_attribute20                    in     varchar2 default null
547   ,p_information_category           in     varchar2 default null
548   ,p_information1                   in     varchar2 default null
549   ,p_information2                   in     varchar2 default null
550   ,p_information3                   in     varchar2 default null
551   ,p_information4                   in     varchar2 default null
552   ,p_information5                   in     varchar2 default null
553   ,p_information6                   in     varchar2 default null
554   ,p_information7                   in     varchar2 default null
555   ,p_information8                   in     varchar2 default null
556   ,p_information9                   in     varchar2 default null
557   ,p_information10                  in     varchar2 default null
558   ,p_information11                  in     varchar2 default null
559   ,p_information12                  in     varchar2 default null
560   ,p_information13                  in     varchar2 default null
561   ,p_information14                  in     varchar2 default null
562   ,p_information15                  in     varchar2 default null
563   ,p_information16                  in     varchar2 default null
564   ,p_information17                  in     varchar2 default null
565   ,p_information18                  in     varchar2 default null
566   ,p_information19                  in     varchar2 default null
567   ,p_information20                  in     varchar2 default null
568   ,p_allocated_checklist_id            out nocopy number
569   ,p_object_version_number             out nocopy number
570   ) is
571 --
572   l_rec   per_pac_shd.g_rec_type;
573   l_proc  varchar2(72) := g_package||'ins';
574 --
575 Begin
576   hr_utility.set_location('Entering:'||l_proc, 5);
577   --
578   -- Call conversion function to turn arguments into the
579   -- p_rec structure.
580   --
581   l_rec :=
582   per_pac_shd.convert_args
583     (null
584     ,p_checklist_id
585     ,p_person_id
586     ,p_assignment_id
587     ,p_checklist_name
588     ,p_description
589     ,p_checklist_category
590     ,null
591     ,p_attribute_category
592     ,p_attribute1
593     ,p_attribute2
594     ,p_attribute3
598     ,p_attribute7
595     ,p_attribute4
596     ,p_attribute5
597     ,p_attribute6
599     ,p_attribute8
600     ,p_attribute9
601     ,p_attribute10
602     ,p_attribute11
603     ,p_attribute12
604     ,p_attribute13
605     ,p_attribute14
606     ,p_attribute15
607     ,p_attribute16
608     ,p_attribute17
609     ,p_attribute18
610     ,p_attribute19
611     ,p_attribute20
612     ,p_information_category
613     ,p_information1
614     ,p_information2
615     ,p_information3
616     ,p_information4
617     ,p_information5
618     ,p_information6
619     ,p_information7
620     ,p_information8
621     ,p_information9
622     ,p_information10
623     ,p_information11
624     ,p_information12
625     ,p_information13
626     ,p_information14
627     ,p_information15
628     ,p_information16
629     ,p_information17
630     ,p_information18
631     ,p_information19
632     ,p_information20
633     );
634   --
635   -- Having converted the arguments into the per_pac_rec
636   -- plsql record structure we call the corresponding record business process.
637   --
638   per_pac_ins.ins
639      (p_effective_date
640      ,l_rec
641      );
642   --
643   -- As the primary key argument(s)
644   -- are specified as an OUT's we must set these values.
645   --
646   p_allocated_checklist_id := l_rec.allocated_checklist_id;
647   p_object_version_number := l_rec.object_version_number;
648   --
649   hr_utility.set_location(' Leaving:'||l_proc, 10);
650 End ins;
651 --
652 end per_pac_ins;