1 Package Body ben_bri_ins as
2 /* $Header: bebrirhi.pkb 120.0 2005/05/28 00:51:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bri_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_bri_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_bri_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ben_batch_rate_info
64 --
65 insert into ben_batch_rate_info
66 ( batch_rt_id,
67 benefit_action_id,
68 person_id,
69 pgm_id,
70 pl_id,
71 oipl_id,
72 bnft_rt_typ_cd,
73 dflt_flag,
74 val,
75 old_val,
76 tx_typ_cd,
77 acty_typ_cd,
78 mn_elcn_val,
79 mx_elcn_val,
80 incrmt_elcn_val,
81 dflt_val,
82 rt_strt_dt,
83 business_group_id,
84 object_version_number,
85 enrt_cvg_strt_dt,
86 enrt_cvg_thru_dt,
87 actn_cd,
88 close_actn_itm_dt
89 )
90 Values
91 ( p_rec.batch_rt_id,
92 p_rec.benefit_action_id,
93 p_rec.person_id,
94 p_rec.pgm_id,
95 p_rec.pl_id,
96 p_rec.oipl_id,
97 p_rec.bnft_rt_typ_cd,
98 p_rec.dflt_flag,
99 p_rec.val,
100 p_rec.old_val,
101 p_rec.tx_typ_cd,
102 p_rec.acty_typ_cd,
103 p_rec.mn_elcn_val,
104 p_rec.mx_elcn_val,
105 p_rec.incrmt_elcn_val,
106 p_rec.dflt_val,
107 p_rec.rt_strt_dt,
108 p_rec.business_group_id,
109 p_rec.object_version_number,
110 p_rec.enrt_cvg_strt_dt,
111 p_rec.enrt_cvg_thru_dt,
112 p_rec.actn_cd,
113 p_rec.close_actn_itm_dt
114 );
115 --
116 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
117 --
118 hr_utility.set_location(' Leaving:'||l_proc, 10);
119 Exception
120 When hr_api.check_integrity_violated Then
121 -- A check constraint has been violated
122 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
123 ben_bri_shd.constraint_error
124 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125 When hr_api.parent_integrity_violated Then
126 -- Parent integrity has been violated
127 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
128 ben_bri_shd.constraint_error
129 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
130 When hr_api.unique_integrity_violated Then
131 -- Unique integrity has been violated
132 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
133 ben_bri_shd.constraint_error
134 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
135 When Others Then
136 ben_bri_shd.g_api_dml := false; -- Unset the api dml status
137 Raise;
138 End insert_dml;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |------------------------------< pre_insert >------------------------------|
142 -- ----------------------------------------------------------------------------
143 -- {Start Of Comments}
144 --
145 -- Description:
146 -- This private procedure contains any processing which is required before
147 -- the insert dml. Presently, if the entity has a corresponding primary
148 -- key which is maintained by an associating sequence, the primary key for
149 -- the entity will be populated with the next sequence value in
150 -- preparation for the insert dml.
151 --
152 -- Prerequisites:
153 -- This is an internal procedure which is called from the ins procedure.
154 --
155 -- In Parameters:
156 -- A Pl/Sql record structre.
157 --
158 -- Post Success:
159 -- Processing continues.
160 --
161 -- Post Failure:
162 -- If an error has occurred, an error message and exception will be raised
163 -- but not handled.
164 --
165 -- Developer Implementation Notes:
166 -- Any pre-processing required before the insert dml is issued should be
167 -- coded within this procedure. As stated above, a good example is the
168 -- generation of a primary key number via a corresponding sequence.
169 -- It is important to note that any 3rd party maintenance should be reviewed
170 -- before placing in this procedure.
171 --
172 -- Access Status:
173 -- Internal Row Handler Use Only.
174 --
175 -- {End Of Comments}
176 -- ----------------------------------------------------------------------------
177 Procedure pre_insert(p_rec in out nocopy ben_bri_shd.g_rec_type) is
178 --
179 l_proc varchar2(72) := g_package||'pre_insert';
180 --
181 Cursor C_Sel1 is select ben_batch_rate_info_s.nextval from sys.dual;
182 --
183 Begin
184 hr_utility.set_location('Entering:'||l_proc, 5);
185 --
186 --
187 -- Select the next sequence number
188 --
189 Open C_Sel1;
190 Fetch C_Sel1 Into p_rec.batch_rt_id;
191 Close C_Sel1;
192 --
193 hr_utility.set_location(' Leaving:'||l_proc, 10);
194 End pre_insert;
195 --
196 -- ----------------------------------------------------------------------------
197 -- |-----------------------------< post_insert >------------------------------|
198 -- ----------------------------------------------------------------------------
199 -- {Start Of Comments}
200 --
201 -- Description:
202 -- This private procedure contains any processing which is required after the
203 -- insert dml.
204 --
205 -- Prerequisites:
206 -- This is an internal procedure which is called from the ins procedure.
207 --
208 -- In Parameters:
209 -- A Pl/Sql record structre.
210 --
211 -- Post Success:
212 -- Processing continues.
213 --
214 -- Post Failure:
215 -- If an error has occurred, an error message and exception will be raised
216 -- but not handled.
217 --
218 -- Developer Implementation Notes:
219 -- Any post-processing required after the insert dml is issued should be
220 -- coded within this procedure. It is important to note that any 3rd party
221 -- maintenance should be reviewed before placing in this procedure.
222 --
223 -- Access Status:
224 -- Internal Row Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure post_insert(p_effective_date in date,
229 p_rec in ben_bri_shd.g_rec_type) is
230 --
231 l_proc varchar2(72) := g_package||'post_insert';
232 --
233 Begin
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 --
236 --
237 -- Start of API User Hook for post_insert.
238 --
239 begin
240 --
241 ben_bri_rki.after_insert
242 (p_batch_rt_id =>p_rec.batch_rt_id
243 ,p_benefit_action_id =>p_rec.benefit_action_id
244 ,p_person_id =>p_rec.person_id
245 ,p_pgm_id =>p_rec.pgm_id
246 ,p_pl_id =>p_rec.pl_id
247 ,p_oipl_id =>p_rec.oipl_id
248 ,p_bnft_rt_typ_cd =>p_rec.bnft_rt_typ_cd
249 ,p_dflt_flag =>p_rec.dflt_flag
250 ,p_val =>p_rec.val
251 ,p_old_val =>p_rec.old_val
252 ,p_tx_typ_cd =>p_rec.tx_typ_cd
253 ,p_acty_typ_cd =>p_rec.acty_typ_cd
254 ,p_mn_elcn_val =>p_rec.mn_elcn_val
255 ,p_mx_elcn_val =>p_rec.mx_elcn_val
256 ,p_incrmt_elcn_val =>p_rec.incrmt_elcn_val
257 ,p_dflt_val =>p_rec.dflt_val
258 ,p_rt_strt_dt =>p_rec.rt_strt_dt
259 ,p_business_group_id =>p_rec.business_group_id
260 ,p_object_version_number =>p_rec.object_version_number
261 ,p_enrt_cvg_strt_dt =>p_rec.enrt_cvg_strt_dt
262 ,p_enrt_cvg_thru_dt =>p_rec.enrt_cvg_thru_dt
263 ,p_actn_cd =>p_rec.actn_cd
264 ,p_close_actn_itm_dt =>p_rec.close_actn_itm_dt
265 ,p_effective_date =>p_effective_date);
266 --
267 exception
268 --
269 when hr_api.cannot_find_prog_unit then
270 --
271 hr_api.cannot_find_prog_unit_error
272 (p_module_name => 'ben_batch_rate_info'
273 ,p_hook_type => 'AI');
274 --
275 end;
276 --
277 -- End of API User Hook for post_insert.
278 --
279 --
280 hr_utility.set_location(' Leaving:'||l_proc, 10);
281 End post_insert;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------------< ins >----------------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure ins
287 (
288 p_effective_date in date,
289 p_rec in out nocopy ben_bri_shd.g_rec_type
290 ) is
291 --
292 l_proc varchar2(72) := g_package||'ins';
293 --
294 Begin
295 hr_utility.set_location('Entering:'||l_proc, 5);
296 --
297 -- Call the supporting insert validate operations
298 --
299 ben_bri_bus.insert_validate(p_rec,p_effective_date);
300 --
301 -- Call the supporting pre-insert operation
302 --
303 pre_insert(p_rec);
304 --
305 -- Insert the row
306 --
307 insert_dml(p_rec);
308 --
309 -- Call the supporting post-insert operation
310 --
311 post_insert(p_effective_date,p_rec);
312 --
313 end ins;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |---------------------------------< ins >----------------------------------|
317 -- ----------------------------------------------------------------------------
318 Procedure ins
319 (
320 p_effective_date in date,
321 p_batch_rt_id out nocopy number,
322 p_benefit_action_id in number,
323 p_person_id in number,
324 p_pgm_id in number default null,
325 p_pl_id in number default null,
326 p_oipl_id in number default null,
327 p_bnft_rt_typ_cd in varchar2 default null,
328 p_dflt_flag in varchar2,
329 p_val in number default null,
330 p_old_val in number default null,
331 p_tx_typ_cd in varchar2 default null,
332 p_acty_typ_cd in varchar2 default null,
333 p_mn_elcn_val in number default null,
334 p_mx_elcn_val in number default null,
335 p_incrmt_elcn_val in number default null,
336 p_dflt_val in number default null,
337 p_rt_strt_dt in date default null,
338 p_business_group_id in number,
339 p_object_version_number out nocopy number,
340 p_enrt_cvg_strt_dt in date default null,
341 p_enrt_cvg_thru_dt in date default null,
342 p_actn_cd in varchar2 default null,
343 p_close_actn_itm_dt in date default null
344 ) is
345 --
346 l_rec ben_bri_shd.g_rec_type;
347 l_proc varchar2(72) := g_package||'ins';
348 --
349 Begin
350 hr_utility.set_location('Entering:'||l_proc, 5);
351 --
352 -- Call conversion function to turn arguments into the
353 -- p_rec structure.
354 --
355 l_rec :=
356 ben_bri_shd.convert_args
357 (
358 null,
359 p_benefit_action_id,
360 p_person_id,
361 p_pgm_id,
362 p_pl_id,
363 p_oipl_id,
364 p_bnft_rt_typ_cd,
365 p_dflt_flag,
366 p_val,
367 p_old_val,
368 p_tx_typ_cd,
369 p_acty_typ_cd,
370 p_mn_elcn_val,
371 p_mx_elcn_val,
372 p_incrmt_elcn_val,
373 p_dflt_val,
374 p_rt_strt_dt,
375 p_business_group_id,
376 null,
377 p_enrt_cvg_strt_dt,
378 p_enrt_cvg_thru_dt,
379 p_actn_cd,
380 p_close_actn_itm_dt
381 );
382 --
383 -- Having converted the arguments into the ben_bri_rec
384 -- plsql record structure we call the corresponding record business process.
385 --
386 ins(p_effective_date,l_rec);
387 --
388 -- As the primary key argument(s)
389 -- are specified as an OUT's we must set these values.
390 --
391 p_batch_rt_id := l_rec.batch_rt_id;
392 p_object_version_number := l_rec.object_version_number;
393 --
394 hr_utility.set_location(' Leaving:'||l_proc, 10);
395 End ins;
396 --
397 end ben_bri_ins;