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