DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SUB_INS

Source


1 Package Body per_sub_ins as
2 /* $Header: pesubrhi.pkb 115.14 2004/02/23 01:47:08 smparame ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_sub_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 -- Pre Conditions:
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 Table Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_sub_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   per_sub_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: per_subjects_taken
64   --
65   insert into per_subjects_taken
66   (	subjects_taken_id,
67 	start_date,
68 	major,
69 	subject_status,
70 	subject,
71 	grade_attained,
72 	end_date,
73 	qualification_id,
74 	object_version_number,
75 	attribute_category,
76 	attribute1,
77 	attribute2,
78 	attribute3,
79 	attribute4,
80 	attribute5,
81 	attribute6,
82 	attribute7,
83 	attribute8,
84 	attribute9,
85 	attribute10,
86 	attribute11,
87 	attribute12,
88 	attribute13,
89 	attribute14,
90 	attribute15,
91 	attribute16,
92 	attribute17,
93 	attribute18,
94 	attribute19,
95 	attribute20,
96 	sub_information_category,
97 	sub_information1,
98 	sub_information2,
99 	sub_information3,
100 	sub_information4,
101 	sub_information5,
102 	sub_information6,
103 	sub_information7,
104 	sub_information8,
105 	sub_information9,
106 	sub_information10,
107 	sub_information11,
108 	sub_information12,
109 	sub_information13,
110 	sub_information14,
111 	sub_information15,
112 	sub_information16,
113 	sub_information17,
114 	sub_information18,
115 	sub_information19,
116 	sub_information20
117   )
118   Values
119   (	p_rec.subjects_taken_id,
120 	p_rec.start_date,
121 	p_rec.major,
122 	p_rec.subject_status,
123 	p_rec.subject,
124 	p_rec.grade_attained,
125 	p_rec.end_date,
126 	p_rec.qualification_id,
127 	p_rec.object_version_number,
128 	p_rec.attribute_category,
129 	p_rec.attribute1,
130 	p_rec.attribute2,
131 	p_rec.attribute3,
132 	p_rec.attribute4,
133 	p_rec.attribute5,
134 	p_rec.attribute6,
135 	p_rec.attribute7,
136 	p_rec.attribute8,
137 	p_rec.attribute9,
138 	p_rec.attribute10,
139 	p_rec.attribute11,
140 	p_rec.attribute12,
141 	p_rec.attribute13,
142 	p_rec.attribute14,
143 	p_rec.attribute15,
144 	p_rec.attribute16,
145 	p_rec.attribute17,
146 	p_rec.attribute18,
147 	p_rec.attribute19,
148 	p_rec.attribute20,
149 	p_rec.sub_information_category,
150 	p_rec.sub_information1,
151 	p_rec.sub_information2,
152 	p_rec.sub_information3,
153 	p_rec.sub_information4,
154 	p_rec.sub_information5,
155 	p_rec.sub_information6,
156 	p_rec.sub_information7,
157 	p_rec.sub_information8,
158 	p_rec.sub_information9,
159 	p_rec.sub_information10,
160 	p_rec.sub_information11,
161 	p_rec.sub_information12,
162 	p_rec.sub_information13,
163 	p_rec.sub_information14,
164 	p_rec.sub_information15,
165 	p_rec.sub_information16,
166 	p_rec.sub_information17,
167 	p_rec.sub_information18,
168 	p_rec.sub_information19,
169 	p_rec.sub_information20
170 
171   );
172   --
173   per_sub_shd.g_api_dml := false;   -- Unset the api dml status
174   --
175   hr_utility.set_location(' Leaving:'||l_proc, 10);
176 Exception
177   When hr_api.check_integrity_violated Then
178     -- A check constraint has been violated
179     per_sub_shd.g_api_dml := false;   -- Unset the api dml status
180     per_sub_shd.constraint_error
181       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
182   When hr_api.parent_integrity_violated Then
183     -- Parent integrity has been violated
184     per_sub_shd.g_api_dml := false;   -- Unset the api dml status
185     per_sub_shd.constraint_error
186       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
187   When hr_api.unique_integrity_violated Then
188     -- Unique integrity has been violated
189     per_sub_shd.g_api_dml := false;   -- Unset the api dml status
190     per_sub_shd.constraint_error
191       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
192   When Others Then
193     per_sub_shd.g_api_dml := false;   -- Unset the api dml status
194     Raise;
195 End insert_dml;
196 --
197 -- ----------------------------------------------------------------------------
198 -- |------------------------------< pre_insert >------------------------------|
199 -- ----------------------------------------------------------------------------
200 -- {Start Of Comments}
201 --
202 -- Description:
203 --   This private procedure contains any processing which is required before
204 --   the insert dml. Presently, if the entity has a corresponding primary
205 --   key which is maintained by an associating sequence, the primary key for
206 --   the entity will be populated with the next sequence value in
207 --   preparation for the insert dml.
208 --
209 -- Pre Conditions:
210 --   This is an internal procedure which is called from the ins procedure.
211 --
212 -- In Parameters:
213 --   A Pl/Sql record structre.
214 --
215 -- Post Success:
216 --   Processing continues.
217 --
218 -- Post Failure:
219 --   If an error has occurred, an error message and exception will be raised
220 --   but not handled.
221 --
222 -- Developer Implementation Notes:
223 --   Any pre-processing required before the insert dml is issued should be
224 --   coded within this procedure. As stated above, a good example is the
225 --   generation of a primary key number via a corresponding sequence.
226 --   It is important to note that any 3rd party maintenance should be reviewed
227 --   before placing in this procedure.
228 --
229 -- Access Status:
230 --   Internal Table Handler Use Only.
231 --
232 -- {End Of Comments}
233 -- ----------------------------------------------------------------------------
234 Procedure pre_insert(p_rec  in out nocopy per_sub_shd.g_rec_type) is
235 --
236   l_proc  varchar2(72) := g_package||'pre_insert';
237 --
238   Cursor C_Sel1 is select per_subjects_taken_s.nextval from sys.dual;
239 --
240 Begin
241   hr_utility.set_location('Entering:'||l_proc, 5);
242   --
243   --
244   -- Select the next sequence number
245   --
246   Open C_Sel1;
247   Fetch C_Sel1 Into p_rec.subjects_taken_id;
248   Close C_Sel1;
249   --
250   hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End pre_insert;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |-----------------------------< post_insert >------------------------------|
255 -- ----------------------------------------------------------------------------
256 -- {Start Of Comments}
257 --
258 -- Description:
259 --   This private procedure contains any processing which is required after the
260 --   insert dml.
261 --
262 -- Pre Conditions:
263 --   This is an internal procedure which is called from the ins procedure.
264 --
265 -- In Parameters:
266 --   A Pl/Sql record structre.
267 --
268 -- Post Success:
269 --   Processing continues.
270 --
271 -- Post Failure:
272 --   If an error has occurred, an error message and exception will be raised
273 --   but not handled.
274 --
275 -- Developer Implementation Notes:
276 --   Any post-processing required after the insert dml is issued should be
277 --   coded within this procedure. It is important to note that any 3rd party
278 --   maintenance should be reviewed before placing in this procedure.
279 --
280 -- Access Status:
281 --   Internal Table Handler Use Only.
282 --
283 -- {End Of Comments}
284 -- ----------------------------------------------------------------------------
285 Procedure post_insert(p_rec             in per_sub_shd.g_rec_type,
286                       p_effective_date  in date) is
287 --
288   l_proc  varchar2(72) := g_package||'post_insert';
289 --
290 Begin
291   hr_utility.set_location('Entering:'||l_proc, 5);
292   --
293   -- Start of Row Handler User Hook for post_insert.
294   --
295   Begin
296     per_sub_rki.after_insert
297       (
298       p_subjects_taken_id            => p_rec.subjects_taken_id,
299       p_start_date                   => p_rec.start_date,
300       p_major                        => p_rec.major,
301       p_subject_status               => p_rec.subject_status,
302       p_subject                      => p_rec.subject,
303       p_grade_attained               => p_rec.grade_attained,
304       p_end_date                     => p_rec.end_date,
305       p_qualification_id             => p_rec.qualification_id,
306       p_object_version_number        => p_rec.object_version_number,
307       p_attribute_category           => p_rec.attribute_category,
308       p_attribute1                   => p_rec.attribute1,
309       p_attribute2                   => p_rec.attribute2,
310       p_attribute3                   => p_rec.attribute3,
311       p_attribute4                   => p_rec.attribute4,
312       p_attribute5                   => p_rec.attribute5,
313       p_attribute6                   => p_rec.attribute6,
314       p_attribute7                   => p_rec.attribute7,
315       p_attribute8                   => p_rec.attribute8,
316       p_attribute9                   => p_rec.attribute9,
317       p_attribute10                  => p_rec.attribute10,
318       p_attribute11                  => p_rec.attribute11,
319       p_attribute12                  => p_rec.attribute12,
320       p_attribute13                  => p_rec.attribute13,
321       p_attribute14                  => p_rec.attribute14,
322       p_attribute15                  => p_rec.attribute15,
323       p_attribute16                  => p_rec.attribute16,
324       p_attribute17                  => p_rec.attribute17,
325       p_attribute18                  => p_rec.attribute18,
326       p_attribute19                  => p_rec.attribute19,
327       p_attribute20                  => p_rec.attribute20,
328       p_sub_information_category           => p_rec.sub_information_category,
329       p_sub_information1                   => p_rec.sub_information1,
330       p_sub_information2                   => p_rec.sub_information2,
331       p_sub_information3                   => p_rec.sub_information3,
332       p_sub_information4                   => p_rec.sub_information4,
333       p_sub_information5                   => p_rec.sub_information5,
334       p_sub_information6                   => p_rec.sub_information6,
335       p_sub_information7                   => p_rec.sub_information7,
336       p_sub_information8                   => p_rec.sub_information8,
337       p_sub_information9                   => p_rec.sub_information9,
338       p_sub_information10                  => p_rec.sub_information10,
339       p_sub_information11                  => p_rec.sub_information11,
340       p_sub_information12                  => p_rec.sub_information12,
341       p_sub_information13                  => p_rec.sub_information13,
342       p_sub_information14                  => p_rec.sub_information14,
343       p_sub_information15                  => p_rec.sub_information15,
344       p_sub_information16                  => p_rec.sub_information16,
345       p_sub_information17                  => p_rec.sub_information17,
346       p_sub_information18                  => p_rec.sub_information18,
347       p_sub_information19                  => p_rec.sub_information19,
348       p_sub_information20                  => p_rec.sub_information20,
349       p_effective_date               => p_effective_date
350       );
351   exception
352     when hr_api.cannot_find_prog_unit then
353       hr_api.cannot_find_prog_unit_error
354         (p_module_name => 'PER_SUBJECTS_TAKEN'
355         ,p_hook_type   => 'AI'
356         );
357   end;
358   --
359   -- End of Row Handler User Hook for post_insert.
360   --
361   hr_utility.set_location(' Leaving:'||l_proc, 10);
362 End post_insert;
363 --
364 -- ----------------------------------------------------------------------------
365 -- |---------------------------------< ins >----------------------------------|
366 -- ----------------------------------------------------------------------------
367 Procedure ins
368   (
369   p_rec            in out nocopy per_sub_shd.g_rec_type,
370   p_effective_date in     date,
371   p_validate       in     boolean default false
372   ) is
373 --
374   l_proc  varchar2(72) := g_package||'ins';
375 --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Determine if the business process is to be validated.
380   --
381   If p_validate then
382     --
383     -- Issue the savepoint.
384     --
385     SAVEPOINT ins_sub;
386   End If;
387   --
388   -- Call the supporting insert validate operations
389   --
390   per_sub_bus.insert_validate(p_rec,p_effective_date);
391   --
392   -- Call the supporting pre-insert operation
393   --
394   pre_insert(p_rec);
395   --
396   -- Insert the row
397   --
398   insert_dml(p_rec);
399   --
400   -- Call the supporting post-insert operation
401   --
402   post_insert(p_rec, p_effective_date);
403   --
404   -- If we are validating then raise the Validate_Enabled exception
405   --
406   If p_validate then
407     Raise HR_Api.Validate_Enabled;
408   End If;
409   --
410   hr_utility.set_location(' Leaving:'||l_proc, 10);
411 Exception
412   When HR_Api.Validate_Enabled Then
413     --
414     -- As the Validate_Enabled exception has been raised
415     -- we must rollback to the savepoint
416     --
417     ROLLBACK TO ins_sub;
418 end ins;
419 --
420 -- ----------------------------------------------------------------------------
421 -- |---------------------------------< ins >----------------------------------|
422 -- ----------------------------------------------------------------------------
423 Procedure ins
424   (
425   p_subjects_taken_id            out nocopy number,
426   p_start_date                   in date,
427   p_major                        in varchar2,
428   p_subject_status               in varchar2,
429   p_subject                      in varchar2,
430   p_grade_attained               in varchar2         default null,
431   p_end_date                     in date             default null,
432   p_qualification_id             in number,
433   p_object_version_number        out nocopy number,
434   p_attribute_category           in varchar2         default null,
435   p_attribute1                   in varchar2         default null,
436   p_attribute2                   in varchar2         default null,
437   p_attribute3                   in varchar2         default null,
438   p_attribute4                   in varchar2         default null,
439   p_attribute5                   in varchar2         default null,
440   p_attribute6                   in varchar2         default null,
441   p_attribute7                   in varchar2         default null,
442   p_attribute8                   in varchar2         default null,
443   p_attribute9                   in varchar2         default null,
444   p_attribute10                  in varchar2         default null,
445   p_attribute11                  in varchar2         default null,
446   p_attribute12                  in varchar2         default null,
447   p_attribute13                  in varchar2         default null,
448   p_attribute14                  in varchar2         default null,
449   p_attribute15                  in varchar2         default null,
450   p_attribute16                  in varchar2         default null,
451   p_attribute17                  in varchar2         default null,
452   p_attribute18                  in varchar2         default null,
453   p_attribute19                  in varchar2         default null,
454   p_attribute20                  in varchar2         default null,
455 	p_sub_information_category            in varchar2 default null,
456 	p_sub_information1                    in varchar2 default null,
457 	p_sub_information2                    in varchar2 default null,
458 	p_sub_information3                    in varchar2 default null,
459 	p_sub_information4                    in varchar2 default null,
460 	p_sub_information5                    in varchar2 default null,
461 	p_sub_information6                    in varchar2 default null,
462 	p_sub_information7                    in varchar2 default null,
463 	p_sub_information8                    in varchar2 default null,
464 	p_sub_information9                    in varchar2 default null,
465 	p_sub_information10                   in varchar2 default null,
466 	p_sub_information11                   in varchar2 default null,
467 	p_sub_information12                   in varchar2 default null,
468 	p_sub_information13                   in varchar2 default null,
469 	p_sub_information14                   in varchar2 default null,
470 	p_sub_information15                   in varchar2 default null,
471 	p_sub_information16                   in varchar2 default null,
472 	p_sub_information17                   in varchar2 default null,
473 	p_sub_information18                   in varchar2 default null,
474 	p_sub_information19                   in varchar2 default null,
475 	p_sub_information20                   in varchar2 default null,
476   p_effective_date               in date,
477   p_validate                     in boolean   default false
478   ) is
479 --
480   l_rec	  per_sub_shd.g_rec_type;
481   l_proc  varchar2(72) := g_package||'ins';
482 --
483 Begin
484   hr_utility.set_location('Entering:'||l_proc, 5);
485   --
486   -- Call conversion function to turn arguments into the
487   -- p_rec structure.
488   --
489   l_rec :=
490   per_sub_shd.convert_args
491   (
492   null,
493   p_start_date,
494   p_major,
495   p_subject_status,
496   p_subject,
497   p_grade_attained,
498   p_end_date,
499   p_qualification_id,
500   null,
501   p_attribute_category,
502   p_attribute1,
503   p_attribute2,
504   p_attribute3,
505   p_attribute4,
506   p_attribute5,
507   p_attribute6,
508   p_attribute7,
509   p_attribute8,
510   p_attribute9,
511   p_attribute10,
512   p_attribute11,
513   p_attribute12,
514   p_attribute13,
515   p_attribute14,
516   p_attribute15,
517   p_attribute16,
518   p_attribute17,
519   p_attribute18,
520   p_attribute19,
521   p_attribute20,
522 	p_sub_information_category,
523 	p_sub_information1,
524 	p_sub_information2,
525 	p_sub_information3,
526 	p_sub_information4,
527 	p_sub_information5,
528 	p_sub_information6,
529 	p_sub_information7,
530 	p_sub_information8,
531 	p_sub_information9,
532 	p_sub_information10,
533 	p_sub_information11,
534 	p_sub_information12,
535 	p_sub_information13,
536 	p_sub_information14,
537 	p_sub_information15,
538 	p_sub_information16,
539 	p_sub_information17,
540 	p_sub_information18,
541 	p_sub_information19,
542 	p_sub_information20
543   );
544   --
545   -- Having converted the arguments into the sub_rec
546   -- plsql record structure we call the corresponding record business process.
547   --
548   ins(l_rec, p_effective_date, p_validate);
549   --
550   -- As the primary key argument(s)
551   -- are specified as an OUT's we must set these values.
552   --
553   p_subjects_taken_id := l_rec.subjects_taken_id;
554   p_object_version_number := l_rec.object_version_number;
555   --
556   hr_utility.set_location(' Leaving:'||l_proc, 10);
557 End ins;
558 --
559 end per_sub_ins;