DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XCL_INS

Source


1 Package Body ben_xcl_ins as
2 /* $Header: bexclrhi.pkb 115.7 2002/12/24 21:28:21 rpillay ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xcl_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_xcl_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_xcl_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_ext_chg_evt_log
64   --
65   insert into ben_ext_chg_evt_log
66   (	ext_chg_evt_log_id,
67 	chg_evt_cd,
68 	chg_eff_dt,
69 	chg_user_id,
70 	prmtr_01,
71 	prmtr_02,
72 	prmtr_03,
73 	prmtr_04,
74 	prmtr_05,
75 	prmtr_06,
76 	prmtr_07,
77 	prmtr_08,
78 	prmtr_09,
79 	prmtr_10,
80 	person_id,
81 	business_group_id,
82 	object_version_number,
83         chg_actl_dt,
84         new_val1,
85         new_val2,
86         new_val3,
87         new_val4,
88         new_val5,
89         new_val6,
90         old_val1,
91         old_val2,
92         old_val3,
93         old_val4,
94         old_val5,
95         old_val6
96   )
97   Values
98   (	p_rec.ext_chg_evt_log_id,
99 	p_rec.chg_evt_cd,
100 	p_rec.chg_eff_dt,
101 	p_rec.chg_user_id,
102 	p_rec.prmtr_01,
103 	p_rec.prmtr_02,
104 	p_rec.prmtr_03,
105 	p_rec.prmtr_04,
106 	p_rec.prmtr_05,
107 	p_rec.prmtr_06,
108 	p_rec.prmtr_07,
109 	p_rec.prmtr_08,
110 	p_rec.prmtr_09,
111 	p_rec.prmtr_10,
112 	p_rec.person_id,
113 	p_rec.business_group_id,
114 	p_rec.object_version_number,
115         p_rec.chg_actl_dt,
116         p_rec.new_val1,
117         p_rec.new_val2,
118         p_rec.new_val3,
119         p_rec.new_val4,
120         p_rec.new_val5,
121         p_rec.new_val6,
122         p_rec.old_val1,
123         p_rec.old_val2,
124         p_rec.old_val3,
125         p_rec.old_val4,
126         p_rec.old_val5,
127         p_rec.old_val6
128   );
129   --
130   ben_xcl_shd.g_api_dml := false;   -- Unset the api dml status
131   --
132   hr_utility.set_location(' Leaving:'||l_proc, 10);
133 Exception
134   When hr_api.check_integrity_violated Then
135     -- A check constraint has been violated
136     ben_xcl_shd.g_api_dml := false;   -- Unset the api dml status
137     ben_xcl_shd.constraint_error
138       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
139   When hr_api.parent_integrity_violated Then
140     -- Parent integrity has been violated
141     ben_xcl_shd.g_api_dml := false;   -- Unset the api dml status
142     ben_xcl_shd.constraint_error
143       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
144   When hr_api.unique_integrity_violated Then
145     -- Unique integrity has been violated
146     ben_xcl_shd.g_api_dml := false;   -- Unset the api dml status
147     ben_xcl_shd.constraint_error
148       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
149   When Others Then
150     ben_xcl_shd.g_api_dml := false;   -- Unset the api dml status
151     Raise;
152 End insert_dml;
153 --
154 -- ----------------------------------------------------------------------------
155 -- |------------------------------< pre_insert >------------------------------|
156 -- ----------------------------------------------------------------------------
157 -- {Start Of Comments}
158 --
159 -- Description:
160 --   This private procedure contains any processing which is required before
161 --   the insert dml. Presently, if the entity has a corresponding primary
162 --   key which is maintained by an associating sequence, the primary key for
163 --   the entity will be populated with the next sequence value in
164 --   preparation for the insert dml.
165 --
166 -- Prerequisites:
167 --   This is an internal procedure which is called from the ins procedure.
168 --
169 -- In Parameters:
170 --   A Pl/Sql record structre.
171 --
172 -- Post Success:
173 --   Processing continues.
174 --
175 -- Post Failure:
176 --   If an error has occurred, an error message and exception will be raised
177 --   but not handled.
178 --
179 -- Developer Implementation Notes:
180 --   Any pre-processing required before the insert dml is issued should be
181 --   coded within this procedure. As stated above, a good example is the
182 --   generation of a primary key number via a corresponding sequence.
183 --   It is important to note that any 3rd party maintenance should be reviewed
184 --   before placing in this procedure.
185 --
186 -- Access Status:
187 --   Internal Row Handler Use Only.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure pre_insert(p_rec  in out nocopy ben_xcl_shd.g_rec_type) is
192 --
193   l_proc  varchar2(72) := g_package||'pre_insert';
194 --
195 cursor c1 is
196   select ben_ext_chg_evt_log_s.nextval from sys.dual;
197 --
198 --
199 Begin
200   hr_utility.set_location('Entering:'||l_proc, 5);
201   --
202   open c1;
203   Fetch c1 Into p_rec.ext_chg_evt_log_id;
204   close c1;
205   --
206   --
207   hr_utility.set_location(' Leaving:'||l_proc, 10);
208 End pre_insert;
209 --
210 -- ----------------------------------------------------------------------------
211 -- |-----------------------------< post_insert >------------------------------|
212 -- ----------------------------------------------------------------------------
213 -- {Start Of Comments}
214 --
215 -- Description:
216 --   This private procedure contains any processing which is required after the
217 --   insert dml.
218 --
219 -- Prerequisites:
220 --   This is an internal procedure which is called from the ins procedure.
221 --
222 -- In Parameters:
223 --   A Pl/Sql record structre.
224 --
225 -- Post Success:
226 --   Processing continues.
227 --
228 -- Post Failure:
229 --   If an error has occurred, an error message and exception will be raised
230 --   but not handled.
231 --
232 -- Developer Implementation Notes:
233 --   Any post-processing required after the insert dml is issued should be
234 --   coded within this procedure. It is important to note that any 3rd party
235 --   maintenance should be reviewed before placing in this procedure.
236 --
237 -- Access Status:
238 --   Internal Row Handler Use Only.
239 --
240 -- {End Of Comments}
241 -- ----------------------------------------------------------------------------
242 Procedure post_insert(
243 p_effective_date in date,p_rec in ben_xcl_shd.g_rec_type) is
244 --
245   l_proc  varchar2(72) := g_package||'post_insert';
246 --
247 Begin
248   hr_utility.set_location('Entering:'||l_proc, 5);
249 --
250   --
251   -- Start of API User Hook for post_insert.
252   --
253   begin
254     --
255     ben_xcl_rki.after_insert
256       (
257   p_ext_chg_evt_log_id            =>p_rec.ext_chg_evt_log_id
258  ,p_chg_evt_cd                    =>p_rec.chg_evt_cd
259  ,p_chg_eff_dt                    =>p_rec.chg_eff_dt
260  ,p_chg_user_id                   =>p_rec.chg_user_id
261  ,p_prmtr_01                      =>p_rec.prmtr_01
262  ,p_prmtr_02                      =>p_rec.prmtr_02
263  ,p_prmtr_03                      =>p_rec.prmtr_03
264  ,p_prmtr_04                      =>p_rec.prmtr_04
265  ,p_prmtr_05                      =>p_rec.prmtr_05
266  ,p_prmtr_06                      =>p_rec.prmtr_06
267  ,p_prmtr_07                      =>p_rec.prmtr_07
268  ,p_prmtr_08                      =>p_rec.prmtr_08
269  ,p_prmtr_09                      =>p_rec.prmtr_09
270  ,p_prmtr_10                      =>p_rec.prmtr_10
271  ,p_person_id                     =>p_rec.person_id
272  ,p_business_group_id             =>p_rec.business_group_id
273  ,p_object_version_number         =>p_rec.object_version_number
274  ,p_effective_date                =>p_effective_date
275  ,p_chg_actl_dt                   =>p_rec.chg_actl_dt
276  ,p_new_val1                      =>p_rec.new_val1
277  ,p_new_val2                      =>p_rec.new_val2
278  ,p_new_val3                      =>p_rec.new_val3
279  ,p_new_val4                      =>p_rec.new_val4
280  ,p_new_val5                      =>p_rec.new_val5
281  ,p_new_val6                      =>p_rec.new_val6
282  ,p_old_val1                      =>p_rec.old_val1
283  ,p_old_val2                      =>p_rec.old_val2
284  ,p_old_val3                      =>p_rec.old_val3
285  ,p_old_val4                      =>p_rec.old_val4
286  ,p_old_val5                      =>p_rec.old_val5
287  ,p_old_val6                      =>p_rec.old_val6
288       );
289     --
290   exception
291     --
292     when hr_api.cannot_find_prog_unit then
293       --
294       hr_api.cannot_find_prog_unit_error
295         (p_module_name => 'ben_ext_chg_evt_log'
296         ,p_hook_type   => 'AI');
297       --
298   end;
299   --
300   -- End of API User Hook for post_insert.
301   --
302   --
303   hr_utility.set_location(' Leaving:'||l_proc, 10);
304 End post_insert;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< ins >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure ins
310   (
311   p_effective_date in date,
312   p_rec        in out nocopy ben_xcl_shd.g_rec_type
313   ) is
314 --
315   l_proc  varchar2(72) := g_package||'ins';
316 --
317 Begin
318   hr_utility.set_location('Entering:'||l_proc, 5);
319   --
320   -- Call the supporting insert validate operations
321   --
322   ben_xcl_bus.insert_validate(p_rec
323   ,p_effective_date);
324   --
325   -- Call the supporting pre-insert operation
326   --
327   pre_insert(p_rec);
328   --
329   -- Insert the row
330   --
331   insert_dml(p_rec);
332   --
333   -- Call the supporting post-insert operation
334   --
335   post_insert(
336 p_effective_date,p_rec);
337 end ins;
338 --
339 -- ----------------------------------------------------------------------------
340 -- |---------------------------------< ins >----------------------------------|
341 -- ----------------------------------------------------------------------------
342 Procedure ins
343   (
344   p_effective_date in date,
345   p_ext_chg_evt_log_id           out nocopy number,
346   p_chg_evt_cd                   in varchar2,
347   p_chg_eff_dt                   in date,
348   p_chg_user_id                  in number           default null,
349   p_prmtr_01                     in varchar2         default null,
350   p_prmtr_02                     in varchar2         default null,
351   p_prmtr_03                     in varchar2         default null,
352   p_prmtr_04                     in varchar2         default null,
353   p_prmtr_05                     in varchar2         default null,
354   p_prmtr_06                     in varchar2         default null,
355   p_prmtr_07                     in varchar2         default null,
356   p_prmtr_08                     in varchar2         default null,
357   p_prmtr_09                     in varchar2         default null,
358   p_prmtr_10                     in varchar2         default null,
359   p_person_id                    in number,
360   p_business_group_id            in number,
361   p_object_version_number        out nocopy number,
362   p_chg_actl_dt                  in date,
363   p_new_val1                     in varchar2         default null,
364   p_new_val2                     in varchar2         default null,
365   p_new_val3                     in varchar2         default null,
366   p_new_val4                     in varchar2         default null,
367   p_new_val5                     in varchar2         default null,
368   p_new_val6                     in varchar2         default null,
369   p_old_val1                     in varchar2         default null,
370   p_old_val2                     in varchar2         default null,
371   p_old_val3                     in varchar2         default null,
372   p_old_val4                     in varchar2         default null,
373   p_old_val5                     in varchar2         default null,
374   p_old_val6                     in varchar2         default null
375   ) is
376 --
377   l_rec	  ben_xcl_shd.g_rec_type;
378   l_proc  varchar2(72) := g_package||'ins';
379 --
380 Begin
381   hr_utility.set_location('Entering:'||l_proc, 5);
382   --
383   -- Call conversion function to turn arguments into the
384   -- p_rec structure.
385   --
386   l_rec :=
387   ben_xcl_shd.convert_args
388   (
389   null,
390   p_chg_evt_cd,
391   p_chg_eff_dt,
392   p_chg_user_id,
393   p_prmtr_01,
394   p_prmtr_02,
395   p_prmtr_03,
396   p_prmtr_04,
397   p_prmtr_05,
398   p_prmtr_06,
399   p_prmtr_07,
400   p_prmtr_08,
401   p_prmtr_09,
402   p_prmtr_10,
403   p_person_id,
404   p_business_group_id,
405   null,
406   p_chg_actl_dt,
407   p_new_val1,
408   p_new_val2,
409   p_new_val3,
410   p_new_val4,
411   p_new_val5,
412   p_new_val6,
413   p_old_val1,
414   p_old_val2,
415   p_old_val3,
416   p_old_val4,
417   p_old_val5,
418   p_old_val6
419   );
420   --
421   -- Having converted the arguments into the ben_xcl_rec
422   -- plsql record structure we call the corresponding record business process.
423   --
424   ins(
425     p_effective_date,l_rec);
426   --
427   -- As the primary key argument(s)
428   -- are specified as an OUT's we must set these values.
429   --
430   p_ext_chg_evt_log_id := l_rec.ext_chg_evt_log_id;
431   p_object_version_number := l_rec.object_version_number;
432   --
433   hr_utility.set_location(' Leaving:'||l_proc, 10);
434 End ins;
435 --
436 end ben_xcl_ins;