DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_SCL_INS

Source


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