DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_EVT_INS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body per_evt_ins as
2 /* $Header: peevtrhi.pkb 120.2 2008/04/30 11:32:10 uuddavol ship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_evt_ins.';  -- Global package name
9 --
10 --
11 -- The following global variables are only to be used by
15 --
12 -- the set_base_key_value and pre_insert procedures.
13 --
14 g_event_id_i  number   default null;
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20   (p_event_id  in  number) is
21 --
22   l_proc       varchar2(72) := g_package||'set_base_key_value';
23 --
24 Begin
25   hr_utility.set_location('Entering:'||l_proc, 10);
26   --
27   per_evt_ins.g_event_id_i := p_event_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_evt_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, 10);
84   p_rec.object_version_number := 1;  -- Initialise the object version
85   --
86   per_evt_shd.g_api_dml := true;  -- Set the api dml status
87   --
88   -- Insert the row into: per_events
89   --
90   insert into per_events
91       (event_id
92       ,business_group_id
93       ,location_id
94       ,internal_contact_person_id
95       ,organization_run_by_id
96       ,assignment_id
97       ,date_start
98       ,type
99       ,comments
100       ,contact_telephone_number
101       ,date_end
102       ,emp_or_apl
103       ,event_or_interview
104       ,external_contact
105       ,time_end
106       ,time_start
107       ,request_id
108       ,program_application_id
109       ,program_id
110       ,program_update_date
111       ,attribute_category
112       ,attribute1
113       ,attribute2
114       ,attribute3
115       ,attribute4
116       ,attribute5
117       ,attribute6
118       ,attribute7
119       ,attribute8
120       ,attribute9
121       ,attribute10
122       ,attribute11
123       ,attribute12
124       ,attribute13
125       ,attribute14
126       ,attribute15
127       ,attribute16
128       ,attribute17
129       ,attribute18
130       ,attribute19
131       ,attribute20
132       ,party_id
133       ,object_version_number
134       )
135   Values
136     (p_rec.event_id
137     ,p_rec.business_group_id
138     ,p_rec.location_id
139     ,p_rec.internal_contact_person_id
140     ,p_rec.organization_run_by_id
141     ,p_rec.assignment_id
142     ,p_rec.date_start
143     ,p_rec.type
144     ,p_rec.comments
145     ,p_rec.contact_telephone_number
146     ,p_rec.date_end
147     ,p_rec.emp_or_apl
148     ,p_rec.event_or_interview
149     ,p_rec.external_contact
150     ,p_rec.time_end
151     ,p_rec.time_start
152     ,p_rec.request_id
153     ,p_rec.program_application_id
154     ,p_rec.program_id
155     ,p_rec.program_update_date
156     ,p_rec.attribute_category
157     ,p_rec.attribute1
158     ,p_rec.attribute2
159     ,p_rec.attribute3
160     ,p_rec.attribute4
161     ,p_rec.attribute5
162     ,p_rec.attribute6
163     ,p_rec.attribute7
164     ,p_rec.attribute8
165     ,p_rec.attribute9
166     ,p_rec.attribute10
167     ,p_rec.attribute11
168     ,p_rec.attribute12
169     ,p_rec.attribute13
170     ,p_rec.attribute14
171     ,p_rec.attribute15
172     ,p_rec.attribute16
173     ,p_rec.attribute17
177     ,p_rec.party_id
174     ,p_rec.attribute18
175     ,p_rec.attribute19
176     ,p_rec.attribute20
178     ,p_rec.object_version_number
179     );
180   --
181   per_evt_shd.g_api_dml := false;   -- Unset the api dml status
182   --
183   hr_utility.set_location(' Leaving:'||l_proc, 20);
184 Exception
185   When hr_api.check_integrity_violated Then
186     -- A check constraint has been violated
187     per_evt_shd.g_api_dml := false;   -- Unset the api dml status
188     per_evt_shd.constraint_error
189       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
190   When hr_api.parent_integrity_violated Then
191     -- Parent integrity has been violated
192     per_evt_shd.g_api_dml := false;   -- Unset the api dml status
193     per_evt_shd.constraint_error
194       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
195   When hr_api.unique_integrity_violated Then
196     -- Unique integrity has been violated
197     per_evt_shd.g_api_dml := false;   -- Unset the api dml status
198     per_evt_shd.constraint_error
199       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
200   When Others Then
201     per_evt_shd.g_api_dml := false;   -- Unset the api dml status
202     Raise;
203 End insert_dml;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |------------------------------< pre_insert >------------------------------|
207 -- ----------------------------------------------------------------------------
208 -- {Start Of Comments}
209 --
210 -- Description:
211 --   This private procedure contains any processing which is required before
212 --   the insert dml. Presently, if the entity has a corresponding primary
213 --   key which is maintained by an associating sequence, the primary key for
214 --   the entity will be populated with the next sequence value in
215 --   preparation for the insert dml.
216 --
217 -- Prerequisites:
218 --   This is an internal procedure which is called from the ins procedure.
219 --
220 -- In Parameters:
221 --   A Pl/Sql record structre.
222 --
223 -- Post Success:
224 --   Processing continues.
225 --
226 -- Post Failure:
227 --   If an error has occurred, an error message and exception will be raised
228 --   but not handled.
229 --
230 -- Developer Implementation Notes:
231 --   Any pre-processing required before the insert dml is issued should be
232 --   coded within this procedure. As stated above, a good example is the
233 --   generation of a primary key number via a corresponding sequence.
234 --   It is important to note that any 3rd party maintenance should be reviewed
235 --   before placing in this procedure.
236 --
237 -- Access Status:
238 --   Internal Row Handler Use Only.
239 --
240 -- {End Of Comments}
241 -- ----------------------------------------------------------------------------
242 Procedure pre_insert
243   (p_rec  in out nocopy per_evt_shd.g_rec_type
244   ) is
245 --
246   Cursor C_Sel1 is select per_events_s.nextval from sys.dual;
247 --
248 --
249   Cursor C_Sel2 is
250     Select null
251       from per_events
252      where event_id =
253              per_evt_ins.g_event_id_i;
254 --
255   l_proc   varchar2(72) := g_package||'pre_insert';
256   l_exists varchar2(1);
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   If (per_evt_ins.g_event_id_i is not null) Then
262     --
263     -- Verify registered primary key values not already in use
264     --
265     Open C_Sel2;
266     Fetch C_Sel2 into l_exists;
267     If C_Sel2%found Then
268        Close C_Sel2;
269        --
270        -- The primary key values are already in use.
271        --
272        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
273        fnd_message.set_name('TABLE_NAME','per_events');
274        fnd_message.raise_error;
275     End If;
276     Close C_Sel2;
277     --
278     -- Use registered key values and clear globals
279     --
280     p_rec.event_id :=
281       per_evt_ins.g_event_id_i;
282     per_evt_ins.g_event_id_i := null;
283   Else
284     --
285     -- No registerd key values, so select the next sequence number
286     --
287     --
288     -- Select the next sequence number
289     --
290     Open C_Sel1;
291     Fetch C_Sel1 Into p_rec.event_id;
292     Close C_Sel1;
293   End If;
294   --
295   hr_utility.set_location(' Leaving:'||l_proc, 10);
296 End pre_insert;
297 --
298 -- ----------------------------------------------------------------------------
299 -- |-----------------------------< post_insert >------------------------------|
300 -- ----------------------------------------------------------------------------
301 -- {Start Of Comments}
302 --
303 -- Description:
304 --   This private procedure contains any processing which is required after
305 --   the insert dml.
306 --
307 -- Prerequisites:
308 --   This is an internal procedure which is called from the ins procedure.
309 --
310 -- In Parameters:
311 --   A Pl/Sql record structre.
312 --
313 -- Post Success:
314 --   Processing continues.
315 --
316 -- Post Failure:
317 --   If an error has occurred, an error message and exception will be raised
318 --   but not handled.
319 --
320 -- Developer Implementation Notes:
321 --   Any post-processing required after the insert dml is issued should be
322 --   coded within this procedure. It is important to note that any 3rd party
326 --   Internal Row Handler Use Only.
323 --   maintenance should be reviewed before placing in this procedure.
324 --
325 -- Access Status:
327 --
328 -- {End Of Comments}
329 -- ----------------------------------------------------------------------------
330 Procedure post_insert
331   (p_rec                          in per_evt_shd.g_rec_type
332   ) is
333 --
334   l_proc  varchar2(72) := g_package||'post_insert';
335 --
336 Begin
337   hr_utility.set_location('Entering:'||l_proc, 10);
338   begin
339     --
340     per_evt_rki.after_insert
341       (p_event_id
342       => p_rec.event_id
343       ,p_business_group_id
344       => p_rec.business_group_id
345       ,p_location_id
346       => p_rec.location_id
347       ,p_internal_contact_person_id
348       => p_rec.internal_contact_person_id
349       ,p_organization_run_by_id
350       => p_rec.organization_run_by_id
351       ,p_assignment_id
352       => p_rec.assignment_id
353       ,p_date_start
354       => p_rec.date_start
355       ,p_type
356       => p_rec.type
357       ,p_comments
358       => p_rec.comments
359       ,p_contact_telephone_number
360       => p_rec.contact_telephone_number
361       ,p_date_end
362       => p_rec.date_end
363       ,p_emp_or_apl
364       => p_rec.emp_or_apl
365       ,p_event_or_interview
366       => p_rec.event_or_interview
367       ,p_external_contact
368       => p_rec.external_contact
369       ,p_time_end
370       => p_rec.time_end
371       ,p_time_start
372       => p_rec.time_start
373       ,p_request_id
374       => p_rec.request_id
375       ,p_program_application_id
376       => p_rec.program_application_id
377       ,p_program_id
378       => p_rec.program_id
379       ,p_program_update_date
380       => p_rec.program_update_date
381       ,p_attribute_category
382       => p_rec.attribute_category
383       ,p_attribute1
384       => p_rec.attribute1
385       ,p_attribute2
386       => p_rec.attribute2
387       ,p_attribute3
388       => p_rec.attribute3
389       ,p_attribute4
390       => p_rec.attribute4
391       ,p_attribute5
392       => p_rec.attribute5
393       ,p_attribute6
394       => p_rec.attribute6
395       ,p_attribute7
396       => p_rec.attribute7
397       ,p_attribute8
398       => p_rec.attribute8
399       ,p_attribute9
400       => p_rec.attribute9
401       ,p_attribute10
402       => p_rec.attribute10
403       ,p_attribute11
404       => p_rec.attribute11
405       ,p_attribute12
406       => p_rec.attribute12
407       ,p_attribute13
408       => p_rec.attribute13
409       ,p_attribute14
410       => p_rec.attribute14
411       ,p_attribute15
412       => p_rec.attribute15
413       ,p_attribute16
414       => p_rec.attribute16
415       ,p_attribute17
416       => p_rec.attribute17
417       ,p_attribute18
418       => p_rec.attribute18
419       ,p_attribute19
420       => p_rec.attribute19
421       ,p_attribute20
422       => p_rec.attribute20
423       ,p_party_id
424       => p_rec.party_id
425       ,p_object_version_number
426       => p_rec.object_version_number
427       );
428     --
429   exception
430     --
431     when hr_api.cannot_find_prog_unit then
432       --
433       hr_api.cannot_find_prog_unit_error
434         (p_module_name => 'PER_EVENTS'
435         ,p_hook_type   => 'AI');
436       --
437   end;
438   --
439   hr_utility.set_location(' Leaving:'||l_proc, 20);
440 End post_insert;
441 --
442 -- ----------------------------------------------------------------------------
443 -- |---------------------------------< ins >----------------------------------|
444 -- ----------------------------------------------------------------------------
445 Procedure ins
446   (p_rec                          in out nocopy per_evt_shd.g_rec_type
447   ) is
448 --
449   l_proc  varchar2(72) := g_package||'ins';
450 --
451 Begin
452   hr_utility.set_location('Entering:'||l_proc, 10);
453   --
454   -- Call the supporting insert validate operations
455   --
456   per_evt_bus.insert_validate
457      (p_rec
458      );
459   --
460   -- Call the supporting pre-insert operation
461   --
462   per_evt_ins.pre_insert(p_rec);
463   --
464   -- Insert the row
465   --
466   per_evt_ins.insert_dml(p_rec);
467   --
468   -- Call the supporting post-insert operation
469   --
470   per_evt_ins.post_insert
471      (p_rec
472      );
473   --
474   hr_utility.set_location('Leaving:'||l_proc, 20);
475 end ins;
476 --
477 -- ----------------------------------------------------------------------------
478 -- |---------------------------------< ins >----------------------------------|
479 -- ----------------------------------------------------------------------------
480 Procedure ins
481   (p_business_group_id              in     number
482   ,p_date_start                     in     date
483   ,p_type                           in     varchar2
484   ,p_location_id                    in     number   default null
485   ,p_internal_contact_person_id     in     number   default null
486   ,p_organization_run_by_id         in     number   default null
487   ,p_assignment_id                  in     number   default null
488   ,p_comments                       in     varchar2 default null
492   ,p_event_or_interview             in     varchar2 default null
489   ,p_contact_telephone_number       in     varchar2 default null
490   ,p_date_end                       in     date     default null
491   ,p_emp_or_apl                     in     varchar2 default null
493   ,p_external_contact               in     varchar2 default null
494   ,p_time_end                       in     varchar2 default null
495   ,p_time_start                     in     varchar2 default null
496   ,p_request_id                     in     number   default null
497   ,p_program_application_id         in     number   default null
498   ,p_program_id                     in     number   default null
499   ,p_program_update_date            in     date     default null
500   ,p_attribute_category             in     varchar2 default null
501   ,p_attribute1                     in     varchar2 default null
502   ,p_attribute2                     in     varchar2 default null
503   ,p_attribute3                     in     varchar2 default null
504   ,p_attribute4                     in     varchar2 default null
505   ,p_attribute5                     in     varchar2 default null
506   ,p_attribute6                     in     varchar2 default null
507   ,p_attribute7                     in     varchar2 default null
508   ,p_attribute8                     in     varchar2 default null
509   ,p_attribute9                     in     varchar2 default null
510   ,p_attribute10                    in     varchar2 default null
511   ,p_attribute11                    in     varchar2 default null
512   ,p_attribute12                    in     varchar2 default null
513   ,p_attribute13                    in     varchar2 default null
514   ,p_attribute14                    in     varchar2 default null
515   ,p_attribute15                    in     varchar2 default null
516   ,p_attribute16                    in     varchar2 default null
517   ,p_attribute17                    in     varchar2 default null
518   ,p_attribute18                    in     varchar2 default null
519   ,p_attribute19                    in     varchar2 default null
520   ,p_attribute20                    in     varchar2 default null
521   ,p_party_id                       in     number   default null
522   ,p_event_id                          out nocopy number
523   ,p_object_version_number             out nocopy number
524   ) is
525 --
526   l_rec   per_evt_shd.g_rec_type;
527   l_proc  varchar2(72) := g_package||'ins';
528 --
529 Begin
530   hr_utility.set_location('Entering:'||l_proc, 10);
531   --
532   -- Call conversion function to turn arguments into the
533   -- p_recstructure.
534   --
535   l_rec :=
536   per_evt_shd.convert_args
537     (null
538     ,p_business_group_id
539     ,p_location_id
540     ,p_internal_contact_person_id
541     ,p_organization_run_by_id
542     ,p_assignment_id
543     ,p_date_start
544     ,p_type
545     ,p_comments
546     ,p_contact_telephone_number
547     ,p_date_end
548     ,p_emp_or_apl
549     ,p_event_or_interview
550     ,p_external_contact
551     ,p_time_end
552     ,p_time_start
553     ,p_request_id
554     ,p_program_application_id
555     ,p_program_id
556     ,p_program_update_date
557     ,p_attribute_category
558     ,p_attribute1
559     ,p_attribute2
560     ,p_attribute3
561     ,p_attribute4
562     ,p_attribute5
563     ,p_attribute6
564     ,p_attribute7
565     ,p_attribute8
566     ,p_attribute9
567     ,p_attribute10
568     ,p_attribute11
569     ,p_attribute12
570     ,p_attribute13
571     ,p_attribute14
572     ,p_attribute15
573     ,p_attribute16
574     ,p_attribute17
575     ,p_attribute18
576     ,p_attribute19
577     ,p_attribute20
578     ,p_party_id
579     ,null
580     );
581   --
582   -- Having converted the arguments into the per_evt_rec
583   -- plsql record structure we call the corresponding record business process.
584   --
585   per_evt_ins.ins
586      (l_rec
587      );
588   --
589   -- As the primary key argument(s)
590   -- are specified as an OUT's we must set these values.
591   --
592   p_event_id := l_rec.event_id;
593   p_object_version_number := l_rec.object_version_number;
594   --
595   hr_utility.set_location(' Leaving:'||l_proc, 20);
596 End ins;
597 --
598 end per_evt_ins;