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