4 -- ----------------------------------------------------------------------------
1 Package Body ben_cmd_ins as
2 /* $Header: becmdrhi.pkb 115.7 2002/12/31 23:57:12 mmudigon ship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_cmd_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_cmd_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_cmd_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ben_cm_dlvry_med_typ
64 --
65 insert into ben_cm_dlvry_med_typ
66 ( cm_dlvry_med_typ_id,
67 cm_dlvry_med_typ_cd,
68 cm_dlvry_mthd_typ_id,
69 rqd_flag,
70 dflt_flag,
71 business_group_id,
72 cmd_attribute_category,
73 cmd_attribute1,
74 cmd_attribute2,
75 cmd_attribute3,
76 cmd_attribute4,
77 cmd_attribute5,
78 cmd_attribute6,
79 cmd_attribute7,
80 cmd_attribute8,
81 cmd_attribute9,
82 cmd_attribute10,
83 cmd_attribute11,
84 cmd_attribute12,
85 cmd_attribute13,
86 cmd_attribute14,
87 cmd_attribute15,
88 cmd_attribute16,
89 cmd_attribute17,
90 cmd_attribute18,
91 cmd_attribute19,
92 cmd_attribute20,
93 cmd_attribute21,
94 cmd_attribute22,
95 cmd_attribute23,
96 cmd_attribute24,
97 cmd_attribute25,
101 cmd_attribute29,
98 cmd_attribute26,
99 cmd_attribute27,
100 cmd_attribute28,
102 cmd_attribute30,
103 object_version_number
104 )
105 Values
106 ( p_rec.cm_dlvry_med_typ_id,
107 p_rec.cm_dlvry_med_typ_cd,
108 p_rec.cm_dlvry_mthd_typ_id,
109 p_rec.rqd_flag,
110 p_rec.dflt_flag,
111 p_rec.business_group_id,
112 p_rec.cmd_attribute_category,
113 p_rec.cmd_attribute1,
114 p_rec.cmd_attribute2,
115 p_rec.cmd_attribute3,
116 p_rec.cmd_attribute4,
117 p_rec.cmd_attribute5,
118 p_rec.cmd_attribute6,
119 p_rec.cmd_attribute7,
120 p_rec.cmd_attribute8,
121 p_rec.cmd_attribute9,
122 p_rec.cmd_attribute10,
123 p_rec.cmd_attribute11,
124 p_rec.cmd_attribute12,
125 p_rec.cmd_attribute13,
126 p_rec.cmd_attribute14,
127 p_rec.cmd_attribute15,
128 p_rec.cmd_attribute16,
129 p_rec.cmd_attribute17,
130 p_rec.cmd_attribute18,
131 p_rec.cmd_attribute19,
132 p_rec.cmd_attribute20,
133 p_rec.cmd_attribute21,
134 p_rec.cmd_attribute22,
135 p_rec.cmd_attribute23,
136 p_rec.cmd_attribute24,
137 p_rec.cmd_attribute25,
138 p_rec.cmd_attribute26,
139 p_rec.cmd_attribute27,
140 p_rec.cmd_attribute28,
141 p_rec.cmd_attribute29,
142 p_rec.cmd_attribute30,
143 p_rec.object_version_number
144 );
145 --
146 ben_cmd_shd.g_api_dml := false; -- Unset the api dml status
147 --
148 hr_utility.set_location(' Leaving:'||l_proc, 10);
149 Exception
150 When hr_api.check_integrity_violated Then
151 -- A check constraint has been violated
152 ben_cmd_shd.g_api_dml := false; -- Unset the api dml status
153 ben_cmd_shd.constraint_error
154 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
155 When hr_api.parent_integrity_violated Then
156 -- Parent integrity has been violated
157 ben_cmd_shd.g_api_dml := false; -- Unset the api dml status
158 ben_cmd_shd.constraint_error
159 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
160 When hr_api.unique_integrity_violated Then
161 -- Unique integrity has been violated
162 ben_cmd_shd.g_api_dml := false; -- Unset the api dml status
163 ben_cmd_shd.constraint_error
164 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
165 When Others Then
166 ben_cmd_shd.g_api_dml := false; -- Unset the api dml status
167 Raise;
168 End insert_dml;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |------------------------------< pre_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 -- This private procedure contains any processing which is required before
177 -- the insert dml. Presently, if the entity has a corresponding primary
178 -- key which is maintained by an associating sequence, the primary key for
179 -- the entity will be populated with the next sequence value in
180 -- preparation for the insert dml.
181 --
182 -- Prerequisites:
183 -- This is an internal procedure which is called from the ins procedure.
184 --
185 -- In Parameters:
186 -- A Pl/Sql record structre.
187 --
188 -- Post Success:
189 -- Processing continues.
190 --
191 -- Post Failure:
192 -- If an error has occurred, an error message and exception will be raised
193 -- but not handled.
194 --
195 -- Developer Implementation Notes:
196 -- Any pre-processing required before the insert dml is issued should be
197 -- coded within this procedure. As stated above, a good example is the
198 -- generation of a primary key number via a corresponding sequence.
199 -- It is important to note that any 3rd party maintenance should be reviewed
200 -- before placing in this procedure.
201 --
202 -- Access Status:
203 -- Internal Row Handler Use Only.
204 --
205 -- {End Of Comments}
206 -- ----------------------------------------------------------------------------
207 Procedure pre_insert(p_rec in out nocopy ben_cmd_shd.g_rec_type) is
208 --
209 l_proc varchar2(72) := g_package||'pre_insert';
210 --
211 Cursor C_Sel1 is select ben_cm_dlvry_med_typ_s.nextval from sys.dual;
212 --
213 Begin
214 hr_utility.set_location('Entering:'||l_proc, 5);
215 --
216 --
217 -- Select the next sequence number
218 --
219 Open C_Sel1;
220 Fetch C_Sel1 Into p_rec.cm_dlvry_med_typ_id;
221 Close C_Sel1;
222 --
223 hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End pre_insert;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< post_insert >------------------------------|
228 -- ----------------------------------------------------------------------------
229 -- {Start Of Comments}
230 --
231 -- Description:
232 -- This private procedure contains any processing which is required after the
233 -- insert dml.
234 --
235 -- Prerequisites:
236 -- This is an internal procedure which is called from the ins procedure.
237 --
238 -- In Parameters:
239 -- A Pl/Sql record structre.
240 --
241 -- Post Success:
242 -- Processing continues.
243 --
244 -- Post Failure:
245 -- If an error has occurred, an error message and exception will be raised
246 -- but not handled.
247 --
248 -- Developer Implementation Notes:
249 -- Any post-processing required after the insert dml is issued should be
253 -- Access Status:
250 -- coded within this procedure. It is important to note that any 3rd party
251 -- maintenance should be reviewed before placing in this procedure.
252 --
254 -- Internal Row Handler Use Only.
255 --
256 -- {End Of Comments}
257 -- ----------------------------------------------------------------------------
258 Procedure post_insert(
259 p_effective_date in date,p_rec in ben_cmd_shd.g_rec_type) is
260 --
261 l_proc varchar2(72) := g_package||'post_insert';
262 --
263 Begin
264 hr_utility.set_location('Entering:'||l_proc, 5);
265 --
266 --
267 -- Start of API User Hook for post_insert.
268 --
269 begin
270 --
271 ben_cmd_rki.after_insert
272 (
273 p_cm_dlvry_med_typ_id =>p_rec.cm_dlvry_med_typ_id
274 ,p_cm_dlvry_med_typ_cd =>p_rec.cm_dlvry_med_typ_cd
275 ,p_cm_dlvry_mthd_typ_id =>p_rec.cm_dlvry_mthd_typ_id
276 ,p_rqd_flag =>p_rec.rqd_flag
277 ,p_dflt_flag =>p_rec.dflt_flag
278 ,p_business_group_id =>p_rec.business_group_id
279 ,p_cmd_attribute_category =>p_rec.cmd_attribute_category
280 ,p_cmd_attribute1 =>p_rec.cmd_attribute1
281 ,p_cmd_attribute2 =>p_rec.cmd_attribute2
282 ,p_cmd_attribute3 =>p_rec.cmd_attribute3
283 ,p_cmd_attribute4 =>p_rec.cmd_attribute4
284 ,p_cmd_attribute5 =>p_rec.cmd_attribute5
285 ,p_cmd_attribute6 =>p_rec.cmd_attribute6
286 ,p_cmd_attribute7 =>p_rec.cmd_attribute7
287 ,p_cmd_attribute8 =>p_rec.cmd_attribute8
288 ,p_cmd_attribute9 =>p_rec.cmd_attribute9
289 ,p_cmd_attribute10 =>p_rec.cmd_attribute10
290 ,p_cmd_attribute11 =>p_rec.cmd_attribute11
291 ,p_cmd_attribute12 =>p_rec.cmd_attribute12
292 ,p_cmd_attribute13 =>p_rec.cmd_attribute13
293 ,p_cmd_attribute14 =>p_rec.cmd_attribute14
294 ,p_cmd_attribute15 =>p_rec.cmd_attribute15
295 ,p_cmd_attribute16 =>p_rec.cmd_attribute16
296 ,p_cmd_attribute17 =>p_rec.cmd_attribute17
297 ,p_cmd_attribute18 =>p_rec.cmd_attribute18
298 ,p_cmd_attribute19 =>p_rec.cmd_attribute19
299 ,p_cmd_attribute20 =>p_rec.cmd_attribute20
300 ,p_cmd_attribute21 =>p_rec.cmd_attribute21
301 ,p_cmd_attribute22 =>p_rec.cmd_attribute22
302 ,p_cmd_attribute23 =>p_rec.cmd_attribute23
303 ,p_cmd_attribute24 =>p_rec.cmd_attribute24
304 ,p_cmd_attribute25 =>p_rec.cmd_attribute25
305 ,p_cmd_attribute26 =>p_rec.cmd_attribute26
306 ,p_cmd_attribute27 =>p_rec.cmd_attribute27
307 ,p_cmd_attribute28 =>p_rec.cmd_attribute28
308 ,p_cmd_attribute29 =>p_rec.cmd_attribute29
309 ,p_cmd_attribute30 =>p_rec.cmd_attribute30
310 ,p_object_version_number =>p_rec.object_version_number
311 ,p_effective_date =>p_effective_date
312 );
313 --
314 exception
315 --
316 when hr_api.cannot_find_prog_unit then
317 --
318 hr_api.cannot_find_prog_unit_error
319 (p_module_name => 'ben_cm_dlvry_med_typ'
320 ,p_hook_type => 'AI');
321 --
322 end;
323 --
324 -- End of API User Hook for post_insert.
325 --
326 --
327 hr_utility.set_location(' Leaving:'||l_proc, 10);
328 End post_insert;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------------< ins >----------------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure ins
334 (
335 p_effective_date in date,
336 p_rec in out nocopy ben_cmd_shd.g_rec_type
337 ) is
338 --
339 l_proc varchar2(72) := g_package||'ins';
340 --
341 Begin
342 hr_utility.set_location('Entering:'||l_proc, 5);
343 --
344 -- Call the supporting insert validate operations
345 --
346 ben_cmd_bus.insert_validate(p_rec
347 ,p_effective_date);
348 --
349 -- Call the supporting pre-insert operation
350 --
351 pre_insert(p_rec);
352 --
353 -- Insert the row
354 --
355 insert_dml(p_rec);
356 --
357 -- Call the supporting post-insert operation
358 --
359 post_insert(
360 p_effective_date,p_rec);
361 end ins;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |---------------------------------< ins >----------------------------------|
365 -- ----------------------------------------------------------------------------
366 Procedure ins
367 (
368 p_effective_date in date,
369 p_cm_dlvry_med_typ_id out nocopy number,
370 p_cm_dlvry_med_typ_cd in varchar2,
371 p_cm_dlvry_mthd_typ_id in number default null,
372 p_rqd_flag in varchar2,
373 p_dflt_flag in varchar2,
374 p_business_group_id in number,
375 p_cmd_attribute_category in varchar2 default null,
376 p_cmd_attribute1 in varchar2 default null,
377 p_cmd_attribute2 in varchar2 default null,
378 p_cmd_attribute3 in varchar2 default null,
379 p_cmd_attribute4 in varchar2 default null,
380 p_cmd_attribute5 in varchar2 default null,
381 p_cmd_attribute6 in varchar2 default null,
382 p_cmd_attribute7 in varchar2 default null,
383 p_cmd_attribute8 in varchar2 default null,
384 p_cmd_attribute9 in varchar2 default null,
385 p_cmd_attribute10 in varchar2 default null,
386 p_cmd_attribute11 in varchar2 default null,
387 p_cmd_attribute12 in varchar2 default null,
388 p_cmd_attribute13 in varchar2 default null,
389 p_cmd_attribute14 in varchar2 default null,
390 p_cmd_attribute15 in varchar2 default null,
391 p_cmd_attribute16 in varchar2 default null,
392 p_cmd_attribute17 in varchar2 default null,
393 p_cmd_attribute18 in varchar2 default null,
394 p_cmd_attribute19 in varchar2 default null,
395 p_cmd_attribute20 in varchar2 default null,
396 p_cmd_attribute21 in varchar2 default null,
397 p_cmd_attribute22 in varchar2 default null,
398 p_cmd_attribute23 in varchar2 default null,
399 p_cmd_attribute24 in varchar2 default null,
400 p_cmd_attribute25 in varchar2 default null,
401 p_cmd_attribute26 in varchar2 default null,
402 p_cmd_attribute27 in varchar2 default null,
403 p_cmd_attribute28 in varchar2 default null,
404 p_cmd_attribute29 in varchar2 default null,
405 p_cmd_attribute30 in varchar2 default null,
406 p_object_version_number out nocopy number
407 ) is
408 --
409 l_rec ben_cmd_shd.g_rec_type;
410 l_proc varchar2(72) := g_package||'ins';
411 --
412 Begin
413 hr_utility.set_location('Entering:'||l_proc, 5);
414 --
415 -- Call conversion function to turn arguments into the
416 -- p_rec structure.
417 --
418 l_rec :=
419 ben_cmd_shd.convert_args
420 (
421 null,
422 p_cm_dlvry_med_typ_cd,
423 p_cm_dlvry_mthd_typ_id,
424 p_rqd_flag,
425 p_dflt_flag,
426 p_business_group_id,
427 p_cmd_attribute_category,
428 p_cmd_attribute1,
429 p_cmd_attribute2,
430 p_cmd_attribute3,
431 p_cmd_attribute4,
432 p_cmd_attribute5,
433 p_cmd_attribute6,
434 p_cmd_attribute7,
435 p_cmd_attribute8,
436 p_cmd_attribute9,
437 p_cmd_attribute10,
438 p_cmd_attribute11,
439 p_cmd_attribute12,
440 p_cmd_attribute13,
441 p_cmd_attribute14,
442 p_cmd_attribute15,
443 p_cmd_attribute16,
444 p_cmd_attribute17,
445 p_cmd_attribute18,
446 p_cmd_attribute19,
447 p_cmd_attribute20,
448 p_cmd_attribute21,
449 p_cmd_attribute22,
450 p_cmd_attribute23,
451 p_cmd_attribute24,
452 p_cmd_attribute25,
453 p_cmd_attribute26,
454 p_cmd_attribute27,
455 p_cmd_attribute28,
456 p_cmd_attribute29,
457 p_cmd_attribute30,
458 null
459 );
460 --
461 -- Having converted the arguments into the ben_cmd_rec
462 -- plsql record structure we call the corresponding record business process.
463 --
464 ins(
465 p_effective_date,l_rec);
466 --
467 -- As the primary key argument(s)
468 -- are specified as an OUT's we must set these values.
469 --
470 p_cm_dlvry_med_typ_id := l_rec.cm_dlvry_med_typ_id;
471 p_object_version_number := l_rec.object_version_number;
472 --
473 hr_utility.set_location(' Leaving:'||l_proc, 10);
474 End ins;
475 --
476 end ben_cmd_ins;