1 Package Body ben_bmn_ins as
2 /* $Header: bebmnrhi.pkb 115.7 2002/12/09 12:40:49 lakrish ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bmn_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_bmn_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_bmn_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ben_reporting
64 --
65 insert into ben_reporting
66 ( reporting_id,
67 benefit_action_id,
68 thread_id,
69 sequence,
70 text,
71 rep_typ_cd,
72 error_message_code,
73 national_identifier,
74 related_person_ler_id,
75 temporal_ler_id,
76 ler_id,
77 person_id,
78 pgm_id,
79 pl_id,
80 related_person_id,
81 oipl_id,
82 pl_typ_id,
83 actl_prem_id ,
84 val ,
85 mo_num ,
86 yr_num ,
87 object_version_number
88 )
89 Values
90 ( p_rec.reporting_id,
91 p_rec.benefit_action_id,
92 p_rec.thread_id,
93 p_rec.sequence,
94 p_rec.text,
95 p_rec.rep_typ_cd,
96 p_rec.error_message_code,
97 p_rec.national_identifier,
98 p_rec.related_person_ler_id,
99 p_rec.temporal_ler_id,
100 p_rec.ler_id,
101 p_rec.person_id,
102 p_rec.pgm_id,
103 p_rec.pl_id,
104 p_rec.related_person_id,
105 p_rec.oipl_id,
106 p_rec.pl_typ_id,
107 p_rec.actl_prem_id ,
108 p_rec.val ,
109 p_rec.mo_num ,
110 p_rec.yr_num ,
111 p_rec.object_version_number
112 );
113 --
114 ben_bmn_shd.g_api_dml := false; -- Unset the api dml status
115 --
116 hr_utility.set_location(' Leaving:'||l_proc, 10);
117 Exception
118 When hr_api.check_integrity_violated Then
119 -- A check constraint has been violated
120 ben_bmn_shd.g_api_dml := false; -- Unset the api dml status
121 ben_bmn_shd.constraint_error
122 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
123 When hr_api.parent_integrity_violated Then
124 -- Parent integrity has been violated
125 ben_bmn_shd.g_api_dml := false; -- Unset the api dml status
126 ben_bmn_shd.constraint_error
127 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
128 When hr_api.unique_integrity_violated Then
129 -- Unique integrity has been violated
130 ben_bmn_shd.g_api_dml := false; -- Unset the api dml status
131 ben_bmn_shd.constraint_error
132 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
133 When Others Then
134 ben_bmn_shd.g_api_dml := false; -- Unset the api dml status
135 Raise;
139 -- |------------------------------< pre_insert >------------------------------|
136 End insert_dml;
137 --
138 -- ----------------------------------------------------------------------------
140 -- ----------------------------------------------------------------------------
141 -- {Start Of Comments}
142 --
143 -- Description:
144 -- This private procedure contains any processing which is required before
145 -- the insert dml. Presently, if the entity has a corresponding primary
146 -- key which is maintained by an associating sequence, the primary key for
147 -- the entity will be populated with the next sequence value in
148 -- preparation for the insert dml.
149 --
150 -- Prerequisites:
151 -- This is an internal procedure which is called from the ins procedure.
152 --
153 -- In Parameters:
154 -- A Pl/Sql record structre.
155 --
156 -- Post Success:
157 -- Processing continues.
158 --
159 -- Post Failure:
160 -- If an error has occurred, an error message and exception will be raised
161 -- but not handled.
162 --
163 -- Developer Implementation Notes:
164 -- Any pre-processing required before the insert dml is issued should be
165 -- coded within this procedure. As stated above, a good example is the
166 -- generation of a primary key number via a corresponding sequence.
167 -- It is important to note that any 3rd party maintenance should be reviewed
168 -- before placing in this procedure.
169 --
170 -- Access Status:
171 -- Internal Row Handler Use Only.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure pre_insert(p_rec in out nocopy ben_bmn_shd.g_rec_type) is
176 --
177 l_proc varchar2(72) := g_package||'pre_insert';
178 --
179 Cursor C_Sel1 is select ben_reporting_s.nextval from sys.dual;
180 --
181 Begin
182 hr_utility.set_location('Entering:'||l_proc, 5);
183 --
184 --
185 -- Select the next sequence number
186 --
187 Open C_Sel1;
188 Fetch C_Sel1 Into p_rec.reporting_id;
189 Close C_Sel1;
190 --
191 hr_utility.set_location(' Leaving:'||l_proc, 10);
192 End pre_insert;
193 --
194 -- ----------------------------------------------------------------------------
195 -- |-----------------------------< post_insert >------------------------------|
196 -- ----------------------------------------------------------------------------
197 -- {Start Of Comments}
198 --
199 -- Description:
200 -- This private procedure contains any processing which is required after the
201 -- insert dml.
202 --
203 -- Prerequisites:
204 -- This is an internal procedure which is called from the ins procedure.
205 --
206 -- In Parameters:
207 -- A Pl/Sql record structre.
208 --
209 -- Post Success:
210 -- Processing continues.
211 --
212 -- Post Failure:
213 -- If an error has occurred, an error message and exception will be raised
214 -- but not handled.
215 --
216 -- Developer Implementation Notes:
217 -- Any post-processing required after the insert dml is issued should be
218 -- coded within this procedure. It is important to note that any 3rd party
219 -- maintenance should be reviewed before placing in this procedure.
220 --
221 -- Access Status:
222 -- Internal Row Handler Use Only.
223 --
224 -- {End Of Comments}
225 -- ----------------------------------------------------------------------------
226 Procedure post_insert(p_rec in ben_bmn_shd.g_rec_type) is
227 --
228 l_proc varchar2(72) := g_package||'post_insert';
229 --
230 Begin
231 hr_utility.set_location('Entering:'||l_proc, 5);
232 --
233 hr_utility.set_location(' Leaving:'||l_proc, 10);
234 End post_insert;
235 --
236 -- ----------------------------------------------------------------------------
237 -- |---------------------------------< ins >----------------------------------|
238 -- ----------------------------------------------------------------------------
239 Procedure ins
240 (
241 p_rec in out nocopy ben_bmn_shd.g_rec_type
242 ) is
243 --
244 l_proc varchar2(72) := g_package||'ins';
245 --
246 Begin
247 hr_utility.set_location('Entering:'||l_proc, 5);
248 --
249 -- Call the supporting insert validate operations
250 --
251 ben_bmn_bus.insert_validate(p_rec);
252 --
253 -- Call the supporting pre-insert operation
254 --
255 pre_insert(p_rec);
256 --
257 -- Insert the row
258 --
259 insert_dml(p_rec);
260 --
261 -- Call the supporting post-insert operation
262 --
263 post_insert(p_rec);
264 end ins;
265 --
266 -- ----------------------------------------------------------------------------
267 -- |---------------------------------< ins >----------------------------------|
268 -- ----------------------------------------------------------------------------
269 Procedure ins
270 (
271 p_reporting_id out nocopy number,
272 p_benefit_action_id in number,
273 p_thread_id in number,
274 p_sequence in number,
275 p_text in varchar2 default null,
276 p_rep_typ_cd in varchar2 default null,
277 p_error_message_code in varchar2 default null,
278 p_national_identifier in varchar2 default null,
279 p_related_person_ler_id in number default null,
280 p_temporal_ler_id in number default null,
281 p_ler_id in number default null,
282 p_person_id in number default null,
286 p_oipl_id in number default null,
283 p_pgm_id in number default null,
284 p_pl_id in number default null,
285 p_related_person_id in number default null,
287 p_pl_typ_id in number default null,
288 p_actl_prem_id in number default null,
289 p_val in number default null,
290 p_mo_num in number default null,
291 p_yr_num in number default null,
292 p_object_version_number out nocopy number
293 ) is
294 --
295 l_rec ben_bmn_shd.g_rec_type;
296 l_proc varchar2(72) := g_package||'ins';
297 --
298 Begin
299 hr_utility.set_location('Entering:'||l_proc, 5);
300 --
301 -- Call conversion function to turn arguments into the
302 -- p_rec structure.
303 --
304 l_rec :=
305 ben_bmn_shd.convert_args
306 (
307 null,
308 p_benefit_action_id,
309 p_thread_id,
310 p_sequence,
311 p_text,
312 p_rep_typ_cd,
313 p_error_message_code,
314 p_national_identifier,
315 p_related_person_ler_id,
316 p_temporal_ler_id,
317 p_ler_id,
318 p_person_id,
319 p_pgm_id,
320 p_pl_id,
321 p_related_person_id,
322 p_oipl_id,
323 p_pl_typ_id,
324 p_actl_prem_id ,
325 p_val ,
326 p_mo_num ,
327 p_yr_num ,
328 null
329 );
330 --
331 -- Having converted the arguments into the ben_bmn_rec
332 -- plsql record structure we call the corresponding record business process.
333 --
334 ins(l_rec);
335 --
336 -- As the primary key argument(s)
337 -- are specified as an OUT's we must set these values.
338 --
339 p_reporting_id := l_rec.reporting_id;
340 p_object_version_number := l_rec.object_version_number;
341 --
342 hr_utility.set_location(' Leaving:'||l_proc, 10);
343 End ins;
344 --
345 end ben_bmn_ins;