DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_ERC_INS

Source


1 Package Body ben_erc_ins as
2 /* $Header: beercrhi.pkb 115.2 2002/12/11 11:16:15 hnarayan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_erc_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy ben_erc_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   ben_erc_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_enrt_rt_ctfn
64   --
65   insert into ben_enrt_rt_ctfn
66   (	enrt_rt_ctfn_id,
67 	enrt_ctfn_typ_cd,
68 	rqd_flag,
69 	enrt_rt_id,
70 	business_group_id,
71 	erc_attribute_category,
72 	erc_attribute1,
73 	erc_attribute2,
74 	erc_attribute3,
75 	erc_attribute4,
76 	erc_attribute5,
77 	erc_attribute6,
78 	erc_attribute7,
79 	erc_attribute8,
80 	erc_attribute9,
81 	erc_attribute10,
82 	erc_attribute11,
83 	erc_attribute12,
84 	erc_attribute13,
85 	erc_attribute14,
86 	erc_attribute15,
87 	erc_attribute16,
88 	erc_attribute17,
89 	erc_attribute18,
90 	erc_attribute19,
91 	erc_attribute20,
92 	erc_attribute21,
93 	erc_attribute22,
94 	erc_attribute23,
95 	erc_attribute24,
96 	erc_attribute25,
97 	erc_attribute26,
98 	erc_attribute27,
99 	erc_attribute28,
100 	erc_attribute29,
101 	erc_attribute30,
102 	request_id,
103 	program_application_id,
104 	program_id,
105 	program_update_date,
106 	object_version_number
107   )
108   Values
109   (	p_rec.enrt_rt_ctfn_id,
110 	p_rec.enrt_ctfn_typ_cd,
111 	p_rec.rqd_flag,
112 	p_rec.enrt_rt_id,
113 	p_rec.business_group_id,
114 	p_rec.erc_attribute_category,
115 	p_rec.erc_attribute1,
116 	p_rec.erc_attribute2,
117 	p_rec.erc_attribute3,
118 	p_rec.erc_attribute4,
119 	p_rec.erc_attribute5,
120 	p_rec.erc_attribute6,
121 	p_rec.erc_attribute7,
122 	p_rec.erc_attribute8,
123 	p_rec.erc_attribute9,
124 	p_rec.erc_attribute10,
125 	p_rec.erc_attribute11,
126 	p_rec.erc_attribute12,
127 	p_rec.erc_attribute13,
128 	p_rec.erc_attribute14,
129 	p_rec.erc_attribute15,
130 	p_rec.erc_attribute16,
131 	p_rec.erc_attribute17,
132 	p_rec.erc_attribute18,
133 	p_rec.erc_attribute19,
134 	p_rec.erc_attribute20,
135 	p_rec.erc_attribute21,
136 	p_rec.erc_attribute22,
137 	p_rec.erc_attribute23,
138 	p_rec.erc_attribute24,
139 	p_rec.erc_attribute25,
140 	p_rec.erc_attribute26,
141 	p_rec.erc_attribute27,
142 	p_rec.erc_attribute28,
143 	p_rec.erc_attribute29,
144 	p_rec.erc_attribute30,
145 	p_rec.request_id,
146 	p_rec.program_application_id,
147 	p_rec.program_id,
148 	p_rec.program_update_date,
149 	p_rec.object_version_number
150   );
151   --
152   ben_erc_shd.g_api_dml := false;   -- Unset the api dml status
153   --
154   hr_utility.set_location(' Leaving:'||l_proc, 10);
155 Exception
156   When hr_api.check_integrity_violated Then
157     -- A check constraint has been violated
158     ben_erc_shd.g_api_dml := false;   -- Unset the api dml status
159     ben_erc_shd.constraint_error
160       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
161   When hr_api.parent_integrity_violated Then
162     -- Parent integrity has been violated
163     ben_erc_shd.g_api_dml := false;   -- Unset the api dml status
164     ben_erc_shd.constraint_error
165       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
166   When hr_api.unique_integrity_violated Then
167     -- Unique integrity has been violated
168     ben_erc_shd.g_api_dml := false;   -- Unset the api dml status
169     ben_erc_shd.constraint_error
170       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
171   When Others Then
172     ben_erc_shd.g_api_dml := false;   -- Unset the api dml status
173     Raise;
174 End insert_dml;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |------------------------------< pre_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 --   This private procedure contains any processing which is required before
183 --   the insert dml. Presently, if the entity has a corresponding primary
184 --   key which is maintained by an associating sequence, the primary key for
185 --   the entity will be populated with the next sequence value in
186 --   preparation for the insert dml.
187 --
188 -- Prerequisites:
189 --   This is an internal procedure which is called from the ins procedure.
190 --
191 -- In Parameters:
192 --   A Pl/Sql record structre.
193 --
194 -- Post Success:
195 --   Processing continues.
196 --
197 -- Post Failure:
198 --   If an error has occurred, an error message and exception will be raised
199 --   but not handled.
200 --
201 -- Developer Implementation Notes:
202 --   Any pre-processing required before the insert dml is issued should be
203 --   coded within this procedure. As stated above, a good example is the
204 --   generation of a primary key number via a corresponding sequence.
205 --   It is important to note that any 3rd party maintenance should be reviewed
206 --   before placing in this procedure.
207 --
208 -- Access Status:
209 --   Internal Row Handler Use Only.
210 --
211 -- {End Of Comments}
212 -- ----------------------------------------------------------------------------
213 Procedure pre_insert(p_rec  in out nocopy ben_erc_shd.g_rec_type) is
214 --
215   l_proc  varchar2(72) := g_package||'pre_insert';
216 --
217   Cursor C_Sel1 is select ben_enrt_rt_ctfn_s.nextval from sys.dual;
218 --
219 Begin
220   hr_utility.set_location('Entering:'||l_proc, 5);
221   --
222   --
223   -- Select the next sequence number
224   --
225   Open C_Sel1;
226   Fetch C_Sel1 Into p_rec.enrt_rt_ctfn_id;
227   Close C_Sel1;
228   --
229   hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End pre_insert;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |-----------------------------< post_insert >------------------------------|
234 -- ----------------------------------------------------------------------------
235 -- {Start Of Comments}
236 --
237 -- Description:
238 --   This private procedure contains any processing which is required after the
239 --   insert dml.
240 --
241 -- Prerequisites:
242 --   This is an internal procedure which is called from the ins procedure.
243 --
244 -- In Parameters:
245 --   A Pl/Sql record structre.
246 --
247 -- Post Success:
248 --   Processing continues.
249 --
250 -- Post Failure:
251 --   If an error has occurred, an error message and exception will be raised
252 --   but not handled.
253 --
254 -- Developer Implementation Notes:
255 --   Any post-processing required after the insert dml is issued should be
256 --   coded within this procedure. It is important to note that any 3rd party
257 --   maintenance should be reviewed before placing in this procedure.
258 --
259 -- Access Status:
260 --   Internal Row Handler Use Only.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure post_insert(
265 p_effective_date in date,p_rec in ben_erc_shd.g_rec_type) is
266 --
267   l_proc  varchar2(72) := g_package||'post_insert';
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271 --
272   --
273   -- Start of API User Hook for post_insert.
274   --
275   begin
276     --
277     ben_erc_rki.after_insert
278       (
279   p_enrt_rt_ctfn_id            =>p_rec.enrt_rt_ctfn_id
280  ,p_enrt_ctfn_typ_cd              =>p_rec.enrt_ctfn_typ_cd
281  ,p_rqd_flag                      =>p_rec.rqd_flag
282  ,p_enrt_rt_id        =>p_rec.enrt_rt_id
283  ,p_business_group_id             =>p_rec.business_group_id
284  ,p_erc_attribute_category        =>p_rec.erc_attribute_category
285  ,p_erc_attribute1                =>p_rec.erc_attribute1
286  ,p_erc_attribute2                =>p_rec.erc_attribute2
287  ,p_erc_attribute3                =>p_rec.erc_attribute3
288  ,p_erc_attribute4                =>p_rec.erc_attribute4
289  ,p_erc_attribute5                =>p_rec.erc_attribute5
290  ,p_erc_attribute6                =>p_rec.erc_attribute6
291  ,p_erc_attribute7                =>p_rec.erc_attribute7
292  ,p_erc_attribute8                =>p_rec.erc_attribute8
293  ,p_erc_attribute9                =>p_rec.erc_attribute9
294  ,p_erc_attribute10               =>p_rec.erc_attribute10
295  ,p_erc_attribute11               =>p_rec.erc_attribute11
296  ,p_erc_attribute12               =>p_rec.erc_attribute12
297  ,p_erc_attribute13               =>p_rec.erc_attribute13
298  ,p_erc_attribute14               =>p_rec.erc_attribute14
299  ,p_erc_attribute15               =>p_rec.erc_attribute15
300  ,p_erc_attribute16               =>p_rec.erc_attribute16
301  ,p_erc_attribute17               =>p_rec.erc_attribute17
302  ,p_erc_attribute18               =>p_rec.erc_attribute18
303  ,p_erc_attribute19               =>p_rec.erc_attribute19
304  ,p_erc_attribute20               =>p_rec.erc_attribute20
305  ,p_erc_attribute21               =>p_rec.erc_attribute21
306  ,p_erc_attribute22               =>p_rec.erc_attribute22
307  ,p_erc_attribute23               =>p_rec.erc_attribute23
308  ,p_erc_attribute24               =>p_rec.erc_attribute24
309  ,p_erc_attribute25               =>p_rec.erc_attribute25
310  ,p_erc_attribute26               =>p_rec.erc_attribute26
311  ,p_erc_attribute27               =>p_rec.erc_attribute27
312  ,p_erc_attribute28               =>p_rec.erc_attribute28
313  ,p_erc_attribute29               =>p_rec.erc_attribute29
314  ,p_erc_attribute30               =>p_rec.erc_attribute30
315  ,p_request_id                    =>p_rec.request_id
316  ,p_program_application_id        =>p_rec.program_application_id
317  ,p_program_id                    =>p_rec.program_id
318  ,p_program_update_date           =>p_rec.program_update_date
319  ,p_object_version_number         =>p_rec.object_version_number
320  ,p_effective_date                =>p_effective_date
321       );
322     --
323   exception
324     --
325     when hr_api.cannot_find_prog_unit then
326       --
327       hr_api.cannot_find_prog_unit_error
328         (p_module_name => 'ben_enrt_rt_ctfn'
329         ,p_hook_type   => 'AI');
330       --
331   end;
332   --
333   -- End of API User Hook for post_insert.
334   --
335   --
336   hr_utility.set_location(' Leaving:'||l_proc, 10);
337 End post_insert;
338 --
339 -- ----------------------------------------------------------------------------
340 -- |---------------------------------< ins >----------------------------------|
341 -- ----------------------------------------------------------------------------
342 Procedure ins
343   (
344   p_effective_date in date,
345   p_rec        in out nocopy ben_erc_shd.g_rec_type
346   ) is
347 --
348   l_proc  varchar2(72) := g_package||'ins';
349 --
350 Begin
351   hr_utility.set_location('Entering:'||l_proc, 5);
352   --
353   -- Call the supporting insert validate operations
354   --
355   ben_erc_bus.insert_validate(p_rec
356   ,p_effective_date);
357   --
358   -- Call the supporting pre-insert operation
359   --
360   pre_insert(p_rec);
361   --
362   -- Insert the row
363   --
364   insert_dml(p_rec);
365   --
366   -- Call the supporting post-insert operation
367   --
368   post_insert(
369 p_effective_date,p_rec);
370 end ins;
371 --
372 -- ----------------------------------------------------------------------------
373 -- |---------------------------------< ins >----------------------------------|
374 -- ----------------------------------------------------------------------------
375 Procedure ins
376   (
377   p_effective_date in date,
378   p_enrt_rt_ctfn_id           out nocopy number,
379   p_enrt_ctfn_typ_cd             in varchar2,
380   p_rqd_flag                     in varchar2,
381   p_enrt_rt_id       in number           default null,
382   p_business_group_id            in number,
383   p_erc_attribute_category       in varchar2         default null,
384   p_erc_attribute1               in varchar2         default null,
385   p_erc_attribute2               in varchar2         default null,
386   p_erc_attribute3               in varchar2         default null,
387   p_erc_attribute4               in varchar2         default null,
388   p_erc_attribute5               in varchar2         default null,
389   p_erc_attribute6               in varchar2         default null,
390   p_erc_attribute7               in varchar2         default null,
391   p_erc_attribute8               in varchar2         default null,
392   p_erc_attribute9               in varchar2         default null,
393   p_erc_attribute10              in varchar2         default null,
394   p_erc_attribute11              in varchar2         default null,
395   p_erc_attribute12              in varchar2         default null,
396   p_erc_attribute13              in varchar2         default null,
397   p_erc_attribute14              in varchar2         default null,
398   p_erc_attribute15              in varchar2         default null,
399   p_erc_attribute16              in varchar2         default null,
400   p_erc_attribute17              in varchar2         default null,
401   p_erc_attribute18              in varchar2         default null,
402   p_erc_attribute19              in varchar2         default null,
403   p_erc_attribute20              in varchar2         default null,
404   p_erc_attribute21              in varchar2         default null,
405   p_erc_attribute22              in varchar2         default null,
406   p_erc_attribute23              in varchar2         default null,
407   p_erc_attribute24              in varchar2         default null,
408   p_erc_attribute25              in varchar2         default null,
409   p_erc_attribute26              in varchar2         default null,
410   p_erc_attribute27              in varchar2         default null,
411   p_erc_attribute28              in varchar2         default null,
412   p_erc_attribute29              in varchar2         default null,
413   p_erc_attribute30              in varchar2         default null,
414   p_request_id                   in number           default null,
415   p_program_application_id       in number           default null,
416   p_program_id                   in number           default null,
417   p_program_update_date          in date             default null,
418   p_object_version_number        out nocopy number
419   ) is
420 --
421   l_rec	  ben_erc_shd.g_rec_type;
422   l_proc  varchar2(72) := g_package||'ins';
423 --
424 Begin
425   hr_utility.set_location('Entering:'||l_proc, 5);
426   --
427   -- Call conversion function to turn arguments into the
428   -- p_rec structure.
429   --
430   l_rec :=
431   ben_erc_shd.convert_args
432   (
433   null,
434   p_enrt_ctfn_typ_cd,
435   p_rqd_flag,
436   p_enrt_rt_id,
437   p_business_group_id,
438   p_erc_attribute_category,
439   p_erc_attribute1,
440   p_erc_attribute2,
441   p_erc_attribute3,
442   p_erc_attribute4,
443   p_erc_attribute5,
444   p_erc_attribute6,
445   p_erc_attribute7,
446   p_erc_attribute8,
447   p_erc_attribute9,
448   p_erc_attribute10,
449   p_erc_attribute11,
450   p_erc_attribute12,
451   p_erc_attribute13,
452   p_erc_attribute14,
453   p_erc_attribute15,
454   p_erc_attribute16,
455   p_erc_attribute17,
456   p_erc_attribute18,
457   p_erc_attribute19,
458   p_erc_attribute20,
459   p_erc_attribute21,
460   p_erc_attribute22,
461   p_erc_attribute23,
462   p_erc_attribute24,
463   p_erc_attribute25,
464   p_erc_attribute26,
465   p_erc_attribute27,
466   p_erc_attribute28,
467   p_erc_attribute29,
468   p_erc_attribute30,
469   p_request_id,
470   p_program_application_id,
471   p_program_id,
472   p_program_update_date,
473   null
474   );
475   --
476   -- Having converted the arguments into the ben_erc_rec
477   -- plsql record structure we call the corresponding record business process.
478   --
479   ins(
480     p_effective_date,l_rec);
481   --
482   -- As the primary key argument(s)
483   -- are specified as an OUT's we must set these values.
484   --
485   p_enrt_rt_ctfn_id := l_rec.enrt_rt_ctfn_id;
486   p_object_version_number := l_rec.object_version_number;
487   --
488   hr_utility.set_location(' Leaving:'||l_proc, 10);
489 End ins;
490 --
491 end ben_erc_ins;