DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PMA_INS

Source


1 Package Body per_pma_ins as
2 /* $Header: pepmarhi.pkb 120.4.12010000.3 2009/10/23 13:48:57 schowdhu ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_pma_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_appraisal_period_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_appraisal_period_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_pma_ins.g_appraisal_period_id_i := p_appraisal_period_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_pma_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_appraisal_periods
88   --
89   insert into per_appraisal_periods
90       (appraisal_period_id
91       ,object_version_number
92       ,plan_id
93       ,appraisal_template_id
94       ,start_date
95       ,end_date
96       ,task_start_date
97       ,task_end_date
98       ,initiator_code
99       ,appraisal_system_type
100       ,appraisal_type
101       ,appraisal_assmt_status
102       ,auto_conc_process
103       ,days_before_task_st_dt
104       ,participation_type
105       ,questionnaire_template_id
106       ,attribute_category
107       ,attribute1
108       ,attribute2
109       ,attribute3
110       ,attribute4
111       ,attribute5
112       ,attribute6
113       ,attribute7
114       ,attribute8
115       ,attribute9
116       ,attribute10
117       ,attribute11
118       ,attribute12
119       ,attribute13
120       ,attribute14
121       ,attribute15
122       ,attribute16
123       ,attribute17
124       ,attribute18
125       ,attribute19
126       ,attribute20
127       ,attribute21
128       ,attribute22
129       ,attribute23
130       ,attribute24
131       ,attribute25
132       ,attribute26
133       ,attribute27
134       ,attribute28
135       ,attribute29
136       ,attribute30
137       )
138   Values
139     (p_rec.appraisal_period_id
140     ,p_rec.object_version_number
141     ,p_rec.plan_id
142     ,p_rec.appraisal_template_id
143     ,p_rec.start_date
144     ,p_rec.end_date
145     ,p_rec.task_start_date
146     ,p_rec.task_end_date
147     ,p_rec.initiator_code
148     ,p_rec.appraisal_system_type
149     ,p_rec.appraisal_type
150     ,p_rec.appraisal_assmt_status
151     ,p_rec.auto_conc_process
152     ,p_rec.days_before_task_st_dt
153     ,p_rec.participation_type
154     ,p_rec.questionnaire_template_id
155     ,p_rec.attribute_category
156     ,p_rec.attribute1
157     ,p_rec.attribute2
158     ,p_rec.attribute3
159     ,p_rec.attribute4
160     ,p_rec.attribute5
161     ,p_rec.attribute6
162     ,p_rec.attribute7
163     ,p_rec.attribute8
164     ,p_rec.attribute9
165     ,p_rec.attribute10
166     ,p_rec.attribute11
167     ,p_rec.attribute12
168     ,p_rec.attribute13
169     ,p_rec.attribute14
170     ,p_rec.attribute15
171     ,p_rec.attribute16
172     ,p_rec.attribute17
173     ,p_rec.attribute18
174     ,p_rec.attribute19
175     ,p_rec.attribute20
176     ,p_rec.attribute21
177     ,p_rec.attribute22
178     ,p_rec.attribute23
179     ,p_rec.attribute24
180     ,p_rec.attribute25
181     ,p_rec.attribute26
182     ,p_rec.attribute27
183     ,p_rec.attribute28
184     ,p_rec.attribute29
185     ,p_rec.attribute30
186     );
187   --
188   --
189   --
190   hr_utility.set_location(' Leaving:'||l_proc, 10);
191 Exception
192   When hr_api.check_integrity_violated Then
193     -- A check constraint has been violated
194     --
195     per_pma_shd.constraint_error
196       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
197   When hr_api.parent_integrity_violated Then
198     -- Parent integrity has been violated
199     --
200     per_pma_shd.constraint_error
201       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
202   When hr_api.unique_integrity_violated Then
203     -- Unique integrity has been violated
204     --
205     per_pma_shd.constraint_error
206       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
207   When Others Then
208     --
209     Raise;
210 End insert_dml;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |------------------------------< pre_insert >------------------------------|
214 -- ----------------------------------------------------------------------------
215 -- {Start Of Comments}
216 --
217 -- Description:
218 --   This private procedure contains any processing which is required before
219 --   the insert dml. Presently, if the entity has a corresponding primary
220 --   key which is maintained by an associating sequence, the primary key for
221 --   the entity will be populated with the next sequence value in
222 --   preparation for the insert dml.
223 --
224 -- Prerequisites:
225 --   This is an internal procedure which is called from the ins procedure.
226 --
227 -- In Parameters:
228 --   A Pl/Sql record structure.
229 --
230 -- Post Success:
231 --   Processing continues.
232 --
233 -- Post Failure:
234 --   If an error has occurred, an error message and exception will be raised
235 --   but not handled.
236 --
237 -- Developer Implementation Notes:
238 --   Any pre-processing required before the insert dml is issued should be
239 --   coded within this procedure. As stated above, a good example is the
240 --   generation of a primary key number via a corresponding sequence.
241 --   It is important to note that any 3rd party maintenance should be reviewed
242 --   before placing in this procedure.
243 --
244 -- Access Status:
245 --   Internal Row Handler Use Only.
246 --
247 -- {End Of Comments}
248 -- ----------------------------------------------------------------------------
249 Procedure pre_insert
250   (p_rec  in out nocopy per_pma_shd.g_rec_type
251   ) is
252 --
253   Cursor C_Sel1 is select per_appraisal_periods_s.nextval from sys.dual;
254 --
255   Cursor C_Sel2 is
256     Select null
257       from per_appraisal_periods
258      where appraisal_period_id =
259              per_pma_ins.g_appraisal_period_id_i;
260 --
261   l_proc   varchar2(72) := g_package||'pre_insert';
262   l_exists varchar2(1);
263 --
264 Begin
265   hr_utility.set_location('Entering:'||l_proc, 5);
266   --
267   If (per_pma_ins.g_appraisal_period_id_i is not null) Then
268     --
269     -- Verify registered primary key values not already in use
270     --
271     Open C_Sel2;
272     Fetch C_Sel2 into l_exists;
273     If C_Sel2%found Then
274        Close C_Sel2;
275        --
276        -- The primary key values are already in use.
277        --
278        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
279        fnd_message.set_token('TABLE_NAME','per_appraisal_periods');
280        fnd_message.raise_error;
281     End If;
282     Close C_Sel2;
283     --
284     -- Use registered key values and clear globals
285     --
286     p_rec.appraisal_period_id :=
287       per_pma_ins.g_appraisal_period_id_i;
288     per_pma_ins.g_appraisal_period_id_i := null;
289   Else
290     --
291     -- No registerd key values, so select the next sequence number
292     --
293     --
294     -- Select the next sequence number
295     --
296     Open C_Sel1;
297     Fetch C_Sel1 Into p_rec.appraisal_period_id;
298     Close C_Sel1;
299   End If;
300   --
301   hr_utility.set_location(' Leaving:'||l_proc, 10);
302 End pre_insert;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |-----------------------------< post_insert >------------------------------|
306 -- ----------------------------------------------------------------------------
307 -- {Start Of Comments}
308 --
309 -- Description:
310 --   This private procedure contains any processing which is required after
311 --   the insert dml.
312 --
313 -- Prerequisites:
314 --   This is an internal procedure which is called from the ins procedure.
315 --
316 -- In Parameters:
317 --   A Pl/Sql record structre.
318 --
319 -- Post Success:
320 --   Processing continues.
321 --
322 -- Post Failure:
323 --   If an error has occurred, an error message and exception will be raised
324 --   but not handled.
325 --
326 -- Developer Implementation Notes:
327 --   Any post-processing required after the insert dml is issued should be
328 --   coded within this procedure. It is important to note that any 3rd party
329 --   maintenance should be reviewed before placing in this procedure.
330 --
331 -- Access Status:
332 --   Internal Row Handler Use Only.
333 --
334 -- {End Of Comments}
335 -- ----------------------------------------------------------------------------
336 Procedure post_insert
337   (p_effective_date               in date
338   ,p_rec                          in per_pma_shd.g_rec_type
339   ) is
340 --
341   l_proc  varchar2(72) := g_package||'post_insert';
342 --
343 Begin
344   hr_utility.set_location('Entering:'||l_proc, 5);
345   begin
346     --
347     per_pma_rki.after_insert
348       (p_effective_date
349       => p_effective_date
350       ,p_appraisal_period_id
351       => p_rec.appraisal_period_id
352       ,p_object_version_number
353       => p_rec.object_version_number
354       ,p_plan_id
355       => p_rec.plan_id
356       ,p_appraisal_template_id
357       => p_rec.appraisal_template_id
358       ,p_start_date
359       => p_rec.start_date
360       ,p_end_date
361       => p_rec.end_date
362       ,p_task_start_date
363       => p_rec.task_start_date
364       ,p_task_end_date
365       => p_rec.task_end_date
366       ,p_initiator_code
367       => p_rec.initiator_code
368       ,p_appraisal_system_type
369       => p_rec.appraisal_system_type
370       ,p_appraisal_type
371       => p_rec.appraisal_type
372       ,p_appraisal_assmt_status
373       => p_rec.appraisal_assmt_status
374       ,p_auto_conc_process
375       => p_rec.auto_conc_process
376       ,p_days_before_task_st_dt
377       => p_rec.days_before_task_st_dt
378       ,p_participation_type
379       => p_rec.participation_type
380       ,p_questionnaire_template_id
381       => p_rec.questionnaire_template_id
382       ,p_attribute_category
383       => p_rec.attribute_category
384       ,p_attribute1
385       => p_rec.attribute1
386       ,p_attribute2
387       => p_rec.attribute2
388       ,p_attribute3
389       => p_rec.attribute3
390       ,p_attribute4
391       => p_rec.attribute4
392       ,p_attribute5
393       => p_rec.attribute5
394       ,p_attribute6
395       => p_rec.attribute6
396       ,p_attribute7
397       => p_rec.attribute7
398       ,p_attribute8
399       => p_rec.attribute8
400       ,p_attribute9
401       => p_rec.attribute9
402       ,p_attribute10
403       => p_rec.attribute10
404       ,p_attribute11
405       => p_rec.attribute11
406       ,p_attribute12
407       => p_rec.attribute12
408       ,p_attribute13
409       => p_rec.attribute13
410       ,p_attribute14
411       => p_rec.attribute14
412       ,p_attribute15
413       => p_rec.attribute15
414       ,p_attribute16
415       => p_rec.attribute16
416       ,p_attribute17
417       => p_rec.attribute17
418       ,p_attribute18
419       => p_rec.attribute18
420       ,p_attribute19
421       => p_rec.attribute19
422       ,p_attribute20
423       => p_rec.attribute20
424       ,p_attribute21
425       => p_rec.attribute21
426       ,p_attribute22
427       => p_rec.attribute22
428       ,p_attribute23
429       => p_rec.attribute23
430       ,p_attribute24
431       => p_rec.attribute24
432       ,p_attribute25
433       => p_rec.attribute25
434       ,p_attribute26
435       => p_rec.attribute26
436       ,p_attribute27
437       => p_rec.attribute27
438       ,p_attribute28
439       => p_rec.attribute28
440       ,p_attribute29
441       => p_rec.attribute29
442       ,p_attribute30
443       => p_rec.attribute30
444       );
445     --
446   exception
447     --
448     when hr_api.cannot_find_prog_unit then
449       --
450       hr_api.cannot_find_prog_unit_error
451         (p_module_name => 'PER_APPRAISAL_PERIODS'
452         ,p_hook_type   => 'AI');
453       --
454   end;
455   --
456   hr_utility.set_location(' Leaving:'||l_proc, 10);
457 End post_insert;
458 --
459 -- ----------------------------------------------------------------------------
460 -- |---------------------------------< ins >----------------------------------|
461 -- ----------------------------------------------------------------------------
462 Procedure ins
463   (p_effective_date               in date
464   ,p_rec                          in out nocopy per_pma_shd.g_rec_type
465   ) is
466 --
467   l_proc  varchar2(72) := g_package||'ins';
468 --
469 Begin
470   hr_utility.set_location('Entering:'||l_proc, 5);
471   --
472   -- Call the supporting insert validate operations
473   --
474   per_pma_bus.insert_validate
475      (p_effective_date
476      ,p_rec
477      );
478   --
479   -- Call to raise any errors on multi-message list
480   hr_multi_message.end_validation_set;
481   --
482   -- Call the supporting pre-insert operation
483   --
484   per_pma_ins.pre_insert(p_rec);
485   --
486   -- Insert the row
487   --
488   per_pma_ins.insert_dml(p_rec);
489   --
490   -- Call the supporting post-insert operation
491   --
492   per_pma_ins.post_insert
493      (p_effective_date
494      ,p_rec
495      );
496   --
497   -- Call to raise any errors on multi-message list
498   hr_multi_message.end_validation_set;
499   --
500   hr_utility.set_location('Leaving:'||l_proc, 20);
501 end ins;
502 --
503 -- ----------------------------------------------------------------------------
504 -- |---------------------------------< ins >----------------------------------|
505 -- ----------------------------------------------------------------------------
506 Procedure ins
507   (p_effective_date               in     date
508   ,p_plan_id                        in     number
509   ,p_appraisal_template_id          in     number
510   ,p_start_date                     in     date
511   ,p_end_date                       in     date
512   ,p_task_start_date                in     date
513   ,p_task_end_date                  in     date
514   ,p_initiator_code                 in     varchar2
515   ,p_appraisal_system_type          in     varchar2
516   ,p_appraisal_type                 in     varchar2
517   ,p_appraisal_assmt_status         in     varchar2
518   ,p_auto_conc_process              in     varchar2
519   ,p_days_before_task_st_dt         in     number
520   ,p_participation_type          in varchar2
521   ,p_questionnaire_template_id   in number
522   ,p_attribute_category             in     varchar2 default null
523   ,p_attribute1                     in     varchar2 default null
524   ,p_attribute2                     in     varchar2 default null
525   ,p_attribute3                     in     varchar2 default null
526   ,p_attribute4                     in     varchar2 default null
527   ,p_attribute5                     in     varchar2 default null
528   ,p_attribute6                     in     varchar2 default null
529   ,p_attribute7                     in     varchar2 default null
530   ,p_attribute8                     in     varchar2 default null
531   ,p_attribute9                     in     varchar2 default null
532   ,p_attribute10                    in     varchar2 default null
533   ,p_attribute11                    in     varchar2 default null
534   ,p_attribute12                    in     varchar2 default null
535   ,p_attribute13                    in     varchar2 default null
536   ,p_attribute14                    in     varchar2 default null
537   ,p_attribute15                    in     varchar2 default null
538   ,p_attribute16                    in     varchar2 default null
539   ,p_attribute17                    in     varchar2 default null
540   ,p_attribute18                    in     varchar2 default null
541   ,p_attribute19                    in     varchar2 default null
542   ,p_attribute20                    in     varchar2 default null
543   ,p_attribute21                    in     varchar2 default null
544   ,p_attribute22                    in     varchar2 default null
545   ,p_attribute23                    in     varchar2 default null
546   ,p_attribute24                    in     varchar2 default null
547   ,p_attribute25                    in     varchar2 default null
548   ,p_attribute26                    in     varchar2 default null
549   ,p_attribute27                    in     varchar2 default null
550   ,p_attribute28                    in     varchar2 default null
551   ,p_attribute29                    in     varchar2 default null
552   ,p_attribute30                    in     varchar2 default null
553   ,p_appraisal_period_id               out nocopy number
554   ,p_object_version_number             out nocopy number
555   ) is
556 --
557   l_rec   per_pma_shd.g_rec_type;
558   l_proc  varchar2(72) := g_package||'ins';
559 --
560 Begin
561   hr_utility.set_location('Entering:'||l_proc, 5);
562   --
563   -- Call conversion function to turn arguments into the
564   -- p_rec structure.
565   --
566   l_rec :=
567   per_pma_shd.convert_args
568     (null
569     ,null
570     ,p_plan_id
571     ,p_appraisal_template_id
572     ,p_start_date
573     ,p_end_date
574     ,p_task_start_date
575     ,p_task_end_date
576     ,p_initiator_code
577     ,p_appraisal_system_type
578     ,p_appraisal_type
579     ,p_appraisal_assmt_status
580     ,p_auto_conc_process
581     ,p_days_before_task_st_dt
582     ,p_participation_type
583     ,p_questionnaire_template_id
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_attribute21
606     ,p_attribute22
607     ,p_attribute23
608     ,p_attribute24
609     ,p_attribute25
610     ,p_attribute26
611     ,p_attribute27
612     ,p_attribute28
613     ,p_attribute29
614     ,p_attribute30
615     );
616   --
617   -- Having converted the arguments into the per_pma_rec
618   -- plsql record structure we call the corresponding record business process.
619   --
620   per_pma_ins.ins
621      (p_effective_date
622      ,l_rec
623      );
624   --
625   -- As the primary key argument(s)
626   -- are specified as an OUT's we must set these values.
627   --
628   p_appraisal_period_id := l_rec.appraisal_period_id;
629   p_object_version_number := l_rec.object_version_number;
630   --
631   hr_utility.set_location(' Leaving:'||l_proc, 10);
632 End ins;
633 --
634 end per_pma_ins;