DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HPH_INS

Source


1 Package Body hxc_hph_ins as
2 /* $Header: hxchphrhi.pkb 120.2.12000000.2 2007/03/16 13:22:54 rchennur noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_hph_ins.';  -- Global package name
9 g_debug	   boolean	:= hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< insert_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 --   This procedure controls the actual dml insert logic. The processing of
18 --   this procedure are as follows:
19 --   1) Initialise the object_version_number to 1 if the object_version_number
20 --      is defined as an attribute for this entity.
21 --   2) To set and unset the g_api_dml status as required (as we are about to
22 --      perform dml).
23 --   3) To insert the row into the schema.
24 --   4) To trap any constraint violations that may have occurred.
25 --   5) To raise any other errors.
26 --
27 -- Prerequisites:
28 --   This is an internal private procedure which must be called from the ins
29 --   procedure and must have all mandatory attributes set (except the
30 --   object_version_number which is initialised within this procedure).
31 --
32 -- In Parameters:
33 --   A Pl/Sql record structre.
34 --
35 -- Post Success:
36 --   The specified row will be inserted into the schema.
37 --
38 -- Post Failure:
39 --   On the insert dml failure it is important to note that we always reset the
40 --   g_api_dml status to false.
41 --   If a check, unique or parent integrity constraint violation is raised the
42 --   constraint_error procedure will be called.
43 --   If any other error is reported, the error will be raised after the
44 --   g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 --   None.
48 --
49 -- Access Status:
50 --   Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure insert_dml
55   (p_rec in out nocopy hxc_hph_shd.g_rec_type
56   ) is
57 --
58   l_proc  varchar2(72);
59 --
60 Begin
61   if g_debug then
62 	  l_proc := g_package||'insert_dml';
63 	  hr_utility.set_location('Entering:'||l_proc, 5);
64   end if;
65   p_rec.object_version_number := 1;  -- Initialise the object version
66   --
67   --
68   --
69   -- Insert the row into: hxc_pref_hierarchies
70   --
71   insert into hxc_pref_hierarchies
72       (pref_hierarchy_id
73       ,type
74       ,name
75       ,business_group_id
76       ,legislation_code
77       ,parent_pref_hierarchy_id
78       ,edit_allowed
79       ,displayed
80       ,pref_definition_id
81       ,attribute_category
82       ,attribute1
83       ,attribute2
84       ,attribute3
85       ,attribute4
86       ,attribute5
87       ,attribute6
88       ,attribute7
89       ,attribute8
90       ,attribute9
91       ,attribute10
92       ,attribute11
93       ,attribute12
94       ,attribute13
95       ,attribute14
96       ,attribute15
97       ,attribute16
98       ,attribute17
99       ,attribute18
100       ,attribute19
101       ,attribute20
102       ,attribute21
103       ,attribute22
104       ,attribute23
105       ,attribute24
106       ,attribute25
107       ,attribute26
108       ,attribute27
109       ,attribute28
110       ,attribute29
111       ,attribute30
112       ,object_version_number
113       ,orig_pref_hierarchy_id
114       ,orig_parent_hierarchy_id
115       ,top_level_parent_id         --Performance Fix
116       ,code
117       ,creation_date
118 ,created_by
119 ,last_updated_by
120 ,last_update_date
121 ,last_update_login
122       )
123   Values
124     (p_rec.pref_hierarchy_id
125     ,p_rec.type
126     ,p_rec.name
127     ,p_rec.business_group_id
128     ,p_rec.legislation_code
129     ,p_rec.parent_pref_hierarchy_id
130     ,p_rec.edit_allowed
131     ,p_rec.displayed
132     ,p_rec.pref_definition_id
133     ,p_rec.attribute_category
134     ,p_rec.attribute1
135     ,p_rec.attribute2
136     ,p_rec.attribute3
137     ,p_rec.attribute4
138     ,p_rec.attribute5
139     ,p_rec.attribute6
140     ,p_rec.attribute7
141     ,p_rec.attribute8
142     ,p_rec.attribute9
143     ,p_rec.attribute10
144     ,p_rec.attribute11
145     ,p_rec.attribute12
146     ,p_rec.attribute13
147     ,p_rec.attribute14
148     ,p_rec.attribute15
149     ,p_rec.attribute16
150     ,p_rec.attribute17
151     ,p_rec.attribute18
152     ,p_rec.attribute19
153     ,p_rec.attribute20
154     ,p_rec.attribute21
155     ,p_rec.attribute22
156     ,p_rec.attribute23
157     ,p_rec.attribute24
158     ,p_rec.attribute25
159     ,p_rec.attribute26
160     ,p_rec.attribute27
161     ,p_rec.attribute28
162     ,p_rec.attribute29
163     ,p_rec.attribute30
164     ,p_rec.object_version_number
165     ,p_rec.orig_pref_hierarchy_id
166     ,p_rec.orig_parent_hierarchy_id
167     ,p_rec.top_level_parent_id   --Performance Fix
168     ,p_rec.code
169      ,sysdate
170  ,fnd_global.user_id
171  ,fnd_global.user_id
172  ,sysdate
173  ,fnd_global.login_id
174     );
175   --
176   --
177   --
178   if g_debug then
179 	hr_utility.set_location(' Leaving:'||l_proc, 10);
180   end if;
181 Exception
182   When hr_api.check_integrity_violated Then
183     -- A check constraint has been violated
184     --
185     hxc_hph_shd.constraint_error
186       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
187   When hr_api.parent_integrity_violated Then
188     -- Parent integrity has been violated
189     --
190     hxc_hph_shd.constraint_error
191       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
192   When hr_api.unique_integrity_violated Then
193     -- Unique integrity has been violated
194     --
195     hxc_hph_shd.constraint_error
196       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
197   When Others Then
198     --
199     Raise;
200 End insert_dml;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |------------------------------< pre_insert >------------------------------|
204 -- ----------------------------------------------------------------------------
205 -- {Start Of Comments}
206 --
207 -- Description:
208 --   This private procedure contains any processing which is required before
209 --   the insert dml. Presently, if the entity has a corresponding primary
210 --   key which is maintained by an associating sequence, the primary key for
211 --   the entity will be populated with the next sequence value in
212 --   preparation for the insert dml.
213 --
214 -- Prerequisites:
215 --   This is an internal procedure which is called from the ins procedure.
216 --
217 -- In Parameters:
218 --   A Pl/Sql record structre.
219 --
220 -- Post Success:
221 --   Processing continues.
222 --
223 -- Post Failure:
224 --   If an error has occurred, an error message and exception will be raised
225 --   but not handled.
226 --
227 -- Developer Implementation Notes:
228 --   Any pre-processing required before the insert dml is issued should be
229 --   coded within this procedure. As stated above, a good example is the
230 --   generation of a primary key number via a corresponding sequence.
231 --   It is important to note that any 3rd party maintenance should be reviewed
232 --   before placing in this procedure.
233 --
234 -- Access Status:
235 --   Internal Row Handler Use Only.
236 --
237 -- {End Of Comments}
238 -- ----------------------------------------------------------------------------
239 Procedure pre_insert
240   (p_rec  in out nocopy hxc_hph_shd.g_rec_type
241   ) is
242 --
243   l_proc  varchar2(72);
244 --
245   Cursor C_Sel1 is select hxc_pref_hierarchies_s.nextval from sys.dual;
246   cursor c_top_level_node(p_pref_hierarchy_id number)
247   is
248           select  pref_hierarchy_id
249             from  hxc_pref_hierarchies
250 	   where parent_pref_hierarchy_id is null
251            connect by prior parent_pref_hierarchy_id = pref_hierarchy_id
252            start with pref_hierarchy_id = p_pref_hierarchy_id;
253 
254   Cursor c_code(p_pref_definition_id number)
255   is
256           select hpd.code
257           from   hxc_pref_definitions hpd
258           where  pref_definition_id = p_pref_definition_id;
259 
260 l_top_node_id number := p_rec.parent_pref_hierarchy_id;
261 l_node_id     number;
262 l_code        varchar2(30);
263 --
264 Begin
265   if g_debug then
266 	l_proc := g_package||'pre_insert';
267 	hr_utility.set_location('Entering:'||l_proc, 5);
268   end if;
269   --
270   --
271   -- Select the next sequence number
272   --
273   Open C_Sel1;
274   Fetch C_Sel1 Into p_rec.pref_hierarchy_id;
275   Close C_Sel1;
276 
277 --Performance Fix
278   if (p_rec.pref_definition_id is not null) then
279   -- Get the top level parent ID
280      open c_top_level_node(l_top_node_id);
281          fetch c_top_level_node into l_top_node_id;
282      close c_top_level_node;
283      p_rec.top_level_parent_id := l_top_node_id;
284   -- Get the code for the node
285      open c_code(p_rec.pref_definition_id);
286      fetch c_code into l_code;
287         p_rec.code := l_code;
288      close c_code;
289   --
290    else
291      p_rec.top_level_parent_id := null;
292      p_rec.code := null;
293    end if;
294   if g_debug then
295 	hr_utility.set_location(' Leaving:'||l_proc, 10);
296   end if;
297 End pre_insert;
298 --
299 -- ----------------------------------------------------------------------------
300 -- |-----------------------------< post_insert >------------------------------|
301 -- ----------------------------------------------------------------------------
302 -- {Start Of Comments}
303 --
304 -- Description:
305 --   This private procedure contains any processing which is required after the
306 --   insert dml.
307 --
308 -- Prerequisites:
309 --   This is an internal procedure which is called from the ins procedure.
310 --
311 -- In Parameters:
312 --   A Pl/Sql record structre.
313 --
314 -- Post Success:
315 --   Processing continues.
316 --
317 -- Post Failure:
318 --   If an error has occurred, an error message and exception will be raised
319 --   but not handled.
320 --
321 -- Developer Implementation Notes:
322 --   Any post-processing required after the insert dml is issued should be
323 --   coded within this procedure. It is important to note that any 3rd party
324 --   maintenance should be reviewed before placing in this procedure.
325 --
326 -- Access Status:
327 --   Internal Row Handler Use Only.
328 --
329 -- {End Of Comments}
330 -- ----------------------------------------------------------------------------
331 Procedure post_insert
332   (p_effective_date               in date
333   ,p_rec                          in hxc_hph_shd.g_rec_type
334   ) is
335 --
336   l_proc  varchar2(72);
337 --
338 Begin
339   if g_debug then
340 	l_proc := g_package||'post_insert';
341 	hr_utility.set_location('Entering:'||l_proc, 5);
342   end if;
343   begin
344     --
345     hxc_hph_rki.after_insert
346       (p_effective_date              => p_effective_date
347       ,p_pref_hierarchy_id
348       => p_rec.pref_hierarchy_id
349       ,p_type
350       => p_rec.type
351       ,p_name
352       => p_rec.name
353       ,p_business_group_id	     => p_rec.business_group_id
354       ,p_legislation_code	     => p_rec.legislation_code
355       ,p_parent_pref_hierarchy_id
356       => p_rec.parent_pref_hierarchy_id
357       ,p_edit_allowed
358       => p_rec.edit_allowed
359       ,p_displayed
360       => p_rec.displayed
361       ,p_pref_definition_id
362       => p_rec.pref_definition_id
363       ,p_attribute_category
364       => p_rec.attribute_category
365       ,p_attribute1
366       => p_rec.attribute1
367       ,p_attribute2
368       => p_rec.attribute2
369       ,p_attribute3
370       => p_rec.attribute3
371       ,p_attribute4
372       => p_rec.attribute4
373       ,p_attribute5
374       => p_rec.attribute5
375       ,p_attribute6
376       => p_rec.attribute6
377       ,p_attribute7
378       => p_rec.attribute7
379       ,p_attribute8
380       => p_rec.attribute8
381       ,p_attribute9
382       => p_rec.attribute9
383       ,p_attribute10
384       => p_rec.attribute10
385       ,p_attribute11
386       => p_rec.attribute11
387       ,p_attribute12
388       => p_rec.attribute12
389       ,p_attribute13
390       => p_rec.attribute13
391       ,p_attribute14
392       => p_rec.attribute14
393       ,p_attribute15
394       => p_rec.attribute15
395       ,p_attribute16
396       => p_rec.attribute16
397       ,p_attribute17
398       => p_rec.attribute17
399       ,p_attribute18
400       => p_rec.attribute18
401       ,p_attribute19
402       => p_rec.attribute19
403       ,p_attribute20
404       => p_rec.attribute20
405       ,p_attribute21
406       => p_rec.attribute21
407       ,p_attribute22
408       => p_rec.attribute22
409       ,p_attribute23
410       => p_rec.attribute23
411       ,p_attribute24
412       => p_rec.attribute24
413       ,p_attribute25
414       => p_rec.attribute25
415       ,p_attribute26
416       => p_rec.attribute26
417       ,p_attribute27
418       => p_rec.attribute27
419       ,p_attribute28
420       => p_rec.attribute28
421       ,p_attribute29
422       => p_rec.attribute29
423       ,p_attribute30
424       => p_rec.attribute30
425       ,p_object_version_number
426       => p_rec.object_version_number
427       ,p_orig_pref_hierarchy_id
428       => p_rec.orig_pref_hierarchy_id
429       ,p_orig_parent_hierarchy_id
430       => p_rec.orig_parent_hierarchy_id
431       ,p_top_level_parent_id  --Performance Fix
432       =>p_rec.top_level_parent_id
433       ,p_code
434       => p_rec.code
435       );
436     --
437   exception
438     --
439     when hr_api.cannot_find_prog_unit then
440       --
441       hr_api.cannot_find_prog_unit_error
442         (p_module_name => 'HXC_PREF_HIERARCHIES'
443         ,p_hook_type   => 'AI');
444       --
445   end;
446   --
447   if g_debug then
448 	hr_utility.set_location(' Leaving:'||l_proc, 10);
449   end if;
450 End post_insert;
451 --
452 -- ----------------------------------------------------------------------------
453 -- |---------------------------------< ins >----------------------------------|
454 -- ----------------------------------------------------------------------------
455 Procedure ins
456   (p_effective_date               in date
457   ,p_rec                          in out nocopy hxc_hph_shd.g_rec_type
458   ) is
459 --
460   l_proc  varchar2(72);
461 --
462 Begin
463   g_debug:=hr_utility.debug_enabled;
464   if g_debug then
465 	l_proc := g_package||'ins';
466 	hr_utility.set_location('Entering:'||l_proc, 5);
467   end if;
468   --
469   -- Call the supporting insert validate operations
470   --
471   hxc_hph_bus.insert_validate
472      (p_effective_date
473      ,p_rec
474      );
475   --
476   -- Call the supporting pre-insert operation
477   --
478   hxc_hph_ins.pre_insert(p_rec);
479   --
480   -- Insert the row
481   --
482   hxc_hph_ins.insert_dml(p_rec);
483   --
484   -- Call the supporting post-insert operation
485   --
486   hxc_hph_ins.post_insert
487      (p_effective_date
488      ,p_rec
489      );
490   --
491   if g_debug then
492 	hr_utility.set_location('Leaving:'||l_proc, 20);
493   end if;
494 end ins;
495 --
496 -- ----------------------------------------------------------------------------
497 -- |---------------------------------< ins >----------------------------------|
498 -- ----------------------------------------------------------------------------
499 Procedure ins
500   (p_effective_date               in     date
501   ,p_name                           in     varchar2
502   ,p_business_group_id		    in     number   default null
503   ,p_legislation_code		    in     varchar2 default null
504   ,p_edit_allowed                   in     varchar2
505   ,p_displayed                      in     varchar2
506   ,p_type                           in     varchar2 default null
507   ,p_parent_pref_hierarchy_id       in     number   default null
508   ,p_pref_definition_id             in     number   default null
509   ,p_attribute_category             in     varchar2 default null
510   ,p_attribute1                     in     varchar2 default null
511   ,p_attribute2                     in     varchar2 default null
512   ,p_attribute3                     in     varchar2 default null
513   ,p_attribute4                     in     varchar2 default null
514   ,p_attribute5                     in     varchar2 default null
515   ,p_attribute6                     in     varchar2 default null
516   ,p_attribute7                     in     varchar2 default null
517   ,p_attribute8                     in     varchar2 default null
518   ,p_attribute9                     in     varchar2 default null
519   ,p_attribute10                    in     varchar2 default null
520   ,p_attribute11                    in     varchar2 default null
521   ,p_attribute12                    in     varchar2 default null
522   ,p_attribute13                    in     varchar2 default null
523   ,p_attribute14                    in     varchar2 default null
524   ,p_attribute15                    in     varchar2 default null
525   ,p_attribute16                    in     varchar2 default null
526   ,p_attribute17                    in     varchar2 default null
527   ,p_attribute18                    in     varchar2 default null
528   ,p_attribute19                    in     varchar2 default null
529   ,p_attribute20                    in     varchar2 default null
530   ,p_attribute21                    in     varchar2 default null
531   ,p_attribute22                    in     varchar2 default null
532   ,p_attribute23                    in     varchar2 default null
533   ,p_attribute24                    in     varchar2 default null
534   ,p_attribute25                    in     varchar2 default null
535   ,p_attribute26                    in     varchar2 default null
536   ,p_attribute27                    in     varchar2 default null
537   ,p_attribute28                    in     varchar2 default null
538   ,p_attribute29                    in     varchar2 default null
539   ,p_attribute30                    in     varchar2 default null
540   ,p_orig_pref_hierarchy_id         in     number   default null
541   ,p_orig_parent_hierarchy_id       in     number   default null
542   ,p_pref_hierarchy_id                 out nocopy number
543   ,p_object_version_number             out nocopy number
544   ,p_top_level_parent_id            in     number   default null--Performance Fix
545   ,p_code                           in     varchar2 default null
546   ) is
547 --
548   l_rec	  hxc_hph_shd.g_rec_type;
549   l_proc  varchar2(72);
550 --
551 Begin
552   g_debug:=hr_utility.debug_enabled;
553   if g_debug then
554 	l_proc := g_package||'ins';
555 	hr_utility.set_location('Entering:'||l_proc, 5);
556   end if;
557   --
558   -- Call conversion function to turn arguments into the
559   -- p_rec structure.
560   --
561   l_rec :=
562   hxc_hph_shd.convert_args
563     (null
564     ,p_type
565     ,p_name
566     ,p_business_group_id
567     ,p_legislation_code
568     ,p_parent_pref_hierarchy_id
569     ,p_edit_allowed
570     ,p_displayed
571     ,p_pref_definition_id
572     ,p_attribute_category
573     ,p_attribute1
574     ,p_attribute2
575     ,p_attribute3
576     ,p_attribute4
577     ,p_attribute5
578     ,p_attribute6
579     ,p_attribute7
580     ,p_attribute8
581     ,p_attribute9
582     ,p_attribute10
583     ,p_attribute11
584     ,p_attribute12
585     ,p_attribute13
586     ,p_attribute14
587     ,p_attribute15
588     ,p_attribute16
589     ,p_attribute17
590     ,p_attribute18
591     ,p_attribute19
592     ,p_attribute20
593     ,p_attribute21
594     ,p_attribute22
595     ,p_attribute23
596     ,p_attribute24
597     ,p_attribute25
598     ,p_attribute26
599     ,p_attribute27
600     ,p_attribute28
601     ,p_attribute29
602     ,p_attribute30
603     ,null
604     ,p_orig_pref_hierarchy_id
605     ,p_orig_parent_hierarchy_id
606     ,p_top_level_parent_id        --Performance Fix
607     ,p_code
608     );
609   --
610   -- Having converted the arguments into the hxc_hph_rec
611   -- plsql record structure we call the corresponding record business process.
612   --
613   hxc_hph_ins.ins
614      (p_effective_date
615      ,l_rec
616      );
617   --
618   -- As the primary key argument(s)
619   -- are specified as an OUT's we must set these values.
620   --
621   p_pref_hierarchy_id := l_rec.pref_hierarchy_id;
622   p_object_version_number := l_rec.object_version_number;
623   --
624   if g_debug then
625 	hr_utility.set_location(' Leaving:'||l_proc, 10);
626   end if;
627 End ins;
628 --
629 end hxc_hph_ins;