DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RAA_INS

Source


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