1 Package Body hxc_ter_ins as
2 /* $Header: hxcterrhi.pkb 120.2 2005/09/23 09:19:47 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_ter_ins.'; -- Global package name
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |------------------------------< insert_dml >------------------------------|
14 -- ----------------------------------------------------------------------------
15 -- {Start Of Comments}
16 --
17 -- Description:
18 -- This procedure controls the actual dml insert logic. The processing of
19 -- this procedure are as follows:
20 -- 1) Initialise the object_version_number to 1 if the object_version_number
21 -- is defined as an attribute for this entity.
22 -- 2) To set and unset the g_api_dml status as required (as we are about to
23 -- perform dml).
24 -- 3) To insert the row into the schema.
25 -- 4) To trap any constraint violations that may have occurred.
26 -- 5) To raise any other errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the ins
30 -- procedure and must have all mandatory attributes set (except the
31 -- object_version_number which is initialised within this procedure).
32 --
33 -- In Parameters:
34 -- A Pl/Sql record structre.
35 --
36 -- Post Success:
37 -- The specified row will be inserted into the schema.
38 --
39 -- Post Failure:
40 -- On the insert dml failure it is important to note that we always reset the
41 -- g_api_dml status to false.
42 -- If a check, unique or parent integrity constraint violation is raised the
43 -- constraint_error procedure will be called.
44 -- If any other error is reported, the error will be raised after the
45 -- g_api_dml status is reset.
46 --
47 -- Developer Implementation Notes:
48 -- None.
49 --
50 -- Access Status:
51 -- Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure insert_dml
56 (p_rec in out nocopy hxc_ter_shd.g_rec_type
57 ) is
58 --
59 l_proc varchar2(72);
60 --
61 Begin
62
63
64 if g_debug then
65 l_proc := g_package||'insert_dml';
66 hr_utility.set_location('Entering:'||l_proc, 5);
67 end if;
68 p_rec.object_version_number := 1; -- Initialise the object version
69 --
70 hxc_ter_shd.g_api_dml := true; -- Set the api dml status
71 --
72 -- Insert the row into: hxc_time_entry_rules
73 --
74 insert into hxc_time_entry_rules
75 (time_entry_rule_id
76 ,name
77 ,business_group_id
78 ,legislation_code
79 ,rule_usage
80 ,mapping_id
81 ,formula_id
82 ,description
83 ,start_date
84 ,end_date
85 ,object_version_number
86 ,attribute_category
87 ,attribute1
88 ,attribute2
89 ,attribute3
90 ,attribute4
91 ,attribute5
92 ,attribute6
93 ,attribute7
94 ,attribute8
95 ,attribute9
96 ,attribute10
97 ,attribute11
98 ,attribute12
99 ,attribute13
100 ,attribute14
101 ,attribute15
102 ,attribute16
103 ,attribute17
104 ,attribute18
105 ,attribute19
106 ,attribute20
107 ,attribute21
108 ,attribute22
109 ,attribute23
110 ,attribute24
111 ,attribute25
112 ,attribute26
113 ,attribute27
114 ,attribute28
115 ,attribute29
116 ,attribute30
117 ,creation_date
118 ,created_by
119 ,last_updated_by
120 ,last_update_date
121 ,last_update_login
122 )
123 Values
124 (p_rec.time_entry_rule_id
125 ,p_rec.name
126 ,p_rec.business_group_id
127 ,p_rec.legislation_code
128 ,p_rec.rule_usage
129 ,p_rec.mapping_id
130 ,p_rec.formula_id
131 ,p_rec.description
132 ,p_rec.start_date
133 ,p_rec.end_date
134 ,p_rec.object_version_number
135 ,p_rec.attribute_category
136 ,p_rec.attribute1
137 ,p_rec.attribute2
138 ,p_rec.attribute3
139 ,p_rec.attribute4
140 ,p_rec.attribute5
141 ,p_rec.attribute6
142 ,p_rec.attribute7
143 ,p_rec.attribute8
144 ,p_rec.attribute9
145 ,p_rec.attribute10
146 ,p_rec.attribute11
147 ,p_rec.attribute12
148 ,p_rec.attribute13
149 ,p_rec.attribute14
150 ,p_rec.attribute15
151 ,p_rec.attribute16
152 ,p_rec.attribute17
153 ,p_rec.attribute18
154 ,p_rec.attribute19
155 ,p_rec.attribute20
156 ,p_rec.attribute21
157 ,p_rec.attribute22
158 ,p_rec.attribute23
159 ,p_rec.attribute24
160 ,p_rec.attribute25
161 ,p_rec.attribute26
162 ,p_rec.attribute27
163 ,p_rec.attribute28
164 ,p_rec.attribute29
165 ,p_rec.attribute30
166 ,sysdate
167 ,fnd_global.user_id
168 ,fnd_global.user_id
169 ,sysdate
170 ,fnd_global.login_id
171 );
172 --
173 if g_debug then
174 hr_utility.trace('error is '||SUBSTR(SQLERRM,1,60));
175 end if;
176 hxc_ter_shd.g_api_dml := false; -- Unset the api dml status
177 --
178 if g_debug then
179 hr_utility.set_location(' Leaving:'||l_proc, 10);
180 end if;
181 Exception
182 When hr_api.check_integrity_violated Then
183 if g_debug then
184 hr_utility.trace('error is '||SUBSTR(SQLERRM,1,60));
185 end if;
186 -- A check constraint has been violated
187 hxc_ter_shd.g_api_dml := false; -- Unset the api dml status
188 hxc_ter_shd.constraint_error
189 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
190 When hr_api.parent_integrity_violated Then
191 -- Parent integrity has been violated
192 if g_debug then
193 hr_utility.trace('error is '||SUBSTR(SQLERRM,1,60));
194 end if;
195 hxc_ter_shd.g_api_dml := false; -- Unset the api dml status
196 hxc_ter_shd.constraint_error
197 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
198 When hr_api.unique_integrity_violated Then
199 -- Unique integrity has been violated
200 if g_debug then
201 hr_utility.trace('error is '||SUBSTR(SQLERRM,1,60));
202 end if;
203 hxc_ter_shd.g_api_dml := false; -- Unset the api dml status
204 hxc_ter_shd.constraint_error
205 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
206 When Others Then
207 if g_debug then
208 hr_utility.trace('error is '||SUBSTR(SQLERRM,1,60));
209 end if;
210 hxc_ter_shd.g_api_dml := false; -- Unset the api dml status
211 Raise;
212 End insert_dml;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |------------------------------< pre_insert >------------------------------|
216 -- ----------------------------------------------------------------------------
217 -- {Start Of Comments}
218 --
219 -- Description:
220 -- This private procedure contains any processing which is required before
221 -- the insert dml. Presently, if the entity has a corresponding primary
222 -- key which is maintained by an associating sequence, the primary key for
223 -- the entity will be populated with the next sequence value in
224 -- preparation for the insert dml.
225 --
226 -- Prerequisites:
227 -- This is an internal procedure which is called from the ins procedure.
228 --
229 -- In Parameters:
230 -- A Pl/Sql record structre.
231 --
232 -- Post Success:
233 -- Processing continues.
234 --
235 -- Post Failure:
236 -- If an error has occurred, an error message and exception will be raised
237 -- but not handled.
238 --
239 -- Developer Implementation Notes:
240 -- Any pre-processing required before the insert dml is issued should be
241 -- coded within this procedure. As stated above, a good example is the
242 -- generation of a primary key number via a corresponding sequence.
243 -- It is important to note that any 3rd party maintenance should be reviewed
244 -- before placing in this procedure.
245 --
246 -- Access Status:
247 -- Internal Row Handler Use Only.
248 --
249 -- {End Of Comments}
250 -- ----------------------------------------------------------------------------
251 Procedure pre_insert
252 (p_rec in out nocopy hxc_ter_shd.g_rec_type
253 ) is
254 --
255 l_proc varchar2(72);
256 --
257 Cursor C_Sel1 is select hxc_time_entry_rules_s.nextval from sys.dual;
258 --
259 Begin
260
261
262 if g_debug then
263 l_proc := g_package||'pre_insert';
264 hr_utility.set_location('Entering:'||l_proc, 5);
265 end if;
266 --
267 --
268 -- Select the next sequence number
269 --
270 Open C_Sel1;
271 Fetch C_Sel1 Into p_rec.time_entry_rule_id;
272 Close C_Sel1;
273 --
274 if g_debug then
275 hr_utility.set_location(' Leaving:'||l_proc, 10);
276 end if;
277 End pre_insert;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |-----------------------------< post_insert >------------------------------|
281 -- ----------------------------------------------------------------------------
282 -- {Start Of Comments}
283 --
284 -- Description:
285 -- This private procedure contains any processing which is required after the
286 -- insert dml.
287 --
288 -- Prerequisites:
289 -- This is an internal procedure which is called from the ins procedure.
290 --
291 -- In Parameters:
292 -- A Pl/Sql record structre.
293 --
294 -- Post Success:
295 -- Processing continues.
296 --
297 -- Post Failure:
298 -- If an error has occurred, an error message and exception will be raised
299 -- but not handled.
300 --
301 -- Developer Implementation Notes:
302 -- Any post-processing required after the insert dml is issued should be
303 -- coded within this procedure. It is important to note that any 3rd party
304 -- maintenance should be reviewed before placing in this procedure.
305 --
306 -- Access Status:
307 -- Internal Row Handler Use Only.
308 --
309 -- {End Of Comments}
310 -- ----------------------------------------------------------------------------
311 Procedure post_insert
312 (p_effective_date in date
313 ,p_rec in hxc_ter_shd.g_rec_type
314 ) is
315 --
316 l_proc varchar2(72);
317 --
318 Begin
319
320
321 if g_debug then
322 l_proc := g_package||'post_insert';
323 hr_utility.set_location('Entering:'||l_proc, 5);
324 end if;
325 begin
326 --
327 hxc_ter_rki.after_insert
328 (p_effective_date => p_effective_date
329 ,p_time_entry_rule_id => p_rec.time_entry_rule_id
330 ,p_name => p_rec.name
331 ,p_business_group_id => p_rec.business_group_id
332 ,p_legislation_code => p_rec.legislation_code
333 ,p_rule_usage => p_rec.rule_usage
334 ,p_formula_id => p_rec.formula_id
335 ,p_mapping_id => p_rec.mapping_id
336 ,p_description => p_rec.description
337 ,p_start_date => p_rec.start_date
338 ,p_end_date => p_rec.end_date
339 ,p_object_version_number => p_rec.object_version_number
340 ,p_attribute_category
341 => p_rec.attribute_category
342 ,p_attribute1
343 => p_rec.attribute1
344 ,p_attribute2
345 => p_rec.attribute2
346 ,p_attribute3
347 => p_rec.attribute3
348 ,p_attribute4
349 => p_rec.attribute4
350 ,p_attribute5
351 => p_rec.attribute5
352 ,p_attribute6
353 => p_rec.attribute6
354 ,p_attribute7
355 => p_rec.attribute7
356 ,p_attribute8
357 => p_rec.attribute8
358 ,p_attribute9
359 => p_rec.attribute9
360 ,p_attribute10
361 => p_rec.attribute10
362 ,p_attribute11
363 => p_rec.attribute11
364 ,p_attribute12
365 => p_rec.attribute12
366 ,p_attribute13
367 => p_rec.attribute13
368 ,p_attribute14
369 => p_rec.attribute14
370 ,p_attribute15
371 => p_rec.attribute15
372 ,p_attribute16
373 => p_rec.attribute16
374 ,p_attribute17
375 => p_rec.attribute17
376 ,p_attribute18
377 => p_rec.attribute18
378 ,p_attribute19
379 => p_rec.attribute19
380 ,p_attribute20
381 => p_rec.attribute20
382 ,p_attribute21
383 => p_rec.attribute21
384 ,p_attribute22
385 => p_rec.attribute22
386 ,p_attribute23
387 => p_rec.attribute23
388 ,p_attribute24
389 => p_rec.attribute24
390 ,p_attribute25
391 => p_rec.attribute25
392 ,p_attribute26
393 => p_rec.attribute26
394 ,p_attribute27
395 => p_rec.attribute27
396 ,p_attribute28
397 => p_rec.attribute28
398 ,p_attribute29
399 => p_rec.attribute29
400 ,p_attribute30
401 => p_rec.attribute30
402 );
403 --
404 exception
405 --
406 when hr_api.cannot_find_prog_unit then
407 --
408 hr_api.cannot_find_prog_unit_error
409 (p_module_name => 'HXC_TIME_ENTRY_RULES'
410 ,p_hook_type => 'AI');
411 --
412 end;
413 --
414 if g_debug then
415 hr_utility.set_location(' Leaving:'||l_proc, 10);
416 end if;
417 End post_insert;
418 --
419 -- ----------------------------------------------------------------------------
420 -- |---------------------------------< ins >----------------------------------|
421 -- ----------------------------------------------------------------------------
422 Procedure ins
423 (p_effective_date in date
424 ,p_rec in out nocopy hxc_ter_shd.g_rec_type
425 ) is
426 --
427 l_proc varchar2(72);
428 --
429 Begin
430 g_debug := hr_utility.debug_enabled;
431
432 if g_debug then
433 l_proc := g_package||'ins';
434 hr_utility.set_location('Entering:'||l_proc, 5);
435 end if;
436 --
437 -- Call the supporting insert validate operations
438 --
439 hxc_ter_bus.insert_validate
440 (p_effective_date
441 ,p_rec
442 );
443 --
444 -- Call the supporting pre-insert operation
445 --
446 hxc_ter_ins.pre_insert(p_rec);
447 --
448 -- Insert the row
449 --
450 hxc_ter_ins.insert_dml(p_rec);
451 --
452 -- Call the supporting post-insert operation
453 --
454 hxc_ter_ins.post_insert
455 (p_effective_date
456 ,p_rec
457 );
458 --
459 if g_debug then
460 hr_utility.set_location('Leaving:'||l_proc, 20);
461 end if;
462 end ins;
463 --
464 -- ----------------------------------------------------------------------------
465 -- |---------------------------------< ins >----------------------------------|
466 -- ----------------------------------------------------------------------------
467 Procedure ins
468 (p_effective_date in date
469 ,p_name in varchar2
470 ,p_business_group_id in number default null
471 ,p_legislation_code in varchar2 default null
472 ,p_rule_usage in varchar2
473 ,p_start_date in date
474 ,p_mapping_id in number default null
475 ,p_formula_id in number default null
476 ,p_description in varchar2 default null
477 ,p_end_date in date default null
478 ,p_time_entry_rule_id out nocopy number
479 ,p_object_version_number out nocopy number
480 ,p_attribute_category in varchar2 default null
481 ,p_attribute1 in varchar2 default null
482 ,p_attribute2 in varchar2 default null
483 ,p_attribute3 in varchar2 default null
484 ,p_attribute4 in varchar2 default null
485 ,p_attribute5 in varchar2 default null
486 ,p_attribute6 in varchar2 default null
487 ,p_attribute7 in varchar2 default null
488 ,p_attribute8 in varchar2 default null
489 ,p_attribute9 in varchar2 default null
490 ,p_attribute10 in varchar2 default null
491 ,p_attribute11 in varchar2 default null
492 ,p_attribute12 in varchar2 default null
493 ,p_attribute13 in varchar2 default null
494 ,p_attribute14 in varchar2 default null
495 ,p_attribute15 in varchar2 default null
496 ,p_attribute16 in varchar2 default null
497 ,p_attribute17 in varchar2 default null
498 ,p_attribute18 in varchar2 default null
499 ,p_attribute19 in varchar2 default null
500 ,p_attribute20 in varchar2 default null
501 ,p_attribute21 in varchar2 default null
502 ,p_attribute22 in varchar2 default null
503 ,p_attribute23 in varchar2 default null
504 ,p_attribute24 in varchar2 default null
505 ,p_attribute25 in varchar2 default null
506 ,p_attribute26 in varchar2 default null
507 ,p_attribute27 in varchar2 default null
508 ,p_attribute28 in varchar2 default null
509 ,p_attribute29 in varchar2 default null
510 ,p_attribute30 in varchar2 default null
511 ) is
512 --
513 l_rec hxc_ter_shd.g_rec_type;
514 l_proc varchar2(72);
515 --
516 Begin
517 g_debug := hr_utility.debug_enabled;
518
519 if g_debug then
520 l_proc := g_package||'ins';
521 hr_utility.set_location('Entering:'||l_proc, 5);
522 end if;
523 --
524 -- Call conversion function to turn arguments into the
525 -- p_rec structure.
526 --
527 l_rec :=
528 hxc_ter_shd.convert_args
529 (null
530 ,p_name
531 ,p_business_group_id
532 ,p_legislation_code
533 ,p_rule_usage
534 ,p_mapping_id
535 ,p_formula_id
536 ,p_description
537 ,p_start_date
538 ,p_end_date
539 ,null
540 ,p_attribute_category
541 ,p_attribute1
542 ,p_attribute2
543 ,p_attribute3
544 ,p_attribute4
545 ,p_attribute5
546 ,p_attribute6
547 ,p_attribute7
548 ,p_attribute8
549 ,p_attribute9
550 ,p_attribute10
551 ,p_attribute11
552 ,p_attribute12
553 ,p_attribute13
554 ,p_attribute14
555 ,p_attribute15
556 ,p_attribute16
557 ,p_attribute17
558 ,p_attribute18
559 ,p_attribute19
560 ,p_attribute20
561 ,p_attribute21
562 ,p_attribute22
563 ,p_attribute23
564 ,p_attribute24
565 ,p_attribute25
566 ,p_attribute26
567 ,p_attribute27
568 ,p_attribute28
569 ,p_attribute29
570 ,p_attribute30
571 );
572 --
573 -- Having converted the arguments into the hxc_ter_rec
574 -- plsql record structure we call the corresponding record business process.
575 --
576 hxc_ter_ins.ins
577 (p_effective_date
578 ,l_rec
579 );
580 --
581 -- As the primary key argument(s)
582 -- are specified as an OUT's we must set these values.
583 --
584 p_time_entry_rule_id := l_rec.time_entry_rule_id;
585 p_object_version_number := l_rec.object_version_number;
586 --
587 if g_debug then
588 hr_utility.set_location(' Leaving:'||l_proc, 10);
589 end if;
590 End ins;
591 --
592 end hxc_ter_ins;