DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XCR_INS

Source


1 Package Body ben_xcr_ins as
2 /* $Header: bexcrrhi.pkb 120.0 2005/05/28 12:25:40 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xcr_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_xcr_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_xcr_shd.g_api_dml := true;  -- Set the api dml status
117   --
118   -- Insert the row into: ben_ext_crit_prfl
119   --
120   insert into ben_ext_crit_prfl
121   (	ext_crit_prfl_id,
122 	name,
123 	business_group_id,
124 	legislation_code,
125 	xcr_attribute_category,
126 	xcr_attribute1,
127 	xcr_attribute2,
128 	xcr_attribute3,
129 	xcr_attribute4,
130 	xcr_attribute5,
131 	xcr_attribute6,
132 	xcr_attribute7,
133 	xcr_attribute8,
134 	xcr_attribute9,
135 	xcr_attribute10,
136 	xcr_attribute11,
137 	xcr_attribute12,
138 	xcr_attribute13,
139 	xcr_attribute14,
140 	xcr_attribute15,
141 	xcr_attribute16,
142 	xcr_attribute17,
143 	xcr_attribute18,
144 	xcr_attribute19,
145 	xcr_attribute20,
146 	xcr_attribute21,
147 	xcr_attribute22,
148 	xcr_attribute23,
149 	xcr_attribute24,
150 	xcr_attribute25,
151 	xcr_attribute26,
152 	xcr_attribute27,
153 	xcr_attribute28,
154 	xcr_attribute29,
155 	xcr_attribute30,
156 	ext_global_flag,
157         last_update_date,
158         creation_date,
159         last_updated_by,
160         last_update_login,
161         created_by,
162 	object_version_number
163   )
164   Values
165   (	p_rec.ext_crit_prfl_id,
166 	p_rec.name,
167 	p_rec.business_group_id,
168 	p_rec.legislation_code,
169 	p_rec.xcr_attribute_category,
170 	p_rec.xcr_attribute1,
171 	p_rec.xcr_attribute2,
172 	p_rec.xcr_attribute3,
173 	p_rec.xcr_attribute4,
174 	p_rec.xcr_attribute5,
175 	p_rec.xcr_attribute6,
176 	p_rec.xcr_attribute7,
177 	p_rec.xcr_attribute8,
178 	p_rec.xcr_attribute9,
179 	p_rec.xcr_attribute10,
180 	p_rec.xcr_attribute11,
181 	p_rec.xcr_attribute12,
182 	p_rec.xcr_attribute13,
183 	p_rec.xcr_attribute14,
184 	p_rec.xcr_attribute15,
185 	p_rec.xcr_attribute16,
186 	p_rec.xcr_attribute17,
187 	p_rec.xcr_attribute18,
188 	p_rec.xcr_attribute19,
189 	p_rec.xcr_attribute20,
190 	p_rec.xcr_attribute21,
191 	p_rec.xcr_attribute22,
192 	p_rec.xcr_attribute23,
193 	p_rec.xcr_attribute24,
194 	p_rec.xcr_attribute25,
195 	p_rec.xcr_attribute26,
196 	p_rec.xcr_attribute27,
197 	p_rec.xcr_attribute28,
198 	p_rec.xcr_attribute29,
199 	p_rec.xcr_attribute30,
200 	p_rec.ext_global_flag,
201         p_rec.last_update_date,
202         p_rec.creation_date,
203         p_rec.last_updated_by,
204         p_rec.last_update_login,
205         p_rec.created_by,
206 	p_rec.object_version_number
207   );
208   --
209   ben_xcr_shd.g_api_dml := false;   -- Unset the api dml status
210   --
211   hr_utility.set_location(' Leaving:'||l_proc, 10);
212 Exception
213   When hr_api.check_integrity_violated Then
214     -- A check constraint has been violated
215     ben_xcr_shd.g_api_dml := false;   -- Unset the api dml status
216     ben_xcr_shd.constraint_error
217       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
218   When hr_api.parent_integrity_violated Then
219     -- Parent integrity has been violated
220     ben_xcr_shd.g_api_dml := false;   -- Unset the api dml status
221     ben_xcr_shd.constraint_error
222       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
223   When hr_api.unique_integrity_violated Then
224     -- Unique integrity has been violated
225     ben_xcr_shd.g_api_dml := false;   -- Unset the api dml status
226     ben_xcr_shd.constraint_error
227       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
228   When Others Then
229     ben_xcr_shd.g_api_dml := false;   -- Unset the api dml status
230     Raise;
231 End insert_dml;
232 --
233 -- ----------------------------------------------------------------------------
234 -- |------------------------------< pre_insert >------------------------------|
235 -- ----------------------------------------------------------------------------
236 -- {Start Of Comments}
237 --
238 -- Description:
239 --   This private procedure contains any processing which is required before
240 --   the insert dml. Presently, if the entity has a corresponding primary
241 --   key which is maintained by an associating sequence, the primary key for
242 --   the entity will be populated with the next sequence value in
243 --   preparation for the insert dml.
244 --
245 -- Prerequisites:
246 --   This is an internal procedure which is called from the ins procedure.
247 --
248 -- In Parameters:
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 pre-processing required before the insert dml is issued should be
260 --   coded within this procedure. As stated above, a good example is the
261 --   generation of a primary key number via a corresponding sequence.
262 --   It is important to note that any 3rd party maintenance should be reviewed
263 --   before placing in this procedure.
264 --
265 -- Access Status:
266 --   Internal Row Handler Use Only.
267 --
268 -- {End Of Comments}
269 -- ----------------------------------------------------------------------------
270 Procedure pre_insert(p_rec  in out nocopy ben_xcr_shd.g_rec_type) is
271 --
272   l_proc  varchar2(72) := g_package||'pre_insert';
273 --
274   Cursor C_Sel1 is select ben_ext_crit_prfl_s.nextval from sys.dual;
275 --
276 Begin
277   hr_utility.set_location('Entering:'||l_proc, 5);
278   --
279   --
280   -- Select the next sequence number
281   --
282   Open C_Sel1;
283   Fetch C_Sel1 Into p_rec.ext_crit_prfl_id;
284   Close C_Sel1;
285   --
286   hr_utility.set_location(' Leaving:'||l_proc, 10);
287 End pre_insert;
288 --
289 -- ----------------------------------------------------------------------------
290 -- |-----------------------------< post_insert >------------------------------|
291 -- ----------------------------------------------------------------------------
292 -- {Start Of Comments}
293 --
294 -- Description:
295 --   This private procedure contains any processing which is required after the
296 --   insert dml.
297 --
298 -- Prerequisites:
299 --   This is an internal procedure which is called from the ins procedure.
300 --
301 -- In Parameters:
302 --   A Pl/Sql record structre.
303 --
304 -- Post Success:
305 --   Processing continues.
306 --
307 -- Post Failure:
308 --   If an error has occurred, an error message and exception will be raised
309 --   but not handled.
310 --
311 -- Developer Implementation Notes:
312 --   Any post-processing required after the insert dml is issued should be
313 --   coded within this procedure. It is important to note that any 3rd party
314 --   maintenance should be reviewed before placing in this procedure.
315 --
316 -- Access Status:
317 --   Internal Row Handler Use Only.
318 --
319 -- {End Of Comments}
320 -- ----------------------------------------------------------------------------
321 Procedure post_insert(p_rec in ben_xcr_shd.g_rec_type) is
322 --
323   l_proc  varchar2(72) := g_package||'post_insert';
324 --
325 Begin
326   hr_utility.set_location('Entering:'||l_proc, 5);
327 --
328   create_app_ownerships('EXT_CRIT_PRFL_ID', p_rec.ext_crit_prfl_id);
329   --
330   -- Start of API User Hook for post_insert.
331   --
332   begin
333 
334     --
335     ben_xcr_rki.after_insert
336       (
337   p_ext_crit_prfl_id              =>p_rec.ext_crit_prfl_id
338  ,p_name                          =>p_rec.name
339  ,p_business_group_id             =>p_rec.business_group_id
340  ,p_legislation_code              =>p_rec.legislation_code
341  ,p_xcr_attribute_category        =>p_rec.xcr_attribute_category
342  ,p_xcr_attribute1                =>p_rec.xcr_attribute1
343  ,p_xcr_attribute2                =>p_rec.xcr_attribute2
344  ,p_xcr_attribute3                =>p_rec.xcr_attribute3
345  ,p_xcr_attribute4                =>p_rec.xcr_attribute4
346  ,p_xcr_attribute5                =>p_rec.xcr_attribute5
347  ,p_xcr_attribute6                =>p_rec.xcr_attribute6
348  ,p_xcr_attribute7                =>p_rec.xcr_attribute7
349  ,p_xcr_attribute8                =>p_rec.xcr_attribute8
350  ,p_xcr_attribute9                =>p_rec.xcr_attribute9
351  ,p_xcr_attribute10               =>p_rec.xcr_attribute10
352  ,p_xcr_attribute11               =>p_rec.xcr_attribute11
353  ,p_xcr_attribute12               =>p_rec.xcr_attribute12
354  ,p_xcr_attribute13               =>p_rec.xcr_attribute13
355  ,p_xcr_attribute14               =>p_rec.xcr_attribute14
356  ,p_xcr_attribute15               =>p_rec.xcr_attribute15
357  ,p_xcr_attribute16               =>p_rec.xcr_attribute16
358  ,p_xcr_attribute17               =>p_rec.xcr_attribute17
359  ,p_xcr_attribute18               =>p_rec.xcr_attribute18
360  ,p_xcr_attribute19               =>p_rec.xcr_attribute19
361  ,p_xcr_attribute20               =>p_rec.xcr_attribute20
362  ,p_xcr_attribute21               =>p_rec.xcr_attribute21
363  ,p_xcr_attribute22               =>p_rec.xcr_attribute22
364  ,p_xcr_attribute23               =>p_rec.xcr_attribute23
365  ,p_xcr_attribute24               =>p_rec.xcr_attribute24
366  ,p_xcr_attribute25               =>p_rec.xcr_attribute25
367  ,p_xcr_attribute26               =>p_rec.xcr_attribute26
368  ,p_xcr_attribute27               =>p_rec.xcr_attribute27
369  ,p_xcr_attribute28               =>p_rec.xcr_attribute28
370  ,p_xcr_attribute29               =>p_rec.xcr_attribute29
371  ,p_xcr_attribute30               =>p_rec.xcr_attribute30
372  ,p_ext_global_flag               =>p_rec.ext_global_flag
373  ,p_object_version_number         =>p_rec.object_version_number
374       );
375     --
376   exception
377     --
378     when hr_api.cannot_find_prog_unit then
379       --
380       hr_api.cannot_find_prog_unit_error
381         (p_module_name => 'ben_ext_crit_prfl'
382         ,p_hook_type   => 'AI');
383       --
384   end;
385   --
386   -- End of API User Hook for post_insert.
387   --
388   --
389   hr_utility.set_location(' Leaving:'||l_proc, 10);
390 End post_insert;
391 --
392 -- ----------------------------------------------------------------------------
393 -- |---------------------------------< ins >----------------------------------|
394 -- ----------------------------------------------------------------------------
395 Procedure ins
396   (
397   p_rec        in out nocopy ben_xcr_shd.g_rec_type
398   ) is
399 --
400   l_proc  varchar2(72) := g_package||'ins';
401 --
402 Begin
403   hr_utility.set_location('Entering:'||l_proc, 5);
404   --
405   -- Call the supporting insert validate operations
406   --
407   ben_xcr_bus.insert_validate(p_rec);
408   --
409   -- Call the supporting pre-insert operation
410   --
411   pre_insert(p_rec);
412   --
413   -- Insert the row
414   --
415   insert_dml(p_rec);
416   --
417   -- Call the supporting post-insert operation
418   --
419   post_insert(p_rec);
420 end ins;
421 --
422 -- ----------------------------------------------------------------------------
423 -- |---------------------------------< ins >----------------------------------|
424 -- ----------------------------------------------------------------------------
425 Procedure ins
426   (
427   p_ext_crit_prfl_id             out nocopy number,
428   p_name                         in varchar2         default null,
429   p_business_group_id            in number,
430   p_legislation_code             in varchar2         default null,
431   p_xcr_attribute_category       in varchar2         default null,
432   p_xcr_attribute1               in varchar2         default null,
433   p_xcr_attribute2               in varchar2         default null,
434   p_xcr_attribute3               in varchar2         default null,
435   p_xcr_attribute4               in varchar2         default null,
436   p_xcr_attribute5               in varchar2         default null,
437   p_xcr_attribute6               in varchar2         default null,
438   p_xcr_attribute7               in varchar2         default null,
439   p_xcr_attribute8               in varchar2         default null,
440   p_xcr_attribute9               in varchar2         default null,
441   p_xcr_attribute10              in varchar2         default null,
442   p_xcr_attribute11              in varchar2         default null,
443   p_xcr_attribute12              in varchar2         default null,
444   p_xcr_attribute13              in varchar2         default null,
445   p_xcr_attribute14              in varchar2         default null,
446   p_xcr_attribute15              in varchar2         default null,
447   p_xcr_attribute16              in varchar2         default null,
448   p_xcr_attribute17              in varchar2         default null,
449   p_xcr_attribute18              in varchar2         default null,
450   p_xcr_attribute19              in varchar2         default null,
451   p_xcr_attribute20              in varchar2         default null,
452   p_xcr_attribute21              in varchar2         default null,
453   p_xcr_attribute22              in varchar2         default null,
454   p_xcr_attribute23              in varchar2         default null,
455   p_xcr_attribute24              in varchar2         default null,
456   p_xcr_attribute25              in varchar2         default null,
457   p_xcr_attribute26              in varchar2         default null,
458   p_xcr_attribute27              in varchar2         default null,
459   p_xcr_attribute28              in varchar2         default null,
460   p_xcr_attribute29              in varchar2         default null,
461   p_xcr_attribute30              in varchar2         default null,
462   p_ext_global_flag              in varchar2         default null,
463   p_last_update_date             in date             default null,
464   p_creation_date                in date             default null,
465   p_last_updated_by              in number           default null,
466   p_last_update_login            in number           default null,
467   p_created_by                   in number           default null,
468   p_object_version_number        out nocopy number
469   ) is
470 --
471   l_rec	  ben_xcr_shd.g_rec_type;
472   l_proc  varchar2(72) := g_package||'ins';
473 --
474 Begin
475   hr_utility.set_location('Entering:'||l_proc, 5);
476   --
477   -- Call conversion function to turn arguments into the
478   -- p_rec structure.
479   --
480   l_rec :=
481   ben_xcr_shd.convert_args
482   (
483   null,
484   p_name,
485   p_business_group_id,
486   p_legislation_code,
487   p_xcr_attribute_category,
488   p_xcr_attribute1,
489   p_xcr_attribute2,
490   p_xcr_attribute3,
491   p_xcr_attribute4,
492   p_xcr_attribute5,
493   p_xcr_attribute6,
494   p_xcr_attribute7,
495   p_xcr_attribute8,
496   p_xcr_attribute9,
497   p_xcr_attribute10,
498   p_xcr_attribute11,
499   p_xcr_attribute12,
500   p_xcr_attribute13,
501   p_xcr_attribute14,
502   p_xcr_attribute15,
503   p_xcr_attribute16,
504   p_xcr_attribute17,
505   p_xcr_attribute18,
506   p_xcr_attribute19,
507   p_xcr_attribute20,
508   p_xcr_attribute21,
509   p_xcr_attribute22,
510   p_xcr_attribute23,
511   p_xcr_attribute24,
512   p_xcr_attribute25,
513   p_xcr_attribute26,
514   p_xcr_attribute27,
515   p_xcr_attribute28,
516   p_xcr_attribute29,
517   p_xcr_attribute30,
518   p_ext_global_flag,
519   p_last_update_date,
520   p_creation_date   ,
521   p_last_updated_by ,
522   p_last_update_login,
523   p_created_by       ,
524   null
525   );
526   --
527   -- Having converted the arguments into the ben_xcr_rec
528   -- plsql record structure we call the corresponding record business process.
529   --
530   ins(l_rec);
531   --
532   -- As the primary key argument(s)
533   -- are specified as an OUT's we must set these values.
534   --
535   p_ext_crit_prfl_id := l_rec.ext_crit_prfl_id;
536   p_object_version_number := l_rec.object_version_number;
537   --
538   hr_utility.set_location(' Leaving:'||l_proc, 10);
539 End ins;
540 --
541 end ben_xcr_ins;