DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HAV_INS

Source


1 Package Body hxc_hav_ins as
2 /* $Header: hxchavrhi.pkb 120.2 2005/09/23 10:41:41 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_hav_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_hav_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_alias_values
70   --
71   insert into hxc_alias_values
72       (alias_value_id
73       ,alias_value_name
74       ,date_from
75       ,date_to
76       ,alias_definition_id
77       ,enabled_flag
78       ,attribute_category
79       ,attribute1
80       ,attribute2
81       ,attribute3
82       ,attribute4
83       ,attribute5
84       ,attribute6
85       ,attribute7
86       ,attribute8
87       ,attribute9
88       ,attribute10
89       ,attribute11
90       ,attribute12
91       ,attribute13
92       ,attribute14
93       ,attribute15
94       ,attribute16
95       ,attribute17
96       ,attribute18
97       ,attribute19
98       ,attribute20
99       ,attribute21
100       ,attribute22
101       ,attribute23
102       ,attribute24
103       ,attribute25
104       ,attribute26
105       ,attribute27
106       ,attribute28
107       ,attribute29
108       ,attribute30
109       ,object_version_number
110       ,creation_date
111 ,created_by
112 ,last_updated_by
113 ,last_update_date
114 ,last_update_login
115       )
116   Values
117     (p_rec.alias_value_id
118     ,p_rec.alias_value_name
119     ,p_rec.date_from
120     ,p_rec.date_to
121     ,p_rec.alias_definition_id
122     ,p_rec.enabled_flag
123     ,p_rec.attribute_category
124     ,p_rec.attribute1
125     ,p_rec.attribute2
126     ,p_rec.attribute3
127     ,p_rec.attribute4
128     ,p_rec.attribute5
129     ,p_rec.attribute6
130     ,p_rec.attribute7
131     ,p_rec.attribute8
132     ,p_rec.attribute9
133     ,p_rec.attribute10
134     ,p_rec.attribute11
135     ,p_rec.attribute12
136     ,p_rec.attribute13
137     ,p_rec.attribute14
138     ,p_rec.attribute15
139     ,p_rec.attribute16
140     ,p_rec.attribute17
141     ,p_rec.attribute18
142     ,p_rec.attribute19
143     ,p_rec.attribute20
144     ,p_rec.attribute21
145     ,p_rec.attribute22
146     ,p_rec.attribute23
147     ,p_rec.attribute24
148     ,p_rec.attribute25
149     ,p_rec.attribute26
150     ,p_rec.attribute27
151     ,p_rec.attribute28
152     ,p_rec.attribute29
153     ,p_rec.attribute30
154     ,p_rec.object_version_number
155      ,sysdate
156  ,fnd_global.user_id
157  ,fnd_global.user_id
158  ,sysdate
159  ,fnd_global.login_id
160     );
161   --
162   --
163   --
164   if g_debug then
165 	hr_utility.set_location(' Leaving:'||l_proc, 10);
166   end if;
167 Exception
168   When hr_api.check_integrity_violated Then
169     -- A check constraint has been violated
170     --
171     hxc_hav_shd.constraint_error
172       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
173   When hr_api.parent_integrity_violated Then
174     -- Parent integrity has been violated
175     --
176     hxc_hav_shd.constraint_error
177       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
178   When hr_api.unique_integrity_violated Then
179     -- Unique integrity has been violated
180     --
181     hxc_hav_shd.constraint_error
182       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
183   When Others Then
184     --
185     Raise;
186 End insert_dml;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |------------------------------< pre_insert >------------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 --   This private procedure contains any processing which is required before
195 --   the insert dml. Presently, if the entity has a corresponding primary
196 --   key which is maintained by an associating sequence, the primary key for
197 --   the entity will be populated with the next sequence value in
198 --   preparation for the insert dml.
199 --
200 -- Prerequisites:
201 --   This is an internal procedure which is called from the ins procedure.
202 --
203 -- In Parameters:
204 --   A Pl/Sql record structre.
205 --
206 -- Post Success:
207 --   Processing continues.
208 --
209 -- Post Failure:
210 --   If an error has occurred, an error message and exception will be raised
211 --   but not handled.
212 --
213 -- Developer Implementation Notes:
214 --   Any pre-processing required before the insert dml is issued should be
215 --   coded within this procedure. As stated above, a good example is the
216 --   generation of a primary key number via a corresponding sequence.
217 --   It is important to note that any 3rd party maintenance should be reviewed
218 --   before placing in this procedure.
219 --
220 -- Access Status:
221 --   Internal Row Handler Use Only.
222 --
223 -- {End Of Comments}
224 -- ----------------------------------------------------------------------------
225 Procedure pre_insert
226   (p_rec  in out nocopy hxc_hav_shd.g_rec_type
227   ) is
228 --
229   l_proc  varchar2(72);
230 --
231   Cursor C_Sel1 is select hxc_alias_values_s.nextval from sys.dual;
232 --
233 Begin
234   if g_debug then
235 	l_proc := g_package||'pre_insert';
236 	hr_utility.set_location('Entering:'||l_proc, 5);
237   end if;
238   --
239   --
240   -- Select the next sequence number
241   --
242   Open C_Sel1;
243   Fetch C_Sel1 Into p_rec.alias_value_id;
244   Close C_Sel1;
245   --
246   if g_debug then
247 	hr_utility.set_location(' Leaving:'||l_proc, 10);
248   end if;
249 End pre_insert;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |-----------------------------< post_insert >------------------------------|
253 -- ----------------------------------------------------------------------------
254 -- {Start Of Comments}
255 --
256 -- Description:
257 --   This private procedure contains any processing which is required after the
258 --   insert dml.
259 --
260 -- Prerequisites:
261 --   This is an internal procedure which is called from the ins procedure.
262 --
263 -- In Parameters:
264 --   A Pl/Sql record structre.
265 --
266 -- Post Success:
267 --   Processing continues.
268 --
269 -- Post Failure:
270 --   If an error has occurred, an error message and exception will be raised
271 --   but not handled.
272 --
273 -- Developer Implementation Notes:
274 --   Any post-processing required after the insert dml is issued should be
275 --   coded within this procedure. It is important to note that any 3rd party
276 --   maintenance should be reviewed before placing in this procedure.
277 --
278 -- Access Status:
279 --   Internal Row Handler Use Only.
280 --
281 -- {End Of Comments}
282 -- ----------------------------------------------------------------------------
283 Procedure post_insert
284   (p_rec                          in hxc_hav_shd.g_rec_type
285   ) is
286 --
287   l_proc  varchar2(72);
288 --
289 Begin
290   if g_debug then
291 	l_proc := g_package||'post_insert';
292 	hr_utility.set_location('Entering:'||l_proc, 5);
293   end if;
294   begin
295     --
296     hxc_hav_rki.after_insert
297       (p_alias_value_id
298       => p_rec.alias_value_id
299       ,p_alias_value_name
300       => p_rec.alias_value_name
301       ,p_date_from
302       => p_rec.date_from
303       ,p_date_to
304       => p_rec.date_to
305       ,p_alias_definition_id
306       => p_rec.alias_definition_id
307       ,p_enabled_flag
308       => p_rec.enabled_flag
309       ,p_attribute_category
310       => p_rec.attribute_category
311       ,p_attribute1
312       => p_rec.attribute1
313       ,p_attribute2
314       => p_rec.attribute2
315       ,p_attribute3
316       => p_rec.attribute3
317       ,p_attribute4
318       => p_rec.attribute4
319       ,p_attribute5
320       => p_rec.attribute5
321       ,p_attribute6
322       => p_rec.attribute6
323       ,p_attribute7
324       => p_rec.attribute7
325       ,p_attribute8
326       => p_rec.attribute8
327       ,p_attribute9
328       => p_rec.attribute9
329       ,p_attribute10
330       => p_rec.attribute10
331       ,p_attribute11
332       => p_rec.attribute11
333       ,p_attribute12
334       => p_rec.attribute12
335       ,p_attribute13
336       => p_rec.attribute13
337       ,p_attribute14
338       => p_rec.attribute14
339       ,p_attribute15
340       => p_rec.attribute15
341       ,p_attribute16
342       => p_rec.attribute16
343       ,p_attribute17
344       => p_rec.attribute17
345       ,p_attribute18
346       => p_rec.attribute18
347       ,p_attribute19
348       => p_rec.attribute19
349       ,p_attribute20
350       => p_rec.attribute20
351       ,p_attribute21
352       => p_rec.attribute21
353       ,p_attribute22
354       => p_rec.attribute22
355       ,p_attribute23
356       => p_rec.attribute23
357       ,p_attribute24
358       => p_rec.attribute24
359       ,p_attribute25
360       => p_rec.attribute25
361       ,p_attribute26
362       => p_rec.attribute26
363       ,p_attribute27
364       => p_rec.attribute27
365       ,p_attribute28
366       => p_rec.attribute28
367       ,p_attribute29
368       => p_rec.attribute29
369       ,p_attribute30
370       => p_rec.attribute30
371       ,p_object_version_number
372       => p_rec.object_version_number
373       );
374     --
375   exception
376     --
377     when hr_api.cannot_find_prog_unit then
378       --
379       hr_api.cannot_find_prog_unit_error
380         (p_module_name => 'HXC_ALIAS_VALUES'
381         ,p_hook_type   => 'AI');
382       --
383   end;
384   --
385   if g_debug then
386 	hr_utility.set_location(' Leaving:'||l_proc, 10);
387   end if;
388 End post_insert;
389 --
390 -- ----------------------------------------------------------------------------
391 -- |---------------------------------< ins >----------------------------------|
392 -- ----------------------------------------------------------------------------
393 Procedure ins
394   (p_rec                          in out nocopy hxc_hav_shd.g_rec_type
395   ) is
396 --
397   l_proc  varchar2(72);
398 --
399 Begin
400   g_debug:=hr_utility.debug_enabled;
401   if g_debug then
402 	l_proc := g_package||'ins';
403 	hr_utility.set_location('Entering:'||l_proc, 5);
404   end if;
405   --
406   -- Call the supporting insert validate operations
407   --
408   hxc_hav_bus.insert_validate
409      (p_rec
410      );
411   --
412   -- Call the supporting pre-insert operation
413   --
414   hxc_hav_ins.pre_insert(p_rec);
415   --
416   -- Insert the row
417   --
418   hxc_hav_ins.insert_dml(p_rec);
419   --
420   -- Call the supporting post-insert operation
421   --
422   hxc_hav_ins.post_insert
423      (p_rec
424      );
425   --
426   if g_debug then
427 	hr_utility.set_location('Leaving:'||l_proc, 20);
428   end if;
429 end ins;
430 --
431 -- ----------------------------------------------------------------------------
432 -- |---------------------------------< ins >----------------------------------|
433 -- ----------------------------------------------------------------------------
434 Procedure ins
435   (p_alias_value_name               in     varchar2
436   ,p_date_from                      in     date
437   ,p_alias_definition_id            in     number
438   ,p_enabled_flag                   in     varchar2
439   ,p_date_to                        in     date     default null
440   ,p_attribute_category             in     varchar2 default null
441   ,p_attribute1                     in     varchar2 default null
442   ,p_attribute2                     in     varchar2 default null
443   ,p_attribute3                     in     varchar2 default null
444   ,p_attribute4                     in     varchar2 default null
445   ,p_attribute5                     in     varchar2 default null
446   ,p_attribute6                     in     varchar2 default null
447   ,p_attribute7                     in     varchar2 default null
448   ,p_attribute8                     in     varchar2 default null
449   ,p_attribute9                     in     varchar2 default null
450   ,p_attribute10                    in     varchar2 default null
451   ,p_attribute11                    in     varchar2 default null
452   ,p_attribute12                    in     varchar2 default null
453   ,p_attribute13                    in     varchar2 default null
454   ,p_attribute14                    in     varchar2 default null
455   ,p_attribute15                    in     varchar2 default null
456   ,p_attribute16                    in     varchar2 default null
457   ,p_attribute17                    in     varchar2 default null
458   ,p_attribute18                    in     varchar2 default null
459   ,p_attribute19                    in     varchar2 default null
460   ,p_attribute20                    in     varchar2 default null
461   ,p_attribute21                    in     varchar2 default null
462   ,p_attribute22                    in     varchar2 default null
463   ,p_attribute23                    in     varchar2 default null
464   ,p_attribute24                    in     varchar2 default null
465   ,p_attribute25                    in     varchar2 default null
466   ,p_attribute26                    in     varchar2 default null
467   ,p_attribute27                    in     varchar2 default null
468   ,p_attribute28                    in     varchar2 default null
469   ,p_attribute29                    in     varchar2 default null
470   ,p_attribute30                    in     varchar2 default null
471   ,p_alias_value_id                    out nocopy number
472   ,p_object_version_number             out nocopy number
473   ) is
474 --
475   l_rec	  hxc_hav_shd.g_rec_type;
476   l_proc  varchar2(72);
477 --
478 Begin
479   g_debug:=hr_utility.debug_enabled;
480   if g_debug then
481 	l_proc := g_package||'ins';
482 	hr_utility.set_location('Entering:'||l_proc, 5);
483   end if;
484   --
485   -- Call conversion function to turn arguments into the
486   -- p_rec structure.
487   --
488   l_rec :=
489   hxc_hav_shd.convert_args
490     (null
491     ,p_alias_value_name
492     ,p_date_from
493     ,p_date_to
494     ,p_alias_definition_id
495     ,p_enabled_flag
496     ,p_attribute_category
497     ,p_attribute1
498     ,p_attribute2
499     ,p_attribute3
500     ,p_attribute4
501     ,p_attribute5
502     ,p_attribute6
503     ,p_attribute7
504     ,p_attribute8
505     ,p_attribute9
506     ,p_attribute10
507     ,p_attribute11
508     ,p_attribute12
509     ,p_attribute13
510     ,p_attribute14
511     ,p_attribute15
512     ,p_attribute16
513     ,p_attribute17
514     ,p_attribute18
515     ,p_attribute19
516     ,p_attribute20
517     ,p_attribute21
518     ,p_attribute22
519     ,p_attribute23
520     ,p_attribute24
521     ,p_attribute25
522     ,p_attribute26
523     ,p_attribute27
524     ,p_attribute28
525     ,p_attribute29
526     ,p_attribute30
527     ,null
528     );
529   --
530   -- Having converted the arguments into the hxc_hav_rec
531   -- plsql record structure we call the corresponding record business process.
532   --
533   hxc_hav_ins.ins
534      (l_rec
535      );
536   --
537   -- As the primary key argument(s)
538   -- are specified as an OUT's we must set these values.
539   --
540   p_alias_value_id := l_rec.alias_value_id;
541   p_object_version_number := l_rec.object_version_number;
542 
543   -- Call row handler to insert into translated tables
544   --
545   hxc_vtl_ins.ins_tl
546   (p_language_code                  => USERENV('LANG')
547   ,p_alias_value_id                 => p_alias_value_id
548   ,p_alias_value_name               => p_alias_value_name
549   );
550 
551   --
552   if g_debug then
553 	hr_utility.set_location(' Leaving:'||l_proc, 10);
554   end if;
555 End ins;
556 --
557 end hxc_hav_ins;