1 Package Body ben_yrp_ins as
2 /* $Header: beyrprhi.pkb 120.0 2005/05/28 12:44:45 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_yrp_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_yrp_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_yrp_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ben_yr_perd
64 --
65 insert into ben_yr_perd
66 ( yr_perd_id,
67 perds_in_yr_num,
68 perd_tm_uom_cd,
72 lmtn_yr_strt_dt,
69 perd_typ_cd,
70 end_date,
71 start_date,
73 lmtn_yr_end_dt,
74 business_group_id,
75 yrp_attribute_category,
76 yrp_attribute1,
77 yrp_attribute2,
78 yrp_attribute3,
79 yrp_attribute4,
80 yrp_attribute5,
81 yrp_attribute6,
82 yrp_attribute7,
83 yrp_attribute8,
84 yrp_attribute9,
85 yrp_attribute10,
86 yrp_attribute11,
87 yrp_attribute12,
88 yrp_attribute13,
89 yrp_attribute14,
90 yrp_attribute15,
91 yrp_attribute16,
92 yrp_attribute17,
93 yrp_attribute18,
94 yrp_attribute19,
95 yrp_attribute20,
96 yrp_attribute21,
97 yrp_attribute22,
98 yrp_attribute23,
99 yrp_attribute24,
100 yrp_attribute25,
101 yrp_attribute26,
102 yrp_attribute27,
103 yrp_attribute28,
104 yrp_attribute29,
105 yrp_attribute30,
106 object_version_number
107 )
108 Values
109 ( p_rec.yr_perd_id,
110 p_rec.perds_in_yr_num,
111 p_rec.perd_tm_uom_cd,
112 p_rec.perd_typ_cd,
113 p_rec.end_date,
114 p_rec.start_date,
115 p_rec.lmtn_yr_strt_dt,
116 p_rec.lmtn_yr_end_dt,
117 p_rec.business_group_id,
118 p_rec.yrp_attribute_category,
119 p_rec.yrp_attribute1,
120 p_rec.yrp_attribute2,
121 p_rec.yrp_attribute3,
122 p_rec.yrp_attribute4,
123 p_rec.yrp_attribute5,
124 p_rec.yrp_attribute6,
125 p_rec.yrp_attribute7,
126 p_rec.yrp_attribute8,
127 p_rec.yrp_attribute9,
128 p_rec.yrp_attribute10,
129 p_rec.yrp_attribute11,
130 p_rec.yrp_attribute12,
131 p_rec.yrp_attribute13,
132 p_rec.yrp_attribute14,
133 p_rec.yrp_attribute15,
134 p_rec.yrp_attribute16,
135 p_rec.yrp_attribute17,
136 p_rec.yrp_attribute18,
137 p_rec.yrp_attribute19,
138 p_rec.yrp_attribute20,
139 p_rec.yrp_attribute21,
140 p_rec.yrp_attribute22,
141 p_rec.yrp_attribute23,
142 p_rec.yrp_attribute24,
143 p_rec.yrp_attribute25,
144 p_rec.yrp_attribute26,
145 p_rec.yrp_attribute27,
146 p_rec.yrp_attribute28,
147 p_rec.yrp_attribute29,
148 p_rec.yrp_attribute30,
149 p_rec.object_version_number
150 );
151 --
152 ben_yrp_shd.g_api_dml := false; -- Unset the api dml status
153 --
154 hr_utility.set_location(' Leaving:'||l_proc, 10);
155 Exception
156 When hr_api.check_integrity_violated Then
157 -- A check constraint has been violated
158 ben_yrp_shd.g_api_dml := false; -- Unset the api dml status
159 ben_yrp_shd.constraint_error
160 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
161 When hr_api.parent_integrity_violated Then
162 -- Parent integrity has been violated
163 ben_yrp_shd.g_api_dml := false; -- Unset the api dml status
164 ben_yrp_shd.constraint_error
165 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
166 When hr_api.unique_integrity_violated Then
167 -- Unique integrity has been violated
168 ben_yrp_shd.g_api_dml := false; -- Unset the api dml status
169 ben_yrp_shd.constraint_error
170 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
171 When Others Then
172 ben_yrp_shd.g_api_dml := false; -- Unset the api dml status
173 Raise;
174 End insert_dml;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |------------------------------< pre_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 -- This private procedure contains any processing which is required before
183 -- the insert dml. Presently, if the entity has a corresponding primary
184 -- key which is maintained by an associating sequence, the primary key for
185 -- the entity will be populated with the next sequence value in
186 -- preparation for the insert dml.
187 --
188 -- Prerequisites:
189 -- This is an internal procedure which is called from the ins procedure.
190 --
191 -- In Parameters:
192 -- A Pl/Sql record structre.
193 --
194 -- Post Success:
195 -- Processing continues.
196 --
197 -- Post Failure:
198 -- If an error has occurred, an error message and exception will be raised
199 -- but not handled.
200 --
201 -- Developer Implementation Notes:
202 -- Any pre-processing required before the insert dml is issued should be
203 -- coded within this procedure. As stated above, a good example is the
204 -- generation of a primary key number via a corresponding sequence.
205 -- It is important to note that any 3rd party maintenance should be reviewed
206 -- before placing in this procedure.
207 --
208 -- Access Status:
209 -- Internal Row Handler Use Only.
210 --
211 -- {End Of Comments}
212 -- ----------------------------------------------------------------------------
213 Procedure pre_insert(p_rec in out nocopy ben_yrp_shd.g_rec_type) is
214 --
215 l_proc varchar2(72) := g_package||'pre_insert';
216 cursor c is
217 select ben_yr_perd_s.nextval from sys.dual;
218 --
219 --
220 --
221 Begin
222 hr_utility.set_location('Entering:'||l_proc, 5);
223 open c;
224 fetch c into p_rec.yr_perd_id;
225 close c;
226 --
227 --
228 --
229 hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End pre_insert;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |-----------------------------< post_insert >------------------------------|
234 -- ----------------------------------------------------------------------------
235 -- {Start Of Comments}
239 -- insert dml.
236 --
237 -- Description:
238 -- This private procedure contains any processing which is required after the
240 --
241 -- Prerequisites:
242 -- This is an internal procedure which is called from the ins procedure.
243 --
244 -- In Parameters:
245 -- A Pl/Sql record structre.
246 --
247 -- Post Success:
248 -- Processing continues.
249 --
250 -- Post Failure:
251 -- If an error has occurred, an error message and exception will be raised
252 -- but not handled.
253 --
254 -- Developer Implementation Notes:
255 -- Any post-processing required after the insert dml is issued should be
256 -- coded within this procedure. It is important to note that any 3rd party
257 -- maintenance should be reviewed before placing in this procedure.
258 --
259 -- Access Status:
260 -- Internal Row Handler Use Only.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure post_insert(
265 p_effective_date in date,p_rec in ben_yrp_shd.g_rec_type) is
266 --
267 l_proc varchar2(72) := g_package||'post_insert';
268 --
269 Begin
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 --
272 --
273 -- Start of API User Hook for post_insert.
274 --
275 begin
276 --
277 ben_yrp_rki.after_insert
278 (
279 p_yr_perd_id =>p_rec.yr_perd_id
280 ,p_perds_in_yr_num =>p_rec.perds_in_yr_num
281 ,p_perd_tm_uom_cd =>p_rec.perd_tm_uom_cd
282 ,p_perd_typ_cd =>p_rec.perd_typ_cd
283 ,p_end_date =>p_rec.end_date
284 ,p_start_date =>p_rec.start_date
285 ,p_lmtn_yr_strt_dt =>p_rec.lmtn_yr_strt_dt
286 ,p_lmtn_yr_end_dt =>p_rec.lmtn_yr_end_dt
287 ,p_business_group_id =>p_rec.business_group_id
288 ,p_yrp_attribute_category =>p_rec.yrp_attribute_category
289 ,p_yrp_attribute1 =>p_rec.yrp_attribute1
290 ,p_yrp_attribute2 =>p_rec.yrp_attribute2
291 ,p_yrp_attribute3 =>p_rec.yrp_attribute3
292 ,p_yrp_attribute4 =>p_rec.yrp_attribute4
293 ,p_yrp_attribute5 =>p_rec.yrp_attribute5
294 ,p_yrp_attribute6 =>p_rec.yrp_attribute6
295 ,p_yrp_attribute7 =>p_rec.yrp_attribute7
296 ,p_yrp_attribute8 =>p_rec.yrp_attribute8
297 ,p_yrp_attribute9 =>p_rec.yrp_attribute9
298 ,p_yrp_attribute10 =>p_rec.yrp_attribute10
299 ,p_yrp_attribute11 =>p_rec.yrp_attribute11
300 ,p_yrp_attribute12 =>p_rec.yrp_attribute12
301 ,p_yrp_attribute13 =>p_rec.yrp_attribute13
302 ,p_yrp_attribute14 =>p_rec.yrp_attribute14
303 ,p_yrp_attribute15 =>p_rec.yrp_attribute15
304 ,p_yrp_attribute16 =>p_rec.yrp_attribute16
305 ,p_yrp_attribute17 =>p_rec.yrp_attribute17
306 ,p_yrp_attribute18 =>p_rec.yrp_attribute18
307 ,p_yrp_attribute19 =>p_rec.yrp_attribute19
308 ,p_yrp_attribute20 =>p_rec.yrp_attribute20
309 ,p_yrp_attribute21 =>p_rec.yrp_attribute21
310 ,p_yrp_attribute22 =>p_rec.yrp_attribute22
311 ,p_yrp_attribute23 =>p_rec.yrp_attribute23
312 ,p_yrp_attribute24 =>p_rec.yrp_attribute24
313 ,p_yrp_attribute25 =>p_rec.yrp_attribute25
314 ,p_yrp_attribute26 =>p_rec.yrp_attribute26
315 ,p_yrp_attribute27 =>p_rec.yrp_attribute27
316 ,p_yrp_attribute28 =>p_rec.yrp_attribute28
317 ,p_yrp_attribute29 =>p_rec.yrp_attribute29
318 ,p_yrp_attribute30 =>p_rec.yrp_attribute30
319 ,p_object_version_number =>p_rec.object_version_number
320 ,p_effective_date =>p_effective_date
321 );
322 --
323 exception
324 --
325 when hr_api.cannot_find_prog_unit then
326 --
327 hr_api.cannot_find_prog_unit_error
328 (p_module_name => 'ben_yr_perd'
329 ,p_hook_type => 'AI');
330 --
331 end;
332 --
333 -- End of API User Hook for post_insert.
334 --
335 --
336 hr_utility.set_location(' Leaving:'||l_proc, 10);
337 End post_insert;
338 --
339 -- ----------------------------------------------------------------------------
340 -- |---------------------------------< ins >----------------------------------|
341 -- ----------------------------------------------------------------------------
342 Procedure ins
343 (
344 p_effective_date in date,
345 p_rec in out nocopy ben_yrp_shd.g_rec_type
346 ) is
347 --
348 l_proc varchar2(72) := g_package||'ins';
349 --
350 Begin
351 hr_utility.set_location('Entering:'||l_proc, 5);
352 --
353 -- Call the supporting insert validate operations
354 --
355 ben_yrp_bus.insert_validate(p_rec
356 ,p_effective_date);
357 --
358 -- Call the supporting pre-insert operation
359 --
360 pre_insert(p_rec);
361 --
362 -- Insert the row
363 --
364 insert_dml(p_rec);
365 --
366 -- Call the supporting post-insert operation
367 --
368 post_insert(
369 p_effective_date,p_rec);
370 end ins;
371 --
372 -- ----------------------------------------------------------------------------
373 -- |---------------------------------< ins >----------------------------------|
374 -- ----------------------------------------------------------------------------
375 Procedure ins
376 (
377 p_effective_date in date,
378 p_yr_perd_id out nocopy number,
379 p_perds_in_yr_num in number default null,
380 p_perd_tm_uom_cd in varchar2 default null,
381 p_perd_typ_cd in varchar2 default null,
382 p_end_date in date,
383 p_start_date in date,
384 p_lmtn_yr_strt_dt in date default null,
385 p_lmtn_yr_end_dt in date default null,
386 p_business_group_id in number,
387 p_yrp_attribute_category in varchar2 default null,
388 p_yrp_attribute1 in varchar2 default null,
389 p_yrp_attribute2 in varchar2 default null,
390 p_yrp_attribute3 in varchar2 default null,
391 p_yrp_attribute4 in varchar2 default null,
392 p_yrp_attribute5 in varchar2 default null,
393 p_yrp_attribute6 in varchar2 default null,
394 p_yrp_attribute7 in varchar2 default null,
395 p_yrp_attribute8 in varchar2 default null,
396 p_yrp_attribute9 in varchar2 default null,
397 p_yrp_attribute10 in varchar2 default null,
398 p_yrp_attribute11 in varchar2 default null,
399 p_yrp_attribute12 in varchar2 default null,
400 p_yrp_attribute13 in varchar2 default null,
401 p_yrp_attribute14 in varchar2 default null,
402 p_yrp_attribute15 in varchar2 default null,
403 p_yrp_attribute16 in varchar2 default null,
404 p_yrp_attribute17 in varchar2 default null,
405 p_yrp_attribute18 in varchar2 default null,
406 p_yrp_attribute19 in varchar2 default null,
407 p_yrp_attribute20 in varchar2 default null,
408 p_yrp_attribute21 in varchar2 default null,
409 p_yrp_attribute22 in varchar2 default null,
410 p_yrp_attribute23 in varchar2 default null,
411 p_yrp_attribute24 in varchar2 default null,
412 p_yrp_attribute25 in varchar2 default null,
413 p_yrp_attribute26 in varchar2 default null,
414 p_yrp_attribute27 in varchar2 default null,
415 p_yrp_attribute28 in varchar2 default null,
416 p_yrp_attribute29 in varchar2 default null,
417 p_yrp_attribute30 in varchar2 default null,
418 p_object_version_number out nocopy number
419 ) is
420 --
421 l_rec ben_yrp_shd.g_rec_type;
422 l_proc varchar2(72) := g_package||'ins';
423 --
424 Begin
425 hr_utility.set_location('Entering:'||l_proc, 5);
426 --
427 -- Call conversion function to turn arguments into the
428 -- p_rec structure.
429 --
430 l_rec :=
431 ben_yrp_shd.convert_args
432 (
433 null,
434 p_perds_in_yr_num,
435 p_perd_tm_uom_cd,
436 p_perd_typ_cd,
437 p_end_date,
438 p_start_date,
439 p_lmtn_yr_strt_dt,
440 p_lmtn_yr_end_dt,
441 p_business_group_id,
442 p_yrp_attribute_category,
443 p_yrp_attribute1,
444 p_yrp_attribute2,
445 p_yrp_attribute3,
446 p_yrp_attribute4,
447 p_yrp_attribute5,
448 p_yrp_attribute6,
449 p_yrp_attribute7,
450 p_yrp_attribute8,
451 p_yrp_attribute9,
452 p_yrp_attribute10,
453 p_yrp_attribute11,
454 p_yrp_attribute12,
455 p_yrp_attribute13,
456 p_yrp_attribute14,
457 p_yrp_attribute15,
458 p_yrp_attribute16,
459 p_yrp_attribute17,
460 p_yrp_attribute18,
461 p_yrp_attribute19,
462 p_yrp_attribute20,
463 p_yrp_attribute21,
464 p_yrp_attribute22,
465 p_yrp_attribute23,
466 p_yrp_attribute24,
467 p_yrp_attribute25,
468 p_yrp_attribute26,
469 p_yrp_attribute27,
470 p_yrp_attribute28,
471 p_yrp_attribute29,
472 p_yrp_attribute30,
473 null
474 );
475 --
476 -- Having converted the arguments into the ben_yrp_rec
477 -- plsql record structure we call the corresponding record business process.
478 --
479 ins(
480 p_effective_date,l_rec);
481 --
482 -- As the primary key argument(s)
483 -- are specified as an OUT's we must set these values.
484 --
485 p_yr_perd_id := l_rec.yr_perd_id;
486 p_object_version_number := l_rec.object_version_number;
487 --
488 hr_utility.set_location(' Leaving:'||l_proc, 10);
489 End ins;
490 --
491 end ben_yrp_ins;