DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PAT_INS

Source


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