DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ANC_INS

Source


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