DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_PCV_INS

Source


1 Package Body pqp_pcv_ins as
2 /* $Header: pqpcvrhi.pkb 120.0 2005/05/29 01:55:22 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqp_pcv_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_configuration_value_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_configuration_value_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   pqp_pcv_ins.g_configuration_value_id_i := p_configuration_value_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |-----------------------< create_app_ownerships >--------------------------|
34 -- ----------------------------------------------------------------------------
35 --
36 -- Description:
37 --   This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
38 --   when the row handler is called in the appropriate mode.
39 --
40 -- ----------------------------------------------------------------------------
41 PROCEDURE create_app_ownerships(p_pk_column  IN varchar2
42                                ,p_pk_value   IN varchar2) IS
43 --
44 CURSOR csr_definition IS
45   SELECT product_short_name
46     FROM hr_owner_definitions
47    WHERE session_id = hr_startup_data_api_support.g_session_id;
48 --
49 BEGIN
50   --
51   IF (hr_startup_data_api_support.return_startup_mode IN
52                                ('STARTUP','GENERIC')) THEN
53      --
54      FOR c1 IN csr_definition LOOP
55        --
56        INSERT INTO hr_application_ownerships
57          (key_name
58          ,key_value
59          ,product_name
60          )
61        VALUES
62          (p_pk_column
63          ,fnd_number.number_to_canonical(p_pk_value)
64          ,c1.product_short_name
65          );
66      END LOOP;
67   END IF;
68 END create_app_ownerships;
69 --
70 -- ----------------------------------------------------------------------------
71 -- |-----------------------< create_app_ownerships >--------------------------|
72 -- ----------------------------------------------------------------------------
73 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
74                                ,p_pk_value  IN number) IS
75 --
76 BEGIN
77   create_app_ownerships(p_pk_column, to_char(p_pk_value));
78 END create_app_ownerships;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |------------------------------< insert_dml >------------------------------|
82 -- ----------------------------------------------------------------------------
83 -- {Start Of Comments}
84 --
85 -- Description:
86 --   This procedure controls the actual dml insert logic. The processing of
87 --   this procedure are as follows:
88 --   1) Initialise the object_version_number to 1 if the object_version_number
89 --      is defined as an attribute for this entity.
90 --   2) To set and unset the g_api_dml status as required (as we are about to
91 --      perform dml).
92 --   3) To insert the row into the schema.
93 --   4) To trap any constraint violations that may have occurred.
94 --   5) To raise any other errors.
95 --
96 -- Prerequisites:
97 --   This is an internal private procedure which must be called from the ins
98 --   procedure and must have all mandatory attributes set (except the
99 --   object_version_number which is initialised within this procedure).
100 --
101 -- In Parameters:
102 --   A Pl/Sql record structre.
103 --
104 -- Post Success:
105 --   The specified row will be inserted into the schema.
106 --
107 -- Post Failure:
108 --   On the insert dml failure it is important to note that we always reset the
109 --   g_api_dml status to false.
110 --   If a check, unique or parent integrity constraint violation is raised the
111 --   constraint_error procedure will be called.
112 --   If any other error is reported, the error will be raised after the
113 --   g_api_dml status is reset.
114 --
115 -- Developer Implementation Notes:
116 --   None.
117 --
118 -- Access Status:
119 --   Internal Row Handler Use Only.
120 --
121 -- {End Of Comments}
122 -- ----------------------------------------------------------------------------
123 Procedure insert_dml
124   (p_rec in out nocopy pqp_pcv_shd.g_rec_type
125   ) is
126 --
127   l_proc  varchar2(72) := g_package||'insert_dml';
128 --
129 Begin
130   hr_utility.set_location('Entering:'||l_proc, 5);
131   p_rec.object_version_number := 1;  -- Initialise the object version
132   --
133   --
134   --
135   -- Insert the row into: pqp_configuration_values
136   --
137   insert into pqp_configuration_values
138       (configuration_value_id
139       ,business_group_id
140       ,legislation_code
141       ,pcv_attribute_category
142       ,pcv_attribute1
143       ,pcv_attribute2
144       ,pcv_attribute3
145       ,pcv_attribute4
146       ,pcv_attribute5
147       ,pcv_attribute6
148       ,pcv_attribute7
149       ,pcv_attribute8
150       ,pcv_attribute9
151       ,pcv_attribute10
152       ,pcv_attribute11
153       ,pcv_attribute12
154       ,pcv_attribute13
155       ,pcv_attribute14
156       ,pcv_attribute15
157       ,pcv_attribute16
158       ,pcv_attribute17
159       ,pcv_attribute18
160       ,pcv_attribute19
161       ,pcv_attribute20
162       ,pcv_information_category
163       ,pcv_information1
164       ,pcv_information2
165       ,pcv_information3
166       ,pcv_information4
167       ,pcv_information5
168       ,pcv_information6
169       ,pcv_information7
170       ,pcv_information8
171       ,pcv_information9
172       ,pcv_information10
173       ,pcv_information11
174       ,pcv_information12
175       ,pcv_information13
176       ,pcv_information14
177       ,pcv_information15
178       ,pcv_information16
179       ,pcv_information17
180       ,pcv_information18
181       ,pcv_information19
182       ,pcv_information20
183       ,object_version_number
184       ,configuration_name
185       )
186   Values
187     (p_rec.configuration_value_id
188     ,p_rec.business_group_id
189     ,p_rec.legislation_code
190     ,p_rec.pcv_attribute_category
191     ,p_rec.pcv_attribute1
192     ,p_rec.pcv_attribute2
193     ,p_rec.pcv_attribute3
194     ,p_rec.pcv_attribute4
195     ,p_rec.pcv_attribute5
196     ,p_rec.pcv_attribute6
197     ,p_rec.pcv_attribute7
198     ,p_rec.pcv_attribute8
199     ,p_rec.pcv_attribute9
200     ,p_rec.pcv_attribute10
201     ,p_rec.pcv_attribute11
202     ,p_rec.pcv_attribute12
203     ,p_rec.pcv_attribute13
204     ,p_rec.pcv_attribute14
205     ,p_rec.pcv_attribute15
206     ,p_rec.pcv_attribute16
207     ,p_rec.pcv_attribute17
208     ,p_rec.pcv_attribute18
209     ,p_rec.pcv_attribute19
213     ,p_rec.pcv_information2
210     ,p_rec.pcv_attribute20
211     ,p_rec.pcv_information_category
212     ,p_rec.pcv_information1
214     ,p_rec.pcv_information3
215     ,p_rec.pcv_information4
216     ,p_rec.pcv_information5
217     ,p_rec.pcv_information6
218     ,p_rec.pcv_information7
219     ,p_rec.pcv_information8
220     ,p_rec.pcv_information9
221     ,p_rec.pcv_information10
222     ,p_rec.pcv_information11
223     ,p_rec.pcv_information12
224     ,p_rec.pcv_information13
225     ,p_rec.pcv_information14
226     ,p_rec.pcv_information15
227     ,p_rec.pcv_information16
228     ,p_rec.pcv_information17
229     ,p_rec.pcv_information18
230     ,p_rec.pcv_information19
231     ,p_rec.pcv_information20
232     ,p_rec.object_version_number
233     ,p_rec.configuration_name
234     );
235   --
236   --
237   --
238   hr_utility.set_location(' Leaving:'||l_proc, 10);
239 Exception
240   When hr_api.check_integrity_violated Then
241     -- A check constraint has been violated
242     --
243     pqp_pcv_shd.constraint_error
244       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
245   When hr_api.parent_integrity_violated Then
246     -- Parent integrity has been violated
247     --
248     pqp_pcv_shd.constraint_error
249       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
250   When hr_api.unique_integrity_violated Then
251     -- Unique integrity has been violated
252     --
253     pqp_pcv_shd.constraint_error
254       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
255   When Others Then
256     --
257     Raise;
258 End insert_dml;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |------------------------------< pre_insert >------------------------------|
262 -- ----------------------------------------------------------------------------
263 -- {Start Of Comments}
264 --
265 -- Description:
266 --   This private procedure contains any processing which is required before
267 --   the insert dml. Presently, if the entity has a corresponding primary
268 --   key which is maintained by an associating sequence, the primary key for
269 --   the entity will be populated with the next sequence value in
270 --   preparation for the insert dml.
271 --
272 -- Prerequisites:
273 --   This is an internal procedure which is called from the ins procedure.
274 --
275 -- In Parameters:
276 --   A Pl/Sql record structure.
277 --
278 -- Post Success:
279 --   Processing continues.
280 --
281 -- Post Failure:
282 --   If an error has occurred, an error message and exception will be raised
283 --   but not handled.
284 --
285 -- Developer Implementation Notes:
286 --   Any pre-processing required before the insert dml is issued should be
287 --   coded within this procedure. As stated above, a good example is the
288 --   generation of a primary key number via a corresponding sequence.
289 --   It is important to note that any 3rd party maintenance should be reviewed
290 --   before placing in this procedure.
291 --
292 -- Access Status:
293 --   Internal Row Handler Use Only.
294 --
295 -- {End Of Comments}
296 -- ----------------------------------------------------------------------------
297 Procedure pre_insert
298   (p_rec  in out nocopy pqp_pcv_shd.g_rec_type
299   ) is
300 --
301   Cursor C_Sel1 is select pqp_configuration_values_s.nextval from sys.dual;
302 --
303   Cursor C_Sel2 is
304     Select null
305       from pqp_configuration_values
306      where configuration_value_id =
307              pqp_pcv_ins.g_configuration_value_id_i;
308 --
309   l_proc   varchar2(72) := g_package||'pre_insert';
310   l_exists varchar2(1);
311 --
312 Begin
313   hr_utility.set_location('Entering:'||l_proc, 5);
314   --
315   If (pqp_pcv_ins.g_configuration_value_id_i is not null) Then
316     --
317     -- Verify registered primary key values not already in use
318     --
319     Open C_Sel2;
320     Fetch C_Sel2 into l_exists;
321     If C_Sel2%found Then
322        Close C_Sel2;
323        --
324        -- The primary key values are already in use.
325        --
326        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
327        fnd_message.set_token('TABLE_NAME','pqp_configuration_values');
328        fnd_message.raise_error;
329     End If;
330     Close C_Sel2;
331     --
332     -- Use registered key values and clear globals
333     --
334     p_rec.configuration_value_id :=
335       pqp_pcv_ins.g_configuration_value_id_i;
336     pqp_pcv_ins.g_configuration_value_id_i := null;
337   Else
338     --
339     -- No registerd key values, so select the next sequence number
340     --
341     --
342     -- Select the next sequence number
343     --
344     Open C_Sel1;
345     Fetch C_Sel1 Into p_rec.configuration_value_id;
346     Close C_Sel1;
347   End If;
348   --
349   hr_utility.set_location(' Leaving:'||l_proc, 10);
350 End pre_insert;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |-----------------------------< post_insert >------------------------------|
354 -- ----------------------------------------------------------------------------
355 -- {Start Of Comments}
356 --
357 -- Description:
358 --   This private procedure contains any processing which is required after
359 --   the insert dml.
360 --
361 -- Prerequisites:
362 --   This is an internal procedure which is called from the ins procedure.
363 --
364 -- In Parameters:
365 --   A Pl/Sql record structre.
366 --
367 -- Post Success:
368 --   Processing continues.
369 --
370 -- Post Failure:
371 --   If an error has occurred, an error message and exception will be raised
372 --   but not handled.
373 --
374 -- Developer Implementation Notes:
375 --   Any post-processing required after the insert dml is issued should be
376 --   coded within this procedure. It is important to note that any 3rd party
377 --   maintenance should be reviewed before placing in this procedure.
378 --
379 -- Access Status:
380 --   Internal Row Handler Use Only.
381 --
382 -- {End Of Comments}
383 -- ----------------------------------------------------------------------------
384 Procedure post_insert
385   (p_effective_date               in date
386   ,p_rec                          in pqp_pcv_shd.g_rec_type
387   ) is
388 --
389   l_proc  varchar2(72) := g_package||'post_insert';
390 --
391 Begin
392   hr_utility.set_location('Entering:'||l_proc, 5);
393   begin
394     --
395     -- insert ownerships if applicable
396     create_app_ownerships
397       ('CONFIGURATION_VALUE_ID', p_rec.configuration_value_id
398       );
399     --
400     --
401     pqp_pcv_rki.after_insert
402       (p_effective_date              => p_effective_date
403       ,p_configuration_value_id
404       => p_rec.configuration_value_id
405       ,p_business_group_id
406       => p_rec.business_group_id
407       ,p_legislation_code
408       => p_rec.legislation_code
409       ,p_pcv_attribute_category
410       => p_rec.pcv_attribute_category
411       ,p_pcv_attribute1
412       => p_rec.pcv_attribute1
413       ,p_pcv_attribute2
414       => p_rec.pcv_attribute2
415       ,p_pcv_attribute3
416       => p_rec.pcv_attribute3
417       ,p_pcv_attribute4
418       => p_rec.pcv_attribute4
419       ,p_pcv_attribute5
420       => p_rec.pcv_attribute5
421       ,p_pcv_attribute6
422       => p_rec.pcv_attribute6
423       ,p_pcv_attribute7
424       => p_rec.pcv_attribute7
425       ,p_pcv_attribute8
426       => p_rec.pcv_attribute8
427       ,p_pcv_attribute9
428       => p_rec.pcv_attribute9
429       ,p_pcv_attribute10
430       => p_rec.pcv_attribute10
431       ,p_pcv_attribute11
432       => p_rec.pcv_attribute11
433       ,p_pcv_attribute12
434       => p_rec.pcv_attribute12
435       ,p_pcv_attribute13
436       => p_rec.pcv_attribute13
437       ,p_pcv_attribute14
438       => p_rec.pcv_attribute14
439       ,p_pcv_attribute15
440       => p_rec.pcv_attribute15
441       ,p_pcv_attribute16
442       => p_rec.pcv_attribute16
443       ,p_pcv_attribute17
444       => p_rec.pcv_attribute17
445       ,p_pcv_attribute18
446       => p_rec.pcv_attribute18
447       ,p_pcv_attribute19
448       => p_rec.pcv_attribute19
449       ,p_pcv_attribute20
450       => p_rec.pcv_attribute20
451       ,p_pcv_information_category
452       => p_rec.pcv_information_category
453       ,p_pcv_information1
454       => p_rec.pcv_information1
455       ,p_pcv_information2
456       => p_rec.pcv_information2
457       ,p_pcv_information3
458       => p_rec.pcv_information3
459       ,p_pcv_information4
460       => p_rec.pcv_information4
461       ,p_pcv_information5
462       => p_rec.pcv_information5
463       ,p_pcv_information6
464       => p_rec.pcv_information6
465       ,p_pcv_information7
466       => p_rec.pcv_information7
467       ,p_pcv_information8
468       => p_rec.pcv_information8
469       ,p_pcv_information9
470       => p_rec.pcv_information9
471       ,p_pcv_information10
472       => p_rec.pcv_information10
473       ,p_pcv_information11
474       => p_rec.pcv_information11
475       ,p_pcv_information12
476       => p_rec.pcv_information12
477       ,p_pcv_information13
478       => p_rec.pcv_information13
479       ,p_pcv_information14
480       => p_rec.pcv_information14
481       ,p_pcv_information15
482       => p_rec.pcv_information15
483       ,p_pcv_information16
484       => p_rec.pcv_information16
485       ,p_pcv_information17
486       => p_rec.pcv_information17
487       ,p_pcv_information18
488       => p_rec.pcv_information18
489       ,p_pcv_information19
490       => p_rec.pcv_information19
491       ,p_pcv_information20
492       => p_rec.pcv_information20
493       ,p_object_version_number
494       => p_rec.object_version_number
495       ,p_configuration_name
496       => p_rec.configuration_name
497       );
498     --
499   exception
500     --
501     when hr_api.cannot_find_prog_unit then
502       --
503       hr_api.cannot_find_prog_unit_error
504         (p_module_name => 'PQP_CONFIGURATION_VALUES'
505         ,p_hook_type   => 'AI');
506       --
507   end;
508   --
509   hr_utility.set_location(' Leaving:'||l_proc, 10);
510 End post_insert;
511 --
512 -- ----------------------------------------------------------------------------
513 -- |---------------------------------< ins >----------------------------------|
514 -- ----------------------------------------------------------------------------
515 Procedure ins
516   (p_effective_date               in date
517   ,p_rec                          in out nocopy pqp_pcv_shd.g_rec_type
518   ) is
519 --
520   l_proc  varchar2(72) := g_package||'ins';
521 --
522 Begin
523   hr_utility.set_location('Entering:'||l_proc, 5);
524   --
525   -- Call the supporting insert validate operations
526   --
527   pqp_pcv_bus.insert_validate
528      (p_effective_date
529      ,p_rec
530      );
531   --
532   -- Call to raise any errors on multi-message list
533   hr_multi_message.end_validation_set;
534   --
535   -- Call the supporting pre-insert operation
536   --
537   pqp_pcv_ins.pre_insert(p_rec);
538   --
539   -- Insert the row
540   --
541   pqp_pcv_ins.insert_dml(p_rec);
542   --
543   -- Call the supporting post-insert operation
544   --
545   pqp_pcv_ins.post_insert
546      (p_effective_date
547      ,p_rec
548      );
549   --
550   -- Call to raise any errors on multi-message list
551   hr_multi_message.end_validation_set;
552   --
553   hr_utility.set_location('Leaving:'||l_proc, 20);
554 end ins;
555 --
556 -- ----------------------------------------------------------------------------
557 -- |---------------------------------< ins >----------------------------------|
558 -- ----------------------------------------------------------------------------
559 Procedure ins
560   (p_effective_date               in     date
561   ,p_business_group_id              in     number
562   ,p_legislation_code               in     varchar2
563   ,p_pcv_attribute_category         in     varchar2
564   ,p_pcv_attribute1                 in     varchar2
565   ,p_pcv_attribute2                 in     varchar2
566   ,p_pcv_attribute3                 in     varchar2
567   ,p_pcv_attribute4                 in     varchar2
568   ,p_pcv_attribute5                 in     varchar2
569   ,p_pcv_attribute6                 in     varchar2
570   ,p_pcv_attribute7                 in     varchar2
571   ,p_pcv_attribute8                 in     varchar2
572   ,p_pcv_attribute9                 in     varchar2
573   ,p_pcv_attribute10                in     varchar2
574   ,p_pcv_attribute11                in     varchar2
575   ,p_pcv_attribute12                in     varchar2
576   ,p_pcv_attribute13                in     varchar2
577   ,p_pcv_attribute14                in     varchar2
578   ,p_pcv_attribute15                in     varchar2
579   ,p_pcv_attribute16                in     varchar2
580   ,p_pcv_attribute17                in     varchar2
581   ,p_pcv_attribute18                in     varchar2
582   ,p_pcv_attribute19                in     varchar2
583   ,p_pcv_attribute20                in     varchar2
584   ,p_pcv_information_category       in     varchar2
585   ,p_pcv_information1               in     varchar2
586   ,p_pcv_information2               in     varchar2
587   ,p_pcv_information3               in     varchar2
588   ,p_pcv_information4               in     varchar2
589   ,p_pcv_information5               in     varchar2
590   ,p_pcv_information6               in     varchar2
591   ,p_pcv_information7               in     varchar2
592   ,p_pcv_information8               in     varchar2
593   ,p_pcv_information9               in     varchar2
594   ,p_pcv_information10              in     varchar2
595   ,p_pcv_information11              in     varchar2
596   ,p_pcv_information12              in     varchar2
597   ,p_pcv_information13              in     varchar2
598   ,p_pcv_information14              in     varchar2
599   ,p_pcv_information15              in     varchar2
600   ,p_pcv_information16              in     varchar2
601   ,p_pcv_information17              in     varchar2
602   ,p_pcv_information18              in     varchar2
603   ,p_pcv_information19              in     varchar2
604   ,p_pcv_information20              in     varchar2
605   ,p_configuration_value_id            out nocopy number
606   ,p_object_version_number             out nocopy number
607   ,p_configuration_name               in     varchar2
608   ) is
609 --
610   l_rec   pqp_pcv_shd.g_rec_type;
611   l_proc  varchar2(72) := g_package||'ins';
612 --
613 Begin
614   hr_utility.set_location('Entering:'||l_proc, 5);
615   --
616   -- Call conversion function to turn arguments into the
617   -- p_rec structure.
618   --
619   l_rec :=
620   pqp_pcv_shd.convert_args
621     (null
622     ,p_business_group_id
623     ,p_legislation_code
624     ,p_pcv_attribute_category
625     ,p_pcv_attribute1
626     ,p_pcv_attribute2
627     ,p_pcv_attribute3
628     ,p_pcv_attribute4
629     ,p_pcv_attribute5
630     ,p_pcv_attribute6
631     ,p_pcv_attribute7
632     ,p_pcv_attribute8
633     ,p_pcv_attribute9
634     ,p_pcv_attribute10
635     ,p_pcv_attribute11
636     ,p_pcv_attribute12
637     ,p_pcv_attribute13
638     ,p_pcv_attribute14
639     ,p_pcv_attribute15
640     ,p_pcv_attribute16
641     ,p_pcv_attribute17
642     ,p_pcv_attribute18
643     ,p_pcv_attribute19
644     ,p_pcv_attribute20
645     ,p_pcv_information_category
646     ,p_pcv_information1
647     ,p_pcv_information2
648     ,p_pcv_information3
649     ,p_pcv_information4
650     ,p_pcv_information5
651     ,p_pcv_information6
652     ,p_pcv_information7
653     ,p_pcv_information8
654     ,p_pcv_information9
655     ,p_pcv_information10
656     ,p_pcv_information11
657     ,p_pcv_information12
658     ,p_pcv_information13
659     ,p_pcv_information14
660     ,p_pcv_information15
661     ,p_pcv_information16
662     ,p_pcv_information17
663     ,p_pcv_information18
664     ,p_pcv_information19
665     ,p_pcv_information20
666     ,null
667     ,p_configuration_name
668     );
669   --
670   -- Having converted the arguments into the pqp_pcv_rec
671   -- plsql record structure we call the corresponding record business process.
672   --
673   pqp_pcv_ins.ins
674      (p_effective_date
675      ,l_rec
676      );
677   --
678   -- As the primary key argument(s)
679   -- are specified as an OUT's we must set these values.
680   --
681   p_configuration_value_id := l_rec.configuration_value_id;
682   p_object_version_number := l_rec.object_version_number;
683   --
684   hr_utility.set_location(' Leaving:'||l_proc, 10);
685 End ins;
686 --
687 end pqp_pcv_ins;