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