DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XRC_INS

Source


1 Package Body ben_xrc_ins as
2 /* $Header: bexrcrhi.pkb 120.0 2005/05/28 12:37:58 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xrc_ins.';  -- Global package name
9 
10 --
11 -- ----------------------------------------------------------------------------
12 -- |-----------------------< create_app_ownerships >--------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 -- Description:
16 --   This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
17 --   when the row handler is called in the appropriate mode.
18 --
19 -- ----------------------------------------------------------------------------
20 PROCEDURE create_app_ownerships(p_pk_column  IN varchar2
21                                ,p_pk_value   IN varchar2) IS
22 --
23 CURSOR csr_definition (p_session_id NUMBER) IS
24   SELECT product_short_name
25     FROM hr_owner_definitions
26    WHERE session_id = p_session_id;
27 --
28 l_session_id NUMBER;
29 --
30 BEGIN
31   --
32   IF (hr_startup_data_api_support.return_startup_mode IN
33                                ('STARTUP','GENERIC')) THEN
34   --
35   l_session_id := nvl(hr_startup_data_api_support.g_startup_session_id
36                      ,hr_startup_data_api_support.g_session_id);
37      --
38      FOR c1 IN csr_definition(l_session_id) LOOP
39        --
40        INSERT INTO hr_application_ownerships
41          (key_name
42          ,key_value
43          ,product_name
44          )
45        VALUES
46          (p_pk_column
47          ,fnd_number.number_to_canonical(p_pk_value)
48          ,c1.product_short_name
49          );
50      END LOOP;
51   END IF;
52 END create_app_ownerships;
53 --
54 -- ----------------------------------------------------------------------------
55 -- |-----------------------< create_app_ownerships >--------------------------|
56 -- ----------------------------------------------------------------------------
57 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
58                                ,p_pk_value  IN number) IS
59 --
60 BEGIN
61   create_app_ownerships(p_pk_column, to_char(p_pk_value));
62 END create_app_ownerships;
63 
64 --
65 -- ----------------------------------------------------------------------------
66 -- |------------------------------< insert_dml >------------------------------|
67 -- ----------------------------------------------------------------------------
68 -- {Start Of Comments}
69 --
70 -- Description:
71 --   This procedure controls the actual dml insert logic. The processing of
72 --   this procedure are as follows:
73 --   1) Initialise the object_version_number to 1 if the object_version_number
74 --      is defined as an attribute for this entity.
75 --   2) To set and unset the g_api_dml status as required (as we are about to
76 --      perform dml).
77 --   3) To insert the row into the schema.
78 --   4) To trap any constraint violations that may have occurred.
79 --   5) To raise any other errors.
80 --
81 -- Prerequisites:
82 --   This is an internal private procedure which must be called from the ins
83 --   procedure and must have all mandatory attributes set (except the
84 --   object_version_number which is initialised within this procedure).
85 --
86 -- In Parameters:
87 --   A Pl/Sql record structre.
88 --
89 -- Post Success:
90 --   The specified row will be inserted into the schema.
91 --
92 -- Post Failure:
93 --   On the insert dml failure it is important to note that we always reset the
94 --   g_api_dml status to false.
95 --   If a check, unique or parent integrity constraint violation is raised the
96 --   constraint_error procedure will be called.
97 --   If any other error is reported, the error will be raised after the
98 --   g_api_dml status is reset.
99 --
100 -- Developer Implementation Notes:
101 --   None.
102 --
103 -- Access Status:
104 --   Internal Row Handler Use Only.
105 --
106 -- {End Of Comments}
107 -- ----------------------------------------------------------------------------
108 Procedure insert_dml(p_rec in out nocopy ben_xrc_shd.g_rec_type) is
109 --
110   l_proc  varchar2(72) := g_package||'insert_dml';
111 --
112 Begin
113   hr_utility.set_location('Entering:'||l_proc, 5);
114   p_rec.object_version_number := 1;  -- Initialise the object version
115   --
116   ben_xrc_shd.g_api_dml := true;  -- Set the api dml status
117   --
118   -- Insert the row into: ben_ext_rcd
119   --
120   insert into ben_ext_rcd
121   (	ext_rcd_id,
122 	name,
123 	xml_tag_name,
124 	rcd_type_cd,
125 	low_lvl_cd,
126 	business_group_id,
127 	legislation_code,
128 	xrc_attribute_category,
129 	xrc_attribute1,
130 	xrc_attribute2,
131 	xrc_attribute3,
132 	xrc_attribute4,
133 	xrc_attribute5,
134 	xrc_attribute6,
135 	xrc_attribute7,
136 	xrc_attribute8,
137 	xrc_attribute9,
138 	xrc_attribute10,
139 	xrc_attribute11,
140 	xrc_attribute12,
141 	xrc_attribute13,
142 	xrc_attribute14,
143 	xrc_attribute15,
144 	xrc_attribute16,
145 	xrc_attribute17,
146 	xrc_attribute18,
147 	xrc_attribute19,
148 	xrc_attribute20,
149 	xrc_attribute21,
150 	xrc_attribute22,
151 	xrc_attribute23,
152 	xrc_attribute24,
153 	xrc_attribute25,
154 	xrc_attribute26,
155 	xrc_attribute27,
156 	xrc_attribute28,
157 	xrc_attribute29,
158 	xrc_attribute30,
159         last_update_date,
160         creation_date,
161         last_updated_by,
162         last_update_login,
163         created_by,
164 	object_version_number
165   )
166   Values
167   (	p_rec.ext_rcd_id,
168 	p_rec.name,
169 	p_rec.xml_tag_name,
170 	p_rec.rcd_type_cd,
171 	p_rec.low_lvl_cd,
172 	p_rec.business_group_id,
173 	p_rec.legislation_code,
174 	p_rec.xrc_attribute_category,
175 	p_rec.xrc_attribute1,
176 	p_rec.xrc_attribute2,
177 	p_rec.xrc_attribute3,
178 	p_rec.xrc_attribute4,
179 	p_rec.xrc_attribute5,
180 	p_rec.xrc_attribute6,
181 	p_rec.xrc_attribute7,
182 	p_rec.xrc_attribute8,
183 	p_rec.xrc_attribute9,
184 	p_rec.xrc_attribute10,
185 	p_rec.xrc_attribute11,
186 	p_rec.xrc_attribute12,
187 	p_rec.xrc_attribute13,
188 	p_rec.xrc_attribute14,
189 	p_rec.xrc_attribute15,
190 	p_rec.xrc_attribute16,
191 	p_rec.xrc_attribute17,
192 	p_rec.xrc_attribute18,
193 	p_rec.xrc_attribute19,
194 	p_rec.xrc_attribute20,
195 	p_rec.xrc_attribute21,
196 	p_rec.xrc_attribute22,
197 	p_rec.xrc_attribute23,
198 	p_rec.xrc_attribute24,
199 	p_rec.xrc_attribute25,
200 	p_rec.xrc_attribute26,
201 	p_rec.xrc_attribute27,
202 	p_rec.xrc_attribute28,
203 	p_rec.xrc_attribute29,
204 	p_rec.xrc_attribute30,
205         p_rec.last_update_date,
206         p_rec.creation_date,
207         p_rec.last_updated_by,
208         p_rec.last_update_login,
209         p_rec.created_by,
210 	p_rec.object_version_number
211   );
212   --
213   ben_xrc_shd.g_api_dml := false;   -- Unset the api dml status
214   --
215   hr_utility.set_location(' Leaving:'||l_proc, 10);
216 Exception
217   When hr_api.check_integrity_violated Then
218     -- A check constraint has been violated
219     ben_xrc_shd.g_api_dml := false;   -- Unset the api dml status
220     ben_xrc_shd.constraint_error
221       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
222   When hr_api.parent_integrity_violated Then
223     -- Parent integrity has been violated
224     ben_xrc_shd.g_api_dml := false;   -- Unset the api dml status
225     ben_xrc_shd.constraint_error
226       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
227   When hr_api.unique_integrity_violated Then
228     -- Unique integrity has been violated
229     ben_xrc_shd.g_api_dml := false;   -- Unset the api dml status
230     ben_xrc_shd.constraint_error
231       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
232   When Others Then
233     ben_xrc_shd.g_api_dml := false;   -- Unset the api dml status
234     Raise;
235 End insert_dml;
236 --
237 -- ----------------------------------------------------------------------------
238 -- |------------------------------< pre_insert >------------------------------|
239 -- ----------------------------------------------------------------------------
240 -- {Start Of Comments}
241 --
242 -- Description:
243 --   This private procedure contains any processing which is required before
244 --   the insert dml. Presently, if the entity has a corresponding primary
245 --   key which is maintained by an associating sequence, the primary key for
246 --   the entity will be populated with the next sequence value in
247 --   preparation for the insert dml.
248 --
249 -- Prerequisites:
250 --   This is an internal procedure which is called from the ins procedure.
251 --
252 -- In Parameters:
253 --   A Pl/Sql record structre.
254 --
255 -- Post Success:
256 --   Processing continues.
257 --
258 -- Post Failure:
259 --   If an error has occurred, an error message and exception will be raised
260 --   but not handled.
261 --
262 -- Developer Implementation Notes:
263 --   Any pre-processing required before the insert dml is issued should be
264 --   coded within this procedure. As stated above, a good example is the
265 --   generation of a primary key number via a corresponding sequence.
266 --   It is important to note that any 3rd party maintenance should be reviewed
267 --   before placing in this procedure.
268 --
269 -- Access Status:
270 --   Internal Row Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure pre_insert(p_rec  in out nocopy ben_xrc_shd.g_rec_type) is
275 --
276   l_proc  varchar2(72) := g_package||'pre_insert';
277 --
278   Cursor C_Sel1 is select ben_ext_rcd_s.nextval from sys.dual;
279 --
280 Begin
281   hr_utility.set_location('Entering:'||l_proc, 5);
282   --
283   --
284   -- Select the next sequence number
285   --
286   Open C_Sel1;
287   Fetch C_Sel1 Into p_rec.ext_rcd_id;
288   Close C_Sel1;
289   --
290   hr_utility.set_location(' Leaving:'||l_proc, 10);
291 End pre_insert;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |-----------------------------< post_insert >------------------------------|
295 -- ----------------------------------------------------------------------------
296 -- {Start Of Comments}
297 --
298 -- Description:
299 --   This private procedure contains any processing which is required after the
300 --   insert dml.
301 --
302 -- Prerequisites:
303 --   This is an internal procedure which is called from the ins procedure.
304 --
305 -- In Parameters:
306 --   A Pl/Sql record structre.
307 --
308 -- Post Success:
309 --   Processing continues.
310 --
311 -- Post Failure:
312 --   If an error has occurred, an error message and exception will be raised
313 --   but not handled.
314 --
315 -- Developer Implementation Notes:
316 --   Any post-processing required after the insert dml is issued should be
317 --   coded within this procedure. It is important to note that any 3rd party
318 --   maintenance should be reviewed before placing in this procedure.
319 --
320 -- Access Status:
321 --   Internal Row Handler Use Only.
322 --
323 -- {End Of Comments}
324 -- ----------------------------------------------------------------------------
325 Procedure post_insert(
326 p_effective_date in date,p_rec in ben_xrc_shd.g_rec_type) is
327 --
328   l_proc  varchar2(72) := g_package||'post_insert';
329 --
330 Begin
331   hr_utility.set_location('Entering:'||l_proc, 5);
332 --
333   --
334   -- insert ownerships if applicable
335   --
336   create_app_ownerships('EXT_RCD_ID', p_rec.ext_rcd_id);
337 
338   --
339   -- Start of API User Hook for post_insert.
340   --
341   begin
342     --
343     ben_xrc_rki.after_insert
344       (
345   p_ext_rcd_id                    =>p_rec.ext_rcd_id
346  ,p_name                          =>p_rec.name
347  ,p_xml_tag_name                  =>p_rec.xml_tag_name
348  ,p_rcd_type_cd                   =>p_rec.rcd_type_cd
349  ,p_low_lvl_cd                    =>p_rec.low_lvl_cd
350  ,p_business_group_id             =>p_rec.business_group_id
351  ,p_legislation_code              =>p_rec.legislation_code
352  ,p_xrc_attribute_category        =>p_rec.xrc_attribute_category
353  ,p_xrc_attribute1                =>p_rec.xrc_attribute1
354  ,p_xrc_attribute2                =>p_rec.xrc_attribute2
355  ,p_xrc_attribute3                =>p_rec.xrc_attribute3
356  ,p_xrc_attribute4                =>p_rec.xrc_attribute4
357  ,p_xrc_attribute5                =>p_rec.xrc_attribute5
358  ,p_xrc_attribute6                =>p_rec.xrc_attribute6
359  ,p_xrc_attribute7                =>p_rec.xrc_attribute7
360  ,p_xrc_attribute8                =>p_rec.xrc_attribute8
361  ,p_xrc_attribute9                =>p_rec.xrc_attribute9
362  ,p_xrc_attribute10               =>p_rec.xrc_attribute10
363  ,p_xrc_attribute11               =>p_rec.xrc_attribute11
364  ,p_xrc_attribute12               =>p_rec.xrc_attribute12
365  ,p_xrc_attribute13               =>p_rec.xrc_attribute13
366  ,p_xrc_attribute14               =>p_rec.xrc_attribute14
367  ,p_xrc_attribute15               =>p_rec.xrc_attribute15
368  ,p_xrc_attribute16               =>p_rec.xrc_attribute16
369  ,p_xrc_attribute17               =>p_rec.xrc_attribute17
370  ,p_xrc_attribute18               =>p_rec.xrc_attribute18
371  ,p_xrc_attribute19               =>p_rec.xrc_attribute19
372  ,p_xrc_attribute20               =>p_rec.xrc_attribute20
373  ,p_xrc_attribute21               =>p_rec.xrc_attribute21
374  ,p_xrc_attribute22               =>p_rec.xrc_attribute22
375  ,p_xrc_attribute23               =>p_rec.xrc_attribute23
376  ,p_xrc_attribute24               =>p_rec.xrc_attribute24
377  ,p_xrc_attribute25               =>p_rec.xrc_attribute25
378  ,p_xrc_attribute26               =>p_rec.xrc_attribute26
379  ,p_xrc_attribute27               =>p_rec.xrc_attribute27
380  ,p_xrc_attribute28               =>p_rec.xrc_attribute28
381  ,p_xrc_attribute29               =>p_rec.xrc_attribute29
382  ,p_xrc_attribute30               =>p_rec.xrc_attribute30
383  ,p_object_version_number         =>p_rec.object_version_number
384  ,p_effective_date                =>p_effective_date
385       );
386     --
387   exception
388     --
389     when hr_api.cannot_find_prog_unit then
390       --
391       hr_api.cannot_find_prog_unit_error
392         (p_module_name => 'ben_ext_rcd'
393         ,p_hook_type   => 'AI');
394       --
395   end;
396   --
397   -- End of API User Hook for post_insert.
398   --
399   --
400   hr_utility.set_location(' Leaving:'||l_proc, 10);
401 End post_insert;
402 --
403 -- ----------------------------------------------------------------------------
404 -- |---------------------------------< ins >----------------------------------|
405 -- ----------------------------------------------------------------------------
406 Procedure ins
407   (
408   p_effective_date in date,
409   p_rec        in out nocopy ben_xrc_shd.g_rec_type
410   ) is
411 --
412   l_proc  varchar2(72) := g_package||'ins';
413 --
414 Begin
415   hr_utility.set_location('Entering:'||l_proc, 5);
416   --
417   -- Call the supporting insert validate operations
418   --
419   ben_xrc_bus.insert_validate(p_rec
420   ,p_effective_date);
421   --
422   ben_xel_bus.chk_xml_name_format
423       ( p_xml_tag_name    => p_rec.xml_tag_name
424       ) ;
425 
426   -- Call the supporting pre-insert operation
427   --
428   pre_insert(p_rec);
429   --
430   -- Insert the row
431   --
432   insert_dml(p_rec);
433   --
434   -- Call the supporting post-insert operation
435   --
436   post_insert(
437 p_effective_date,p_rec);
438 end ins;
439 --
440 -- ----------------------------------------------------------------------------
441 -- |---------------------------------< ins >----------------------------------|
442 -- ----------------------------------------------------------------------------
443 Procedure ins
444   (
445   p_effective_date in date,
446   p_ext_rcd_id                   out nocopy number,
447   p_name                         in varchar2         default null,
448   p_xml_tag_name                 in varchar2         default null,
449   p_rcd_type_cd                  in varchar2         default null,
450   p_low_lvl_cd                   in varchar2         default null,
451   p_business_group_id            in number,
452   p_legislation_code             in varchar2         default null,
453   p_xrc_attribute_category       in varchar2         default null,
454   p_xrc_attribute1               in varchar2         default null,
455   p_xrc_attribute2               in varchar2         default null,
456   p_xrc_attribute3               in varchar2         default null,
457   p_xrc_attribute4               in varchar2         default null,
458   p_xrc_attribute5               in varchar2         default null,
459   p_xrc_attribute6               in varchar2         default null,
460   p_xrc_attribute7               in varchar2         default null,
461   p_xrc_attribute8               in varchar2         default null,
462   p_xrc_attribute9               in varchar2         default null,
463   p_xrc_attribute10              in varchar2         default null,
464   p_xrc_attribute11              in varchar2         default null,
465   p_xrc_attribute12              in varchar2         default null,
466   p_xrc_attribute13              in varchar2         default null,
467   p_xrc_attribute14              in varchar2         default null,
468   p_xrc_attribute15              in varchar2         default null,
469   p_xrc_attribute16              in varchar2         default null,
470   p_xrc_attribute17              in varchar2         default null,
471   p_xrc_attribute18              in varchar2         default null,
472   p_xrc_attribute19              in varchar2         default null,
473   p_xrc_attribute20              in varchar2         default null,
474   p_xrc_attribute21              in varchar2         default null,
475   p_xrc_attribute22              in varchar2         default null,
476   p_xrc_attribute23              in varchar2         default null,
477   p_xrc_attribute24              in varchar2         default null,
478   p_xrc_attribute25              in varchar2         default null,
479   p_xrc_attribute26              in varchar2         default null,
480   p_xrc_attribute27              in varchar2         default null,
481   p_xrc_attribute28              in varchar2         default null,
482   p_xrc_attribute29              in varchar2         default null,
483   p_xrc_attribute30              in varchar2         default null,
484   p_last_update_date             in date             default null,
485   p_creation_date                in date             default null,
486   p_last_updated_by              in number           default null,
487   p_last_update_login            in number           default null,
488   p_created_by                   in number           default null,
489   p_object_version_number        out nocopy number
490   ) is
491 --
492   l_rec	  ben_xrc_shd.g_rec_type;
493   l_proc  varchar2(72) := g_package||'ins';
494 --
495 Begin
496   hr_utility.set_location('Entering:'||l_proc, 5);
497   --
498   -- Call conversion function to turn arguments into the
499   -- p_rec structure.
500   --
501   l_rec :=
502   ben_xrc_shd.convert_args
503   (
504   null,
505   p_name,
506   p_xml_tag_name,
507   p_rcd_type_cd,
508   p_low_lvl_cd,
509   p_business_group_id,
510   p_legislation_code,
511   p_xrc_attribute_category,
512   p_xrc_attribute1,
513   p_xrc_attribute2,
514   p_xrc_attribute3,
515   p_xrc_attribute4,
516   p_xrc_attribute5,
517   p_xrc_attribute6,
518   p_xrc_attribute7,
519   p_xrc_attribute8,
520   p_xrc_attribute9,
521   p_xrc_attribute10,
522   p_xrc_attribute11,
523   p_xrc_attribute12,
524   p_xrc_attribute13,
525   p_xrc_attribute14,
526   p_xrc_attribute15,
527   p_xrc_attribute16,
528   p_xrc_attribute17,
529   p_xrc_attribute18,
530   p_xrc_attribute19,
531   p_xrc_attribute20,
532   p_xrc_attribute21,
533   p_xrc_attribute22,
534   p_xrc_attribute23,
535   p_xrc_attribute24,
536   p_xrc_attribute25,
537   p_xrc_attribute26,
538   p_xrc_attribute27,
539   p_xrc_attribute28,
540   p_xrc_attribute29,
541   p_xrc_attribute30,
542   p_last_update_date,
543   p_creation_date   ,
544   p_last_updated_by ,
545   p_last_update_login,
546   p_created_by       ,
547   null
548   );
549   --
550   -- Having converted the arguments into the ben_xrc_rec
551   -- plsql record structure we call the corresponding record business process.
552   --
553   ins(
554     p_effective_date,l_rec);
555   --
556   -- As the primary key argument(s)
557   -- are specified as an OUT's we must set these values.
558   --
559   p_ext_rcd_id := l_rec.ext_rcd_id;
560   p_object_version_number := l_rec.object_version_number;
561   --
562   hr_utility.set_location(' Leaving:'||l_proc, 10);
563 End ins;
564 --
565 end ben_xrc_ins;