DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_CKL_INS

Source


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