DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_IDP_INS

Source


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