DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_AUD_INS

Source


1 Package Body ben_aud_ins as
2 /* $Header: beaudrhi.pkb 120.0 2005/05/28 00:31 appldev noship $ */
3 --
4 -- --------------------------------------------------------------------------
5 -- |                     Private Global Definitions                         |
6 -- --------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_aud_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_cwb_audit_id_i  number   default null;
14 --
15 -- -------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >--------------------------|
17 -- -------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_cwb_audit_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   ben_aud_ins.g_cwb_audit_id_i := p_cwb_audit_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- -------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >---------------------------|
34 -- -------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- --------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy ben_aud_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: ben_cwb_audit
88   --
89   insert into ben_cwb_audit
90       (cwb_audit_id
91       ,group_per_in_ler_id
92       ,group_pl_id
93       ,lf_evt_ocrd_dt
94       ,pl_id
95       ,group_oipl_id
96       ,audit_type_cd
97       ,old_val_varchar
98       ,new_val_varchar
99       ,old_val_number
100       ,new_val_number
101       ,old_val_date
102       ,new_val_date
103       ,date_stamp
104       ,change_made_by_person_id
105       ,supporting_information
106       ,request_id
107       ,object_version_number
108       )
109   Values
110     (p_rec.cwb_audit_id
111     ,p_rec.group_per_in_ler_id
112     ,p_rec.group_pl_id
113     ,p_rec.lf_evt_ocrd_dt
114     ,p_rec.pl_id
115     ,p_rec.group_oipl_id
116     ,p_rec.audit_type_cd
117     ,p_rec.old_val_varchar
118     ,p_rec.new_val_varchar
119     ,p_rec.old_val_number
120     ,p_rec.new_val_number
121     ,p_rec.old_val_date
122     ,p_rec.new_val_date
123     ,p_rec.date_stamp
124     ,p_rec.change_made_by_person_id
125     ,p_rec.supporting_information
126     ,p_rec.request_id
127     ,p_rec.object_version_number
128     );
129   --
130   --
131   --
132   hr_utility.set_location(' Leaving:'||l_proc, 10);
133 Exception
134   When hr_api.check_integrity_violated Then
135     -- A check constraint has been violated
136     --
137     ben_aud_shd.constraint_error
138       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
139   When hr_api.parent_integrity_violated Then
140     -- Parent integrity has been violated
141     --
142     ben_aud_shd.constraint_error
143       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
144   When hr_api.unique_integrity_violated Then
145     -- Unique integrity has been violated
146     --
147     ben_aud_shd.constraint_error
148       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
149   When Others Then
150     --
151     Raise;
152 End insert_dml;
153 --
154 -- -------------------------------------------------------------------------
155 -- |------------------------------< pre_insert >---------------------------|
156 -- -------------------------------------------------------------------------
157 -- {Start Of Comments}
158 --
159 -- Description:
160 --   This private procedure contains any processing which is required before
161 --   the insert dml. Presently, if the entity has a corresponding primary
162 --   key which is maintained by an associating sequence, the primary key for
163 --   the entity will be populated with the next sequence value in
164 --   preparation for the insert dml.
165 --
166 -- Prerequisites:
167 --   This is an internal procedure which is called from the ins procedure.
168 --
169 -- In Parameters:
170 --   A Pl/Sql record structure.
171 --
172 -- Post Success:
173 --   Processing continues.
174 --
175 -- Post Failure:
176 --   If an error has occurred, an error message and exception will be raised
177 --   but not handled.
178 --
179 -- Developer Implementation Notes:
180 --   Any pre-processing required before the insert dml is issued should be
181 --   coded within this procedure. As stated above, a good example is the
182 --   generation of a primary key number via a corresponding sequence.
183 --   It is important to note that any 3rd party maintenance should be reviewed
184 --   before placing in this procedure.
185 --
186 -- Access Status:
187 --   Internal Row Handler Use Only.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure pre_insert
192   (p_rec  in out nocopy ben_aud_shd.g_rec_type
193   ) is
194 --
195   Cursor C_Sel1 is select ben_cwb_audit_s.nextval from sys.dual;
196 --
197   Cursor C_Sel2 is
198     Select null
199       from ben_cwb_audit
200      where cwb_audit_id =
201              ben_aud_ins.g_cwb_audit_id_i;
202 --
203   l_proc   varchar2(72) := g_package||'pre_insert';
204   l_exists varchar2(1);
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   --
209   If (ben_aud_ins.g_cwb_audit_id_i is not null) Then
210     --
211     -- Verify registered primary key values not already in use
212     --
213     Open C_Sel2;
214     Fetch C_Sel2 into l_exists;
215     If C_Sel2%found Then
216        Close C_Sel2;
217        --
218        -- The primary key values are already in use.
219        --
220        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
221        fnd_message.set_token('TABLE_NAME','ben_cwb_audit');
222        fnd_message.raise_error;
223     End If;
224     Close C_Sel2;
225     --
226     -- Use registered key values and clear globals
227     --
228     p_rec.cwb_audit_id :=
229       ben_aud_ins.g_cwb_audit_id_i;
230     ben_aud_ins.g_cwb_audit_id_i := null;
231   Else
232     --
233     -- No registerd key values, so select the next sequence number
234     --
235     --
236     -- Select the next sequence number
237     --
238     Open C_Sel1;
239     Fetch C_Sel1 Into p_rec.cwb_audit_id;
240     Close C_Sel1;
241   End If;
242   --
243   hr_utility.set_location(' Leaving:'||l_proc, 10);
244 End pre_insert;
245 --
246 -- --------------------------------------------------------------------------
247 -- |-----------------------------< post_insert >----------------------------|
248 -- --------------------------------------------------------------------------
249 -- {Start Of Comments}
250 --
251 -- Description:
252 --   This private procedure contains any processing which is required after
253 --   the insert dml.
254 --
255 -- Prerequisites:
256 --   This is an internal procedure which is called from the ins procedure.
257 --
258 -- In Parameters:
259 --   A Pl/Sql record structre.
260 --
261 -- Post Success:
262 --   Processing continues.
263 --
264 -- Post Failure:
265 --   If an error has occurred, an error message and exception will be raised
266 --   but not handled.
267 --
268 -- Developer Implementation Notes:
269 --   Any post-processing required after the insert dml is issued should be
270 --   coded within this procedure. It is important to note that any 3rd party
271 --   maintenance should be reviewed before placing in this procedure.
272 --
273 -- Access Status:
274 --   Internal Row Handler Use Only.
275 --
276 -- {End Of Comments}
277 -- --------------------------------------------------------------------------
278 Procedure post_insert
279   (p_rec                          in ben_aud_shd.g_rec_type
280   ) is
281 --
282   l_proc  varchar2(72) := g_package||'post_insert';
283 --
284 Begin
285   hr_utility.set_location('Entering:'||l_proc, 5);
286   begin
287     --
288     ben_aud_rki.after_insert
289       (p_cwb_audit_id
290       => p_rec.cwb_audit_id
291       ,p_group_per_in_ler_id
292       => p_rec.group_per_in_ler_id
293       ,p_group_pl_id
294       => p_rec.group_pl_id
295       ,p_lf_evt_ocrd_dt
296       => p_rec.lf_evt_ocrd_dt
297       ,p_pl_id
298       => p_rec.pl_id
299       ,p_group_oipl_id
300       => p_rec.group_oipl_id
301       ,p_audit_type_cd
302       => p_rec.audit_type_cd
303       ,p_old_val_varchar
304       => p_rec.old_val_varchar
305       ,p_new_val_varchar
306       => p_rec.new_val_varchar
307       ,p_old_val_number
308       => p_rec.old_val_number
309       ,p_new_val_number
310       => p_rec.new_val_number
311       ,p_old_val_date
312       => p_rec.old_val_date
313       ,p_new_val_date
314       => p_rec.new_val_date
315       ,p_date_stamp
316       => p_rec.date_stamp
317       ,p_change_made_by_person_id
318       => p_rec.change_made_by_person_id
319       ,p_supporting_information
320       => p_rec.supporting_information
321       ,p_request_id
322       => p_rec.request_id
323       ,p_object_version_number
324       => p_rec.object_version_number
325       );
326     --
327   exception
328     --
329     when hr_api.cannot_find_prog_unit then
330       --
331       hr_api.cannot_find_prog_unit_error
332         (p_module_name => 'BEN_CWB_AUDIT'
333         ,p_hook_type   => 'AI');
334       --
335   end;
336   --
337   hr_utility.set_location(' Leaving:'||l_proc, 10);
338 End post_insert;
339 --
340 -- --------------------------------------------------------------------------
341 -- |---------------------------------< ins >--------------------------------|
342 -- --------------------------------------------------------------------------
343 Procedure ins
344   (p_rec                          in out nocopy ben_aud_shd.g_rec_type
345   ) is
346 --
347   l_proc  varchar2(72) := g_package||'ins';
348 --
349 Begin
350   hr_utility.set_location('Entering:'||l_proc, 5);
351   --
352   -- Call the supporting insert validate operations
353   --
354   ben_aud_bus.insert_validate
355      (p_rec
356      );
357   --
358   -- Call to raise any errors on multi-message list
359   hr_multi_message.end_validation_set;
360   --
361   -- Call the supporting pre-insert operation
362   --
363   ben_aud_ins.pre_insert(p_rec);
364   --
365   -- Insert the row
366   --
367   ben_aud_ins.insert_dml(p_rec);
368   --
369   -- Call the supporting post-insert operation
370   --
371   ben_aud_ins.post_insert
372      (p_rec
373      );
374   --
375   -- Call to raise any errors on multi-message list
376   hr_multi_message.end_validation_set;
377   --
378   hr_utility.set_location('Leaving:'||l_proc, 20);
379 end ins;
380 --
381 -- --------------------------------------------------------------------------
382 -- |---------------------------------< ins >--------------------------------|
383 -- --------------------------------------------------------------------------
384 Procedure ins
385   (p_group_per_in_ler_id            in     number
386   ,p_group_pl_id                    in     number
387   ,p_lf_evt_ocrd_dt                 in     date
388   ,p_pl_id                          in     number
389   ,p_audit_type_cd                  in     varchar2
390   ,p_group_oipl_id                  in     number   default null
391   ,p_old_val_varchar                in     varchar2 default null
392   ,p_new_val_varchar                in     varchar2 default null
393   ,p_old_val_number                 in     number   default null
394   ,p_new_val_number                 in     number   default null
395   ,p_old_val_date                   in     date     default null
396   ,p_new_val_date                   in     date     default null
397   ,p_date_stamp                     in     date     default null
398   ,p_change_made_by_person_id       in     number   default null
399   ,p_supporting_information         in     varchar2 default null
400   ,p_request_id                     in     number   default null
401   ,p_cwb_audit_id                      out nocopy number
402   ,p_object_version_number             out nocopy number
403   ) is
404 --
405   l_rec   ben_aud_shd.g_rec_type;
406   l_proc  varchar2(72) := g_package||'ins';
407 --
408 Begin
409   hr_utility.set_location('Entering:'||l_proc, 5);
410   --
411   -- Call conversion function to turn arguments into the
412   -- p_rec structure.
413   --
414   l_rec :=
415   ben_aud_shd.convert_args
416     (null
417     ,p_group_per_in_ler_id
418     ,p_group_pl_id
419     ,p_lf_evt_ocrd_dt
420     ,p_pl_id
421     ,p_group_oipl_id
422     ,p_audit_type_cd
423     ,p_old_val_varchar
424     ,p_new_val_varchar
425     ,p_old_val_number
426     ,p_new_val_number
427     ,p_old_val_date
428     ,p_new_val_date
429     ,p_date_stamp
430     ,p_change_made_by_person_id
431     ,p_supporting_information
432     ,p_request_id
433     ,null
434     );
435   --
436   -- Having converted the arguments into the ben_aud_rec
437   -- plsql record structure we call the corresponding record business process.
438   --
439   ben_aud_ins.ins
440      (l_rec
441      );
442   --
443   -- As the primary key argument(s)
444   -- are specified as an OUT's we must set these values.
445   --
446   p_cwb_audit_id := l_rec.cwb_audit_id;
447   p_object_version_number := l_rec.object_version_number;
448   --
449   hr_utility.set_location(' Leaving:'||l_proc, 10);
450 End ins;
451 --
452 end ben_aud_ins;