[Home] [Help]
PACKAGE BODY: APPS.PER_ECO_INS
Source
1 Package Body per_eco_ins as
2 /* $Header: peecorhi.pkb 115.7 2002/12/05 10:37:50 pkakar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_eco_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
54 (p_rec in out nocopy per_eco_shd.g_rec_type
55 ) is
56 --
57 l_proc varchar2(72) := g_package||'insert_dml';
58 l_created_by per_election_constituencys.created_by%TYPE;
59 l_creation_date per_election_constituencys.creation_date%TYPE;
60 l_last_update_date per_election_constituencys.last_update_date%TYPE;
61 l_last_updated_by per_election_constituencys.last_updated_by%TYPE;
62 l_last_update_login per_election_constituencys.last_update_login%TYPE;
63 --
64 Begin
65 hr_utility.set_location('Entering:'||l_proc, 5);
66 p_rec.object_version_number := 1; -- Initialise the object version
67 --
68 per_eco_shd.g_api_dml := true; -- Set the api dml status
69 --
70 -- Set the who columns
71 --
72 l_creation_date := sysdate;
73 l_created_by := fnd_global.user_id;
74 l_last_update_date := sysdate;
75 l_last_updated_by := fnd_global.user_id;
76 l_last_update_login := fnd_global.login_id;
77 --
78 -- Insert the row into: per_election_constituencys
79 --
80 hr_utility.set_location('Entering:'||l_proc, 10);
81 insert into per_election_constituencys
82 (election_constituency_id
83 ,election_id
84 ,business_group_id
85 ,constituency_id
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 ,object_version_number
118 ,creation_date
119 ,created_by
120 ,last_update_date
121 ,last_updated_by
122 ,last_update_login
123 )
124 Values
125 (p_rec.election_constituency_id
126 ,p_rec.election_id
127 ,p_rec.business_group_id
128 ,p_rec.constituency_id
129 ,p_rec.attribute_category
130 ,p_rec.attribute1
131 ,p_rec.attribute2
132 ,p_rec.attribute3
133 ,p_rec.attribute4
134 ,p_rec.attribute5
135 ,p_rec.attribute6
136 ,p_rec.attribute7
137 ,p_rec.attribute8
138 ,p_rec.attribute9
139 ,p_rec.attribute10
140 ,p_rec.attribute11
141 ,p_rec.attribute12
145 ,p_rec.attribute16
142 ,p_rec.attribute13
143 ,p_rec.attribute14
144 ,p_rec.attribute15
146 ,p_rec.attribute17
147 ,p_rec.attribute18
148 ,p_rec.attribute19
149 ,p_rec.attribute20
150 ,p_rec.attribute21
151 ,p_rec.attribute22
152 ,p_rec.attribute23
153 ,p_rec.attribute24
154 ,p_rec.attribute25
155 ,p_rec.attribute26
156 ,p_rec.attribute27
157 ,p_rec.attribute28
158 ,p_rec.attribute29
159 ,p_rec.attribute30
160 ,p_rec.object_version_number
161 ,l_creation_date
162 ,l_created_by
163 ,l_last_update_date
164 ,l_last_updated_by
165 ,l_last_update_login
166 );
167 --
168 per_eco_shd.g_api_dml := false; -- Unset the api dml status
169 --
170 hr_utility.set_location(' Leaving:'||l_proc, 10);
171 Exception
172 When hr_api.check_integrity_violated Then
173 hr_utility.set_location(' Leaving:'||l_proc, 11);
174 -- A check constraint has been violated
175 per_eco_shd.g_api_dml := false; -- Unset the api dml status
176 per_eco_shd.constraint_error
177 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
178 When hr_api.parent_integrity_violated Then
179 hr_utility.set_location(' Leaving:'||l_proc, 12);
180 -- Parent integrity has been violated
181 per_eco_shd.g_api_dml := false; -- Unset the api dml status
182 per_eco_shd.constraint_error
183 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
184 When hr_api.unique_integrity_violated Then
185 hr_utility.set_location(' Leaving:'||l_proc, 13);
186 -- Unique integrity has been violated
187 per_eco_shd.g_api_dml := false; -- Unset the api dml status
188 per_eco_shd.constraint_error
189 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
190 When Others Then
191 hr_utility.set_location(' Leaving:'||l_proc, 14);
192 per_eco_shd.g_api_dml := false; -- Unset the api dml status
193 Raise;
194 End insert_dml;
195 --
196 -- ----------------------------------------------------------------------------
197 -- |------------------------------< pre_insert >------------------------------|
198 -- ----------------------------------------------------------------------------
199 -- {Start Of Comments}
200 --
201 -- Description:
202 -- This private procedure contains any processing which is required before
203 -- the insert dml. Presently, if the entity has a corresponding primary
204 -- key which is maintained by an associating sequence, the primary key for
205 -- the entity will be populated with the next sequence value in
206 -- preparation for the insert dml.
207 --
208 -- Prerequisites:
209 -- This is an internal procedure which is called from the ins procedure.
210 --
211 -- In Parameters:
212 -- A Pl/Sql record structre.
213 --
214 -- Post Success:
215 -- Processing continues.
216 --
217 -- Post Failure:
218 -- If an error has occurred, an error message and exception will be raised
219 -- but not handled.
220 --
221 -- Developer Implementation Notes:
222 -- Any pre-processing required before the insert dml is issued should be
223 -- coded within this procedure. As stated above, a good example is the
224 -- generation of a primary key number via a corresponding sequence.
225 -- It is important to note that any 3rd party maintenance should be reviewed
226 -- before placing in this procedure.
227 --
228 -- Access Status:
229 -- Internal Row Handler Use Only.
230 --
231 -- {End Of Comments}
232 -- ----------------------------------------------------------------------------
233 Procedure pre_insert
234 (p_rec in out nocopy per_eco_shd.g_rec_type
235 ) is
236 --
237 l_proc varchar2(72) := g_package||'pre_insert';
238 --
239 Cursor C_Sel1 is select per_election_constituencys_s.nextval from sys.dual;
240 --
241 Begin
242 hr_utility.set_location('Entering:'||l_proc, 5);
243 --
244 --
245 -- Select the next sequence number
246 --
247 Open C_Sel1;
248 Fetch C_Sel1 Into p_rec.election_constituency_id;
249 Close C_Sel1;
250 --
251 hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End pre_insert;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< post_insert >------------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 -- This private procedure contains any processing which is required after the
261 -- insert dml.
262 --
263 -- Prerequisites:
264 -- This is an internal procedure which is called from the ins procedure.
265 --
266 -- In Parameters:
267 -- A Pl/Sql record structre.
268 --
269 -- Post Success:
270 -- Processing continues.
271 --
272 -- Post Failure:
273 -- If an error has occurred, an error message and exception will be raised
274 -- but not handled.
275 --
276 -- Developer Implementation Notes:
277 -- Any post-processing required after the insert dml is issued should be
278 -- coded within this procedure. It is important to note that any 3rd party
279 -- maintenance should be reviewed before placing in this procedure.
280 --
281 -- Access Status:
282 -- Internal Row Handler Use Only.
283 --
284 -- {End Of Comments}
285 -- ----------------------------------------------------------------------------
286 Procedure post_insert
287 (p_effective_date in date
291 l_proc varchar2(72) := g_package||'post_insert';
288 ,p_rec in per_eco_shd.g_rec_type
289 ) is
290 --
292 --
293 Begin
294 hr_utility.set_location('Entering:'||l_proc, 5);
295 begin
296 --
297 per_eco_rki.after_insert
298 (p_effective_date => p_effective_date
299 ,p_election_constituency_id
300 => p_rec.election_constituency_id
301 ,p_election_id
302 => p_rec.election_id
303 ,p_business_group_id
304 => p_rec.business_group_id
305 ,p_constituency_id
306 => p_rec.constituency_id
307 ,p_attribute_category
308 => p_rec.attribute_category
309 ,p_attribute1
310 => p_rec.attribute1
311 ,p_attribute2
312 => p_rec.attribute2
313 ,p_attribute3
314 => p_rec.attribute3
315 ,p_attribute4
316 => p_rec.attribute4
317 ,p_attribute5
318 => p_rec.attribute5
319 ,p_attribute6
320 => p_rec.attribute6
321 ,p_attribute7
322 => p_rec.attribute7
323 ,p_attribute8
324 => p_rec.attribute8
325 ,p_attribute9
326 => p_rec.attribute9
327 ,p_attribute10
328 => p_rec.attribute10
329 ,p_attribute11
330 => p_rec.attribute11
331 ,p_attribute12
332 => p_rec.attribute12
333 ,p_attribute13
334 => p_rec.attribute13
335 ,p_attribute14
336 => p_rec.attribute14
337 ,p_attribute15
338 => p_rec.attribute15
339 ,p_attribute16
340 => p_rec.attribute16
341 ,p_attribute17
342 => p_rec.attribute17
343 ,p_attribute18
344 => p_rec.attribute18
345 ,p_attribute19
346 => p_rec.attribute19
347 ,p_attribute20
348 => p_rec.attribute20
349 ,p_attribute21
350 => p_rec.attribute21
351 ,p_attribute22
352 => p_rec.attribute22
353 ,p_attribute23
354 => p_rec.attribute23
355 ,p_attribute24
356 => p_rec.attribute24
357 ,p_attribute25
358 => p_rec.attribute25
359 ,p_attribute26
360 => p_rec.attribute26
361 ,p_attribute27
362 => p_rec.attribute27
363 ,p_attribute28
364 => p_rec.attribute28
365 ,p_attribute29
366 => p_rec.attribute29
367 ,p_attribute30
368 => p_rec.attribute30
369 ,p_object_version_number
370 => p_rec.object_version_number
371 );
372 --
373 exception
374 --
375 when hr_api.cannot_find_prog_unit then
376 --
377 hr_api.cannot_find_prog_unit_error
378 (p_module_name => 'PER_ELECTION_CONSTITUENCYS'
379 ,p_hook_type => 'AI');
380 --
381 end;
382 --
383 hr_utility.set_location(' Leaving:'||l_proc, 10);
384 End post_insert;
385 --
386 -- ----------------------------------------------------------------------------
387 -- |---------------------------------< ins >----------------------------------|
388 -- ----------------------------------------------------------------------------
389 Procedure ins
390 (p_effective_date in date
391 ,p_validate in boolean default false
392 ,p_rec in out nocopy per_eco_shd.g_rec_type
393 ) is
394 --
395 l_proc varchar2(72) := g_package||'ins';
396 --
397 Begin
398 hr_utility.set_location('Entering:'||l_proc, 5);
399 --
400 -- Determine if the business process is to be validated.
401 --
402 If p_validate then
403 --
404 -- Issue the savepoint.
405 --
406 SAVEPOINT ins_per_eco;
407 End If;
408 --
409 -- Call the supporting insert validate operations
410 --
411 per_eco_bus.insert_validate
412 (p_effective_date
413 ,p_rec
414 );
415 --
416 -- Call the supporting pre-insert operation
417 --
418 per_eco_ins.pre_insert(p_rec);
419 --
420 -- Insert the row
421 --
422 per_eco_ins.insert_dml(p_rec);
423 --
424 -- Call the supporting post-insert operation
425 --
426 per_eco_ins.post_insert
427 (p_effective_date
428 ,p_rec
429 );
430 --
431 --
432 -- If we are validating then raise the Validate_Enabled exception
433 --
434 If p_validate then
435 Raise HR_Api.Validate_Enabled;
436 End If;
437 --
438 hr_utility.set_location(' Leaving:'||l_proc, 10);
439 Exception
440 When HR_Api.Validate_Enabled Then
441 --
442 -- As the Validate_Enabled exception has been raised
443 -- we must rollback to the savepoint
444 --
445 ROLLBACK TO ins_per_elc;
446 --
447 hr_utility.set_location('Leaving:'||l_proc, 20);
448 end ins;
449 --
450 -- ----------------------------------------------------------------------------
451 -- |---------------------------------< ins >----------------------------------|
452 -- ----------------------------------------------------------------------------
453 Procedure ins
454 (p_effective_date in date
455 ,p_election_id in number
456 ,p_business_group_id in number
457 ,p_constituency_id in number
458 ,p_attribute_category in varchar2 default null
459 ,p_attribute1 in varchar2 default null
460 ,p_attribute2 in varchar2 default null
461 ,p_attribute3 in varchar2 default null
462 ,p_attribute4 in varchar2 default null
463 ,p_attribute5 in varchar2 default null
464 ,p_attribute6 in varchar2 default null
465 ,p_attribute7 in varchar2 default null
466 ,p_attribute8 in varchar2 default null
467 ,p_attribute9 in varchar2 default null
468 ,p_attribute10 in varchar2 default null
469 ,p_attribute11 in varchar2 default null
470 ,p_attribute12 in varchar2 default null
471 ,p_attribute13 in varchar2 default null
472 ,p_attribute14 in varchar2 default null
473 ,p_attribute15 in varchar2 default null
474 ,p_attribute16 in varchar2 default null
475 ,p_attribute17 in varchar2 default null
476 ,p_attribute18 in varchar2 default null
477 ,p_attribute19 in varchar2 default null
478 ,p_attribute20 in varchar2 default null
479 ,p_attribute21 in varchar2 default null
480 ,p_attribute22 in varchar2 default null
481 ,p_attribute23 in varchar2 default null
482 ,p_attribute24 in varchar2 default null
483 ,p_attribute25 in varchar2 default null
484 ,p_attribute26 in varchar2 default null
485 ,p_attribute27 in varchar2 default null
486 ,p_attribute28 in varchar2 default null
487 ,p_attribute29 in varchar2 default null
488 ,p_attribute30 in varchar2 default null
489 ,p_validate in boolean default false
490 ,p_election_constituency_id out nocopy number
491 ,p_object_version_number out nocopy number
492 ) is
493 --
494 l_rec per_eco_shd.g_rec_type;
495 l_proc varchar2(72) := g_package||'ins';
496 --
497 Begin
498 hr_utility.set_location('Entering:'||l_proc, 5);
499 --
500 -- Call conversion function to turn arguments into the
501 -- p_rec structure.
502 --
503 l_rec :=
504 per_eco_shd.convert_args
505 (null
506 ,p_election_id
507 ,p_business_group_id
508 ,p_constituency_id
509 ,p_attribute_category
510 ,p_attribute1
511 ,p_attribute2
512 ,p_attribute3
513 ,p_attribute4
514 ,p_attribute5
515 ,p_attribute6
516 ,p_attribute7
517 ,p_attribute8
518 ,p_attribute9
519 ,p_attribute10
520 ,p_attribute11
521 ,p_attribute12
522 ,p_attribute13
523 ,p_attribute14
524 ,p_attribute15
525 ,p_attribute16
526 ,p_attribute17
527 ,p_attribute18
528 ,p_attribute19
529 ,p_attribute20
530 ,p_attribute21
534 ,p_attribute25
531 ,p_attribute22
532 ,p_attribute23
533 ,p_attribute24
535 ,p_attribute26
536 ,p_attribute27
537 ,p_attribute28
538 ,p_attribute29
539 ,p_attribute30
540 ,null
541 );
542 --
543 -- Having converted the arguments into the per_eco_rec
544 -- plsql record structure we call the corresponding record business process.
545 --
546 per_eco_ins.ins
547 (p_effective_date
548 ,p_validate
549 ,l_rec
550 );
551 --
552 -- As the primary key argument(s)
553 -- are specified as an OUT's we must set these values.
554 --
555 p_election_constituency_id := l_rec.election_constituency_id;
556 p_object_version_number := l_rec.object_version_number;
557 --
558 hr_utility.set_location(' Leaving:'||l_proc, 10);
559 End ins;
560 --
561 end per_eco_ins;