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