DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XRE_INS

Source


1 Package Body ben_xre_ins as
2 /* $Header: bexrerhi.pkb 115.8 2002/12/16 17:41:12 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xre_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy ben_xre_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   ben_xre_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_ext_rslt_err
64   --
65   insert into ben_ext_rslt_err
66   (	ext_rslt_err_id,
67 	err_num,
68         err_txt,
69 	typ_cd,
70 	person_id,
71 	business_group_id,
72 	object_version_number,
73 	request_id,
74 	program_application_id,
75 	program_id,
76 	program_update_date,
77         ext_rslt_id
78   )
79   Values
80   (	p_rec.ext_rslt_err_id,
81 	p_rec.err_num,
82         p_rec.err_txt,
83 	p_rec.typ_cd,
84 	p_rec.person_id,
85 	p_rec.business_group_id,
86 	p_rec.object_version_number,
87 	p_rec.request_id,
88 	p_rec.program_application_id,
89 	p_rec.program_id,
90 	p_rec.program_update_date,
91         p_rec.ext_rslt_id
92   );
93   --
94   ben_xre_shd.g_api_dml := false;   -- Unset the api dml status
95   --
96   hr_utility.set_location(' Leaving:'||l_proc, 10);
97 Exception
98   When hr_api.check_integrity_violated Then
99     -- A check constraint has been violated
100     ben_xre_shd.g_api_dml := false;   -- Unset the api dml status
101     ben_xre_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When hr_api.parent_integrity_violated Then
104     -- Parent integrity has been violated
105     ben_xre_shd.g_api_dml := false;   -- Unset the api dml status
106     ben_xre_shd.constraint_error
107       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108   When hr_api.unique_integrity_violated Then
109     -- Unique integrity has been violated
110     ben_xre_shd.g_api_dml := false;   -- Unset the api dml status
111     ben_xre_shd.constraint_error
112       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113   When Others Then
114     ben_xre_shd.g_api_dml := false;   -- Unset the api dml status
115     Raise;
116 End insert_dml;
117 --
118 -- ----------------------------------------------------------------------------
119 -- |------------------------------< pre_insert >------------------------------|
120 -- ----------------------------------------------------------------------------
121 -- {Start Of Comments}
122 --
123 -- Description:
124 --   This private procedure contains any processing which is required before
125 --   the insert dml. Presently, if the entity has a corresponding primary
126 --   key which is maintained by an associating sequence, the primary key for
127 --   the entity will be populated with the next sequence value in
128 --   preparation for the insert dml.
129 --
130 -- Prerequisites:
131 --   This is an internal procedure which is called from the ins procedure.
132 --
133 -- In Parameters:
134 --   A Pl/Sql record structre.
135 --
136 -- Post Success:
137 --   Processing continues.
138 --
139 -- Post Failure:
140 --   If an error has occurred, an error message and exception will be raised
141 --   but not handled.
142 --
143 -- Developer Implementation Notes:
144 --   Any pre-processing required before the insert dml is issued should be
145 --   coded within this procedure. As stated above, a good example is the
146 --   generation of a primary key number via a corresponding sequence.
147 --   It is important to note that any 3rd party maintenance should be reviewed
148 --   before placing in this procedure.
149 --
150 -- Access Status:
151 --   Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure pre_insert(p_rec  in out nocopy ben_xre_shd.g_rec_type) is
156 --
157   l_proc  varchar2(72) := g_package||'pre_insert';
158 --
159  			   cursor c1 is
160     			              select ben_ext_rslt_err_s.nextval
161      				from sys.dual;
162 --
163 --
164 Begin
165   hr_utility.set_location('Entering:'||l_proc, 5);
166   --
167       open c1;
168         fetch c1 into p_rec.ext_rslt_err_id;
169       close c1;
170 
171   --
172   --
173   hr_utility.set_location(' Leaving:'||l_proc, 10);
174 End pre_insert;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |-----------------------------< post_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 --   This private procedure contains any processing which is required after the
183 --   insert dml.
184 --
185 -- Prerequisites:
186 --   This is an internal procedure which is called from the ins procedure.
187 --
188 -- In Parameters:
189 --   A Pl/Sql record structre.
190 --
191 -- Post Success:
192 --   Processing continues.
193 --
194 -- Post Failure:
195 --   If an error has occurred, an error message and exception will be raised
196 --   but not handled.
197 --
198 -- Developer Implementation Notes:
199 --   Any post-processing required after the insert dml is issued should be
200 --   coded within this procedure. It is important to note that any 3rd party
201 --   maintenance should be reviewed before placing in this procedure.
202 --
203 -- Access Status:
204 --   Internal Row Handler Use Only.
205 --
206 -- {End Of Comments}
207 -- ----------------------------------------------------------------------------
208 Procedure post_insert(
209 p_effective_date in date,p_rec in ben_xre_shd.g_rec_type) is
210 --
211   l_proc  varchar2(72) := g_package||'post_insert';
212 --
213 Begin
214   hr_utility.set_location('Entering:'||l_proc, 5);
215 --
216   --
217   -- Start of API User Hook for post_insert.
218   --
219   begin
220     --
221     ben_xre_rki.after_insert
222       (
223   p_ext_rslt_err_id               =>p_rec.ext_rslt_err_id
224  ,p_err_num                       =>p_rec.err_num
225  ,p_err_txt                       =>p_rec.err_txt
226  ,p_typ_cd                        =>p_rec.typ_cd
227  ,p_person_id                     =>p_rec.person_id
228  ,p_business_group_id             =>p_rec.business_group_id
229  ,p_object_version_number         =>p_rec.object_version_number
230  ,p_request_id                    =>p_rec.request_id
231  ,p_program_application_id        =>p_rec.program_application_id
232  ,p_program_id                    =>p_rec.program_id
233  ,p_program_update_date           =>p_rec.program_update_date
234  ,p_ext_rslt_id                   =>p_rec.ext_rslt_id
235  ,p_effective_date                =>p_effective_date
236       );
237     --
238   exception
239     --
240     when hr_api.cannot_find_prog_unit then
241       --
242       hr_api.cannot_find_prog_unit_error
243         (p_module_name => 'ben_ext_rslt_err'
244         ,p_hook_type   => 'AI');
245       --
246   end;
247   --
248   -- End of API User Hook for post_insert.
249   --
250   --
251   hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End post_insert;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |---------------------------------< ins >----------------------------------|
256 -- ----------------------------------------------------------------------------
257 Procedure ins
258   (
259   p_effective_date in date,
260   p_rec        in out nocopy ben_xre_shd.g_rec_type
261   ) is
262 --
263   l_proc  varchar2(72) := g_package||'ins';
264 --
265 Begin
266   hr_utility.set_location('Entering:'||l_proc, 5);
267   --
268   -- Call the supporting insert validate operations
269   --
270   ben_xre_bus.insert_validate(p_rec
271   ,p_effective_date);
272   --
273   -- Call the supporting pre-insert operation
274   --
275   pre_insert(p_rec);
276   --
277   -- Insert the row
278   --
279   insert_dml(p_rec);
280   --
281   -- Call the supporting post-insert operation
282   --
283   post_insert(
284 p_effective_date,p_rec);
285 end ins;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |---------------------------------< ins >----------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure ins
291   (
292   p_effective_date in date,
293   p_ext_rslt_err_id              out nocopy number,
294   p_err_num                      in number           default null,
295   p_err_txt                      in varchar2         default null,
296   p_typ_cd                       in varchar2         default null,
297   p_person_id                    in number,
298   p_business_group_id            in number,
299   p_object_version_number        out nocopy number,
300   p_request_id                   in number           default null,
301   p_program_application_id       in number           default null,
302   p_program_id                   in number           default null,
303   p_program_update_date          in date             default null,
304   p_ext_rslt_id                  in number           default null
305   ) is
306 --
307   l_rec	  ben_xre_shd.g_rec_type;
308   l_proc  varchar2(72) := g_package||'ins';
309 --
310 Begin
311   hr_utility.set_location('Entering:'||l_proc, 5);
312   --
313   -- Call conversion function to turn arguments into the
314   -- p_rec structure.
315   --
316   l_rec :=
317   ben_xre_shd.convert_args
318   (
319   null,
320   p_err_num,
321   p_err_txt,
322   p_typ_cd,
323   p_person_id,
324   p_business_group_id,
325   null,
326   p_request_id,
327   p_program_application_id,
328   p_program_id,
329   p_program_update_date,
330   p_ext_rslt_id
331   );
332   --
333   -- Having converted the arguments into the ben_xre_rec
334   -- plsql record structure we call the corresponding record business process.
335   --
336   ins(
337     p_effective_date,l_rec);
338   --
339   -- As the primary key argument(s)
340   -- are specified as an OUT's we must set these values.
341   --
342   p_ext_rslt_err_id := l_rec.ext_rslt_err_id;
343   p_object_version_number := l_rec.object_version_number;
344   --
345   hr_utility.set_location(' Leaving:'||l_proc, 10);
346 End ins;
347 --
348 end ben_xre_ins;