[Home] [Help]
PACKAGE BODY: APPS.PER_JBD_INS
Source
1 Package Body per_jbd_ins as
2 /* $Header: pejbdrhi.pkb 115.1 99/07/18 13:54:47 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_jbd_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 per_jbd_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_jbd_shd.g_api_dml := true; -- Set the api dml status
58 --
59 -- Insert the row into: per_job_definitions
60 --
61 insert into per_job_definitions
62 ( job_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.job_definition_id,
101 p_rec.id_flex_num,
102 'N',
103 'Y',
104 sysdate,
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_jbd_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_jbd_shd.g_api_dml := false; -- Unset the api dml status
145 per_jbd_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_jbd_shd.g_api_dml := false; -- Unset the api dml status
150 per_jbd_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_jbd_shd.g_api_dml := false; -- Unset the api dml status
155 per_jbd_shd.constraint_error
156 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
157 When Others Then
158 per_jbd_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 per_jbd_shd.g_rec_type) is
200 --
201 l_proc varchar2(72) := g_package||'pre_insert';
202 --
203 Cursor C_Sel1 is select per_job_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.job_definition_id;
213 Close C_Sel1;
214 --
215 hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End pre_insert;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |-----------------------------< post_insert >------------------------------|
220 -- ----------------------------------------------------------------------------
221 -- {Start Of Comments}
222 --
223 -- Description:
224 -- This private procedure contains any processing which is required after the
225 -- insert dml.
226 --
227 -- Pre Conditions:
228 -- This is an internal procedure which is called from the ins procedure.
229 --
230 -- In Arguments:
231 -- A Pl/Sql record structre.
232 --
233 -- Post Success:
234 -- Processing continues.
235 --
236 -- Post Failure:
237 -- If an error has occurred, an error message and exception will be raised
238 -- but not handled.
239 --
240 -- Developer Implementation Notes:
241 -- Any post-processing required after the insert dml is issued should be
242 -- coded within this procedure. It is important to note that any 3rd party
243 -- maintenance should be reviewed before placing in this procedure.
244 --
245 -- Access Status:
246 -- Internal Table Handler Use Only.
247 --
248 -- {End Of Comments}
249 -- ----------------------------------------------------------------------------
250 Procedure post_insert(p_rec in per_jbd_shd.g_rec_type) is
251 --
252 l_proc varchar2(72) := g_package||'post_insert';
253 --
254 Begin
255 hr_utility.set_location('Entering:'||l_proc, 5);
256 --
257 hr_utility.set_location(' Leaving:'||l_proc, 10);
258 End post_insert;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |---------------------------------< ins >----------------------------------|
262 -- ----------------------------------------------------------------------------
263 Procedure ins
264 (
265 p_rec in out per_jbd_shd.g_rec_type,
266 p_validate in boolean default false
267 ) is
268 --
269 l_proc varchar2(72) := g_package||'ins';
270 --
271 Begin
272 hr_utility.set_location('Entering:'||l_proc, 5);
273 --
274 -- Determine if the business process is to be validated.
275 --
276 If p_validate then
277 --
278 -- Issue the savepoint.
279 --
280 SAVEPOINT ins_per_jbd;
281 End If;
282
283 --
284 -- Call the supporting insert validate operations
285 --
286 per_jbd_bus.insert_validate(p_rec);
287 --
288 -- Call the supporting pre-insert operation
289 --
290 pre_insert(p_rec);
291 --
292 -- Insert the row
293 --
294 insert_dml(p_rec);
295 --
296 -- Call the supporting post-insert operation
297 --
298 post_insert(p_rec);
299 --
300 -- If we are validating then raise the Validate_Enabled exception
301 --
302 If p_validate then
303 Raise HR_Api.Validate_Enabled;
304 End If;
305 --
306 hr_utility.set_location(' Leaving:'||l_proc, 10);
307 Exception
308 When HR_Api.Validate_Enabled Then
309 --
310 -- As the Validate_Enabled exception has been raised
311 -- we must rollback to the savepoint
312 --
313 ROLLBACK TO ins_per_jbd;
314 end ins;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------------< ins >----------------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure ins
320 (
321 p_job_definition_id out number,
322 p_id_flex_num in number,
323 p_end_date_active in date default null,
324 p_segment1 in varchar2 default null,
325 p_segment2 in varchar2 default null,
326 p_segment3 in varchar2 default null,
327 p_segment4 in varchar2 default null,
328 p_segment5 in varchar2 default null,
329 p_segment6 in varchar2 default null,
330 p_segment7 in varchar2 default null,
331 p_segment8 in varchar2 default null,
332 p_segment9 in varchar2 default null,
333 p_segment10 in varchar2 default null,
334 p_segment11 in varchar2 default null,
335 p_segment12 in varchar2 default null,
336 p_segment13 in varchar2 default null,
337 p_segment14 in varchar2 default null,
338 p_segment15 in varchar2 default null,
339 p_segment16 in varchar2 default null,
340 p_segment17 in varchar2 default null,
341 p_segment18 in varchar2 default null,
342 p_segment19 in varchar2 default null,
343 p_segment20 in varchar2 default null,
344 p_segment21 in varchar2 default null,
345 p_segment22 in varchar2 default null,
346 p_segment23 in varchar2 default null,
347 p_segment24 in varchar2 default null,
348 p_segment25 in varchar2 default null,
349 p_segment26 in varchar2 default null,
350 p_segment27 in varchar2 default null,
351 p_segment28 in varchar2 default null,
352 p_segment29 in varchar2 default null,
353 p_segment30 in varchar2 default null,
354 p_validate in boolean default false
355 ) is
356 --
357 l_rec per_jbd_shd.g_rec_type;
358 l_proc varchar2(72) := g_package||'ins';
359 --
360 Begin
361 hr_utility.set_location('Entering:'||l_proc, 5);
362 --
363 -- Call conversion function to turn arguments into the
364 -- p_rec structure.
365 --
366 l_rec :=
367 per_jbd_shd.convert_args
368 (
369 null,
370 p_id_flex_num,
371 p_end_date_active,
372 p_segment1,
373 p_segment2,
374 p_segment3,
375 p_segment4,
376 p_segment5,
377 p_segment6,
378 p_segment7,
379 p_segment8,
380 p_segment9,
381 p_segment10,
382 p_segment11,
383 p_segment12,
384 p_segment13,
385 p_segment14,
386 p_segment15,
387 p_segment16,
388 p_segment17,
389 p_segment18,
390 p_segment19,
391 p_segment20,
392 p_segment21,
393 p_segment22,
394 p_segment23,
395 p_segment24,
396 p_segment25,
397 p_segment26,
398 p_segment27,
399 p_segment28,
400 p_segment29,
401 p_segment30
402 );
403 --
404 -- Having converted the arguments into the per_jbd_rec
405 -- plsql record structure we call the corresponding record business process.
406 --
407 ins(l_rec, p_validate);
408 --
409 -- As the primary key argument(s)
410 -- are specified as an OUT's we must set these values.
411 --
412 p_job_definition_id := l_rec.job_definition_id;
413 --
414 hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End ins;
416 --
417 -- ----------------------------------------------------------------------------
418 -- |-------------------------------< ins_or_sel >-----------------------------|
419 -- ----------------------------------------------------------------------------
420 procedure ins_or_sel
421 (p_segment1 in varchar2 default null,
422 p_segment2 in varchar2 default null,
423 p_segment3 in varchar2 default null,
424 p_segment4 in varchar2 default null,
425 p_segment5 in varchar2 default null,
426 p_segment6 in varchar2 default null,
427 p_segment7 in varchar2 default null,
428 p_segment8 in varchar2 default null,
429 p_segment9 in varchar2 default null,
430 p_segment10 in varchar2 default null,
431 p_segment11 in varchar2 default null,
432 p_segment12 in varchar2 default null,
433 p_segment13 in varchar2 default null,
434 p_segment14 in varchar2 default null,
435 p_segment15 in varchar2 default null,
436 p_segment16 in varchar2 default null,
437 p_segment17 in varchar2 default null,
438 p_segment18 in varchar2 default null,
439 p_segment19 in varchar2 default null,
440 p_segment20 in varchar2 default null,
441 p_segment21 in varchar2 default null,
442 p_segment22 in varchar2 default null,
443 p_segment23 in varchar2 default null,
444 p_segment24 in varchar2 default null,
445 p_segment25 in varchar2 default null,
446 p_segment26 in varchar2 default null,
447 p_segment27 in varchar2 default null,
448 p_segment28 in varchar2 default null,
449 p_segment29 in varchar2 default null,
450 p_segment30 in varchar2 default null,
451 p_business_group_id in number,
452 p_job_definition_id out number,
453 p_name out varchar2,
454 p_validate in boolean default false) is
455 --
456 l_job_definition_id number;
457 l_id_flex_num number;
458 l_proc varchar2(72) := g_package||'ins_or_sel';
459
460 --
461 begin
462 hr_utility.set_location('Entering:'||l_proc, 5);
463 --
464 -- determine if a job combination exists
465 --
466 per_jbd_shd.segment_combination_check
467 (p_segment1 => p_segment1,
468 p_segment2 => p_segment2,
469 p_segment3 => p_segment3,
470 p_segment4 => p_segment4,
471 p_segment5 => p_segment5,
472 p_segment6 => p_segment6,
473 p_segment7 => p_segment7,
474 p_segment8 => p_segment8,
475 p_segment9 => p_segment9,
476 p_segment10 => p_segment10,
477 p_segment11 => p_segment11,
478 p_segment12 => p_segment12,
479 p_segment13 => p_segment13,
480 p_segment14 => p_segment14,
481 p_segment15 => p_segment15,
482 p_segment16 => p_segment16,
483 p_segment17 => p_segment17,
484 p_segment18 => p_segment18,
485 p_segment19 => p_segment19,
486 p_segment20 => p_segment20,
487 p_segment21 => p_segment21,
488 p_segment22 => p_segment22,
489 p_segment23 => p_segment23,
490 p_segment24 => p_segment24,
491 p_segment25 => p_segment25,
492 p_segment26 => p_segment26,
493 p_segment27 => p_segment27,
494 p_segment28 => p_segment28,
495 p_segment29 => p_segment29,
496 p_segment30 => p_segment30,
497 p_business_group_id => p_business_group_id,
498 p_job_definition_id => l_job_definition_id,
499 p_name => p_name,
500 p_id_flex_num => l_id_flex_num);
501
502
503 --
504 -- determine the state of p_job_definition_id
505 --
506 -- p_job_definition_id
507 -- state meaning
508 -- ===================== =======
509 -- -1 Segment combination does not exist
510 -- null The segment combination is null
511 -- id A segment combination has been found
512 --
513 if (l_job_definition_id = -1) then
514 hr_utility.set_location(l_proc, 10);
515 --
516 -- a new combination needs to be inserted
517 --
518 per_jbd_ins.ins
519 (p_job_definition_id => p_job_definition_id,
520 p_id_flex_num => l_id_flex_num,
521 p_end_date_active => null,
522 p_segment1 => p_segment1,
523 p_segment2 => p_segment2,
524 p_segment3 => p_segment3,
525 p_segment4 => p_segment4,
526 p_segment5 => p_segment5,
527 p_segment6 => p_segment6,
528 p_segment7 => p_segment7,
529 p_segment8 => p_segment8,
530 p_segment9 => p_segment9,
531 p_segment10 => p_segment10,
532 p_segment11 => p_segment11,
533 p_segment12 => p_segment12,
534 p_segment13 => p_segment13,
535 p_segment14 => p_segment14,
536 p_segment15 => p_segment15,
537 p_segment16 => p_segment16,
538 p_segment17 => p_segment17,
539 p_segment18 => p_segment18,
540 p_segment19 => p_segment19,
541 p_segment20 => p_segment20,
542 p_segment21 => p_segment21,
543 p_segment22 => p_segment22,
544 p_segment23 => p_segment23,
545 p_segment24 => p_segment24,
546 p_segment25 => p_segment25,
547 p_segment26 => p_segment26,
548 p_segment27 => p_segment27,
549 p_segment28 => p_segment28,
550 p_segment29 => p_segment29,
551 p_segment30 => p_segment30,
552 p_validate => p_validate);
553 elsif l_job_definition_id is not null then
554 --
555 -- As the combination already exists we must ensure that the
556 -- we return the primary key
557 --
558 p_job_definition_id := l_job_definition_id;
559 else
560 --
561 -- The combination must be null therefore we must ensure that the
562 -- we return the primary key as null
563 --
564 p_job_definition_id := null;
565 end if;
566 hr_utility.set_location(' Leaving:'||l_proc, 15);
567 end ins_or_sel;
568 --
569 end per_jbd_ins;