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