[Home] [Help]
PACKAGE BODY: APPS.PER_POD_INS
Source
1 Package Body per_pod_ins as
2 /* $Header: pepodrhi.pkb 115.6 2002/12/04 10:56:05 eumenyio ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_pod_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 functions of
17 -- this procedure are as follows:
18 -- 1) To set and unset the g_api_dml status as required (as we are about to
19 -- perform dml).
20 -- 2) To insert the row into the schema.
21 -- 3) To trap any constraint violations that may have occurred.
22 -- 4) To raise any other errors.
23 --
24 -- Pre Conditions:
25 -- This is an internal private procedure which must be called from the ins
26 -- procedure and must have all mandatory arguments set.
27 --
28 -- In Arguments:
29 -- A Pl/Sql record structre.
30 --
31 -- Post Success:
32 -- The specified row will be inserted into the schema.
33 --
34 -- Post Failure:
35 -- On the insert dml failure it is important to note that we always reset the
36 -- g_api_dml status to false.
37 -- If a check, unique or parent integrity constraint violation is raised the
38 -- constraint_error procedure will be called.
39 -- If any other error is reported, the error will be raised after the
40 -- g_api_dml status is reset.
41 --
42 -- Developer Implementation Notes:
43 -- None.
44 --
45 -- Access Status:
46 -- Internal Table Handler Use Only.
47 --
48 -- {End Of Comments}
49 -- ----------------------------------------------------------------------------
50 Procedure insert_dml(p_rec in out nocopy per_pod_shd.g_rec_type) is
51 --
52 l_proc varchar2(72) := g_package||'insert_dml';
53 --
54 Begin
55 hr_utility.set_location('Entering:'||l_proc, 5);
56 --
57 per_pod_shd.g_api_dml := true; -- Set the api dml status
58 --
59 -- Insert the row into: per_position_definitions
60 --
61 insert into per_position_definitions
62 ( position_definition_id,
63 id_flex_num,
64 summary_flag,
65 enabled_flag,
66 start_date_active,
67 end_date_active,
68 segment1,
69 segment2,
70 segment3,
71 segment4,
72 segment5,
73 segment6,
74 segment7,
75 segment8,
76 segment9,
77 segment10,
78 segment11,
79 segment12,
80 segment13,
81 segment14,
82 segment15,
83 segment16,
84 segment17,
85 segment18,
86 segment19,
87 segment20,
88 segment21,
89 segment22,
90 segment23,
91 segment24,
92 segment25,
93 segment26,
94 segment27,
95 segment28,
96 segment29,
97 segment30
98 )
99 Values
100 ( p_rec.position_definition_id,
101 p_rec.id_flex_num,
102 p_rec.summary_flag,
103 p_rec.enabled_flag,
104 p_rec.start_date_active,
105 p_rec.end_date_active,
106 p_rec.segment1,
107 p_rec.segment2,
108 p_rec.segment3,
109 p_rec.segment4,
110 p_rec.segment5,
111 p_rec.segment6,
112 p_rec.segment7,
113 p_rec.segment8,
114 p_rec.segment9,
115 p_rec.segment10,
116 p_rec.segment11,
117 p_rec.segment12,
118 p_rec.segment13,
119 p_rec.segment14,
120 p_rec.segment15,
121 p_rec.segment16,
122 p_rec.segment17,
123 p_rec.segment18,
124 p_rec.segment19,
125 p_rec.segment20,
126 p_rec.segment21,
127 p_rec.segment22,
128 p_rec.segment23,
129 p_rec.segment24,
130 p_rec.segment25,
131 p_rec.segment26,
132 p_rec.segment27,
133 p_rec.segment28,
134 p_rec.segment29,
135 p_rec.segment30
136 );
137 --
138 per_pod_shd.g_api_dml := false; -- Unset the api dml status
139 --
140 hr_utility.set_location(' Leaving:'||l_proc, 10);
141 Exception
142 When hr_api.check_integrity_violated Then
143 -- A check constraint has been violated
144 per_pod_shd.g_api_dml := false; -- Unset the api dml status
145 per_pod_shd.constraint_error
146 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
147 When hr_api.parent_integrity_violated Then
148 -- Parent integrity has been violated
149 per_pod_shd.g_api_dml := false; -- Unset the api dml status
150 per_pod_shd.constraint_error
151 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
152 When hr_api.unique_integrity_violated Then
153 -- Unique integrity has been violated
154 per_pod_shd.g_api_dml := false; -- Unset the api dml status
155 per_pod_shd.constraint_error
156 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
157 When Others Then
158 per_pod_shd.g_api_dml := false; -- Unset the api dml status
159 Raise;
160 End insert_dml;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |------------------------------< pre_insert >------------------------------|
164 -- ----------------------------------------------------------------------------
165 -- {Start Of Comments}
166 --
167 -- Description:
168 -- This private procedure contains any processing which is required before
169 -- the insert dml. Presently, if the entity has a corresponding primary
170 -- key which is maintained by an associating sequence, the primary key for
171 -- the entity will be populated with the next sequence value in
172 -- preparation for the insert dml.
173 --
174 -- Pre Conditions:
175 -- This is an internal procedure which is called from the ins procedure.
176 --
177 -- In Arguments:
178 -- A Pl/Sql record structre.
179 --
180 -- Post Success:
181 -- Processing continues.
182 --
183 -- Post Failure:
184 -- If an error has occurred, an error message and exception will be raised
185 -- but not handled.
186 --
187 -- Developer Implementation Notes:
188 -- Any pre-processing required before the insert dml is issued should be
189 -- coded within this procedure. As stated above, a good example is the
190 -- generation of a primary key number via a corresponding sequence.
191 -- It is important to note that any 3rd party maintenance should be reviewed
192 -- before placing in this procedure.
193 --
194 -- Access Status:
195 -- Internal Table Handler Use Only.
196 --
197 -- {End Of Comments}
198 -- ----------------------------------------------------------------------------
199 Procedure pre_insert(p_rec in out nocopy per_pod_shd.g_rec_type) is
200 --
201 l_proc varchar2(72) := g_package||'pre_insert';
202 --
203 Cursor C_Sel1 is select per_position_definitions_s.nextval from sys.dual;
204 --
205 Begin
206 hr_utility.set_location('Entering:'||l_proc, 5);
207 --
208 --
209 -- Select the next sequence number
210 --
211 Open C_Sel1;
212 Fetch C_Sel1 Into p_rec.position_definition_id;
213 Close C_Sel1;
214 --
215 --
216 -- initialise the hardcode flexfield specific attributes:
217 --
218 p_rec.summary_flag := 'N';
219 p_rec.enabled_flag := 'Y';
220 p_rec.start_date_active := null;
221 p_rec.end_date_active := null;
222 --
223 hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End pre_insert;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< post_insert >------------------------------|
228 -- ----------------------------------------------------------------------------
229 -- {Start Of Comments}
230 --
231 -- Description:
232 -- This private procedure contains any processing which is required after the
233 -- insert dml.
234 --
235 -- Pre Conditions:
236 -- This is an internal procedure which is called from the ins procedure.
237 --
238 -- In Arguments:
239 -- A Pl/Sql record structre.
240 --
241 -- Post Success:
242 -- Processing continues.
243 --
244 -- Post Failure:
245 -- If an error has occurred, an error message and exception will be raised
246 -- but not handled.
247 --
248 -- Developer Implementation Notes:
249 -- Any post-processing required after the insert dml is issued should be
250 -- coded within this procedure. It is important to note that any 3rd party
251 -- maintenance should be reviewed before placing in this procedure.
252 --
253 -- Access Status:
254 -- Internal Table Handler Use Only.
255 --
256 -- {End Of Comments}
257 -- ----------------------------------------------------------------------------
258 Procedure post_insert(p_rec in per_pod_shd.g_rec_type) is
259 --
260 l_proc varchar2(72) := g_package||'post_insert';
261 --
262 Begin
263 hr_utility.set_location('Entering:'||l_proc, 5);
264 --
265 hr_utility.set_location(' Leaving:'||l_proc, 10);
266 End post_insert;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |---------------------------------< ins >----------------------------------|
270 -- ----------------------------------------------------------------------------
271 Procedure ins
272 (
273 p_rec in out nocopy per_pod_shd.g_rec_type,
274 p_validate in boolean default false
275 ) is
276 --
277 l_proc varchar2(72) := g_package||'ins';
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- Determine if the business process is to be validated.
283 --
284 If p_validate then
285 --
286 -- Issue the savepoint.
287 --
288 SAVEPOINT ins_per_pod;
289 End If;
290 --
291 -- Call the supporting insert validate operations
292 --
293 per_pod_bus.insert_validate(p_rec);
294 --
295 -- Call the supporting pre-insert operation
296 --
297 pre_insert(p_rec);
298 --
299 -- Insert the row
300 --
301 insert_dml(p_rec);
302 --
303 -- Call the supporting post-insert operation
304 --
305 post_insert(p_rec);
306 --
307 -- If we are validating then raise the Validate_Enabled exception
308 --
309 If p_validate then
310 Raise HR_Api.Validate_Enabled;
311 End If;
312 --
313 hr_utility.set_location(' Leaving:'||l_proc, 10);
314 Exception
315 When HR_Api.Validate_Enabled Then
316 --
317 -- As the Validate_Enabled exception has been raised
318 -- we must rollback to the savepoint
319 --
320 ROLLBACK TO ins_per_pod;
321 end ins;
322 --
323 -- ----------------------------------------------------------------------------
324 -- |---------------------------------< ins >----------------------------------|
325 -- ----------------------------------------------------------------------------
326 Procedure ins
327 (
328 p_position_definition_id out nocopy number,
329 p_id_flex_num in number,
330 p_summary_flag in varchar2,
331 p_enabled_flag in varchar2,
332 p_start_date_active in date default null,
333 p_end_date_active in date default null,
334 p_segment1 in varchar2 default null,
335 p_segment2 in varchar2 default null,
336 p_segment3 in varchar2 default null,
337 p_segment4 in varchar2 default null,
338 p_segment5 in varchar2 default null,
339 p_segment6 in varchar2 default null,
340 p_segment7 in varchar2 default null,
341 p_segment8 in varchar2 default null,
342 p_segment9 in varchar2 default null,
343 p_segment10 in varchar2 default null,
344 p_segment11 in varchar2 default null,
345 p_segment12 in varchar2 default null,
346 p_segment13 in varchar2 default null,
347 p_segment14 in varchar2 default null,
348 p_segment15 in varchar2 default null,
349 p_segment16 in varchar2 default null,
350 p_segment17 in varchar2 default null,
351 p_segment18 in varchar2 default null,
352 p_segment19 in varchar2 default null,
353 p_segment20 in varchar2 default null,
354 p_segment21 in varchar2 default null,
355 p_segment22 in varchar2 default null,
356 p_segment23 in varchar2 default null,
357 p_segment24 in varchar2 default null,
358 p_segment25 in varchar2 default null,
359 p_segment26 in varchar2 default null,
360 p_segment27 in varchar2 default null,
361 p_segment28 in varchar2 default null,
362 p_segment29 in varchar2 default null,
363 p_segment30 in varchar2 default null,
364 p_validate in boolean default false
365 ) is
366 --
367 l_rec per_pod_shd.g_rec_type;
368 l_proc varchar2(72) := g_package||'ins';
369 --
370 Begin
371 hr_utility.set_location('Entering:'||l_proc, 5);
372 --
373 -- Call conversion function to turn arguments into the
374 -- p_rec structure.
375 --
376 l_rec :=
377 per_pod_shd.convert_args
378 (
379 null,
380 p_id_flex_num,
381 p_summary_flag,
382 p_enabled_flag,
383 p_start_date_active,
384 p_end_date_active,
385 p_segment1,
386 p_segment2,
387 p_segment3,
388 p_segment4,
389 p_segment5,
390 p_segment6,
391 p_segment7,
392 p_segment8,
393 p_segment9,
394 p_segment10,
395 p_segment11,
396 p_segment12,
397 p_segment13,
398 p_segment14,
399 p_segment15,
400 p_segment16,
401 p_segment17,
402 p_segment18,
403 p_segment19,
404 p_segment20,
405 p_segment21,
406 p_segment22,
407 p_segment23,
408 p_segment24,
409 p_segment25,
410 p_segment26,
411 p_segment27,
412 p_segment28,
413 p_segment29,
414 p_segment30
415 );
416 --
417 -- Having converted the arguments into the per_pod_rec
418 -- plsql record structure we call the corresponding record business process.
419 --
420 ins(l_rec, p_validate);
421 --
422 -- As the primary key argument(s)
423 -- are specified as an OUT's we must set these values.
424 --
425 p_position_definition_id := l_rec.position_definition_id;
426 --
427 hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End ins;
429 --
430 -- ----------------------------------------------------------------------------
431 -- |-------------------------------< ins_or_sel >-----------------------------|
432 -- ----------------------------------------------------------------------------
433 procedure ins_or_sel
434 (p_segment1 in varchar2 default null,
435 p_segment2 in varchar2 default null,
436 p_segment3 in varchar2 default null,
440 p_segment7 in varchar2 default null,
437 p_segment4 in varchar2 default null,
438 p_segment5 in varchar2 default null,
439 p_segment6 in varchar2 default null,
441 p_segment8 in varchar2 default null,
442 p_segment9 in varchar2 default null,
443 p_segment10 in varchar2 default null,
444 p_segment11 in varchar2 default null,
445 p_segment12 in varchar2 default null,
446 p_segment13 in varchar2 default null,
447 p_segment14 in varchar2 default null,
448 p_segment15 in varchar2 default null,
449 p_segment16 in varchar2 default null,
450 p_segment17 in varchar2 default null,
451 p_segment18 in varchar2 default null,
452 p_segment19 in varchar2 default null,
453 p_segment20 in varchar2 default null,
454 p_segment21 in varchar2 default null,
455 p_segment22 in varchar2 default null,
456 p_segment23 in varchar2 default null,
457 p_segment24 in varchar2 default null,
458 p_segment25 in varchar2 default null,
459 p_segment26 in varchar2 default null,
460 p_segment27 in varchar2 default null,
461 p_segment28 in varchar2 default null,
462 p_segment29 in varchar2 default null,
463 p_segment30 in varchar2 default null,
464 p_business_group_id in number,
465 p_position_definition_id out nocopy number,
466 p_name out nocopy varchar2,
467 p_validate in boolean default false) is
468 --
469 l_position_definition_id number;
470 l_id_flex_num number;
471 l_proc varchar2(72) := g_package||'ins_or_sel';
472 --
473 --
474 begin
475 hr_utility.set_location('Entering:'||l_proc, 5);
476 --
477 -- determine if a people group combination exists
478 --
479 per_pod_shd.segment_combination_check
480 (p_segment1 => p_segment1,
481 p_segment2 => p_segment2,
482 p_segment3 => p_segment3,
483 p_segment4 => p_segment4,
484 p_segment5 => p_segment5,
485 p_segment6 => p_segment6,
486 p_segment7 => p_segment7,
487 p_segment8 => p_segment8,
488 p_segment9 => p_segment9,
489 p_segment10 => p_segment10,
490 p_segment11 => p_segment11,
491 p_segment12 => p_segment12,
492 p_segment13 => p_segment13,
493 p_segment14 => p_segment14,
494 p_segment15 => p_segment15,
495 p_segment16 => p_segment16,
496 p_segment17 => p_segment17,
497 p_segment18 => p_segment18,
498 p_segment19 => p_segment19,
499 p_segment20 => p_segment20,
500 p_segment21 => p_segment21,
501 p_segment22 => p_segment22,
502 p_segment23 => p_segment23,
503 p_segment24 => p_segment24,
504 p_segment25 => p_segment25,
505 p_segment26 => p_segment26,
506 p_segment27 => p_segment27,
507 p_segment28 => p_segment28,
508 p_segment29 => p_segment29,
509 p_segment30 => p_segment30,
510 p_business_group_id => p_business_group_id,
511 p_position_definition_id => l_position_definition_id,
512 p_name => p_name,
513 p_id_flex_num => l_id_flex_num);
514 --
515 -- determine the state of p_position_definition_id
516 --
517 -- p_position_definition_id
518 -- state meaning
519 -- ===================== =======
520 -- -1 Segment combination does not exist
521 -- null The segment combination is null
522 -- id A segment combination has been found
523 --
524 if (l_position_definition_id = -1) then
525 hr_utility.set_location(l_proc, 10);
526 --
527 -- a new combination needs to be inserted
528 --
529 per_pod_ins.ins
530 (p_position_definition_id => p_position_definition_id,
531 p_id_flex_num => l_id_flex_num,
532 p_summary_flag => null,
533 p_enabled_flag => null,
534 p_start_date_active => null,
535 p_end_date_active => null,
536 p_segment1 => p_segment1,
537 p_segment2 => p_segment2,
538 p_segment3 => p_segment3,
539 p_segment4 => p_segment4,
540 p_segment5 => p_segment5,
541 p_segment6 => p_segment6,
542 p_segment7 => p_segment7,
543 p_segment8 => p_segment8,
544 p_segment9 => p_segment9,
545 p_segment10 => p_segment10,
546 p_segment11 => p_segment11,
547 p_segment12 => p_segment12,
548 p_segment13 => p_segment13,
549 p_segment14 => p_segment14,
550 p_segment15 => p_segment15,
551 p_segment16 => p_segment16,
552 p_segment17 => p_segment17,
553 p_segment18 => p_segment18,
554 p_segment19 => p_segment19,
555 p_segment20 => p_segment20,
556 p_segment21 => p_segment21,
557 p_segment22 => p_segment22,
558 p_segment23 => p_segment23,
559 p_segment24 => p_segment24,
560 p_segment25 => p_segment25,
561 p_segment26 => p_segment26,
562 p_segment27 => p_segment27,
563 p_segment28 => p_segment28,
564 p_segment29 => p_segment29,
565 p_segment30 => p_segment30,
566 p_validate => p_validate);
567 elsif l_position_definition_id is not null then
568 --
569 -- As the combination already exists we must ensure that the
570 -- we return the primary key
571 --
572 p_position_definition_id := l_position_definition_id;
573 else
574 --
575 -- The combination must be null therefore we must ensure that the
576 -- we return the primary key as null
577 --
578 p_position_definition_id := null;
579 end if;
580 hr_utility.set_location(' Leaving:'||l_proc, 10);
581 end ins_or_sel;
582 --
583 end per_pod_ins;