1 Package Body per_chk_ins as
2 /* $Header: pechkrhi.pkb 115.7 2002/12/04 12:17:45 pkakar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_chk_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 per_chk_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 per_chk_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: per_checklist_items
64 --
65 insert into per_checklist_items
66 ( checklist_item_id,
67 person_id,
68 item_code,
69 date_due,
70 date_done,
71 status,
72 notes,
73 object_version_number,
74 attribute_category,
75 attribute1,
76 attribute2,
77 attribute3,
78 attribute4,
79 attribute5,
80 attribute6,
81 attribute7,
82 attribute8,
83 attribute9,
84 attribute10,
85 attribute11,
86 attribute12,
87 attribute13,
88 attribute14,
89 attribute15,
90 attribute16,
91 attribute17,
92 attribute18,
93 attribute19,
94 attribute20,
95 attribute21,
96 attribute22,
97 attribute23,
98 attribute24,
99 attribute25,
100 attribute26,
101 attribute27,
102 attribute28,
103 attribute29,
104 attribute30
105 )
106 Values
107 ( p_rec.checklist_item_id,
108 p_rec.person_id,
109 p_rec.item_code,
110 p_rec.date_due,
111 p_rec.date_done,
112 p_rec.status,
113 p_rec.notes,
114 p_rec.object_version_number,
115 p_rec.attribute_category,
116 p_rec.attribute1,
117 p_rec.attribute2,
118 p_rec.attribute3,
119 p_rec.attribute4,
120 p_rec.attribute5,
121 p_rec.attribute6,
122 p_rec.attribute7,
123 p_rec.attribute8,
124 p_rec.attribute9,
125 p_rec.attribute10,
126 p_rec.attribute11,
127 p_rec.attribute12,
128 p_rec.attribute13,
129 p_rec.attribute14,
130 p_rec.attribute15,
131 p_rec.attribute16,
132 p_rec.attribute17,
133 p_rec.attribute18,
134 p_rec.attribute19,
135 p_rec.attribute20,
136 p_rec.attribute21,
137 p_rec.attribute22,
138 p_rec.attribute23,
139 p_rec.attribute24,
140 p_rec.attribute25,
141 p_rec.attribute26,
142 p_rec.attribute27,
143 p_rec.attribute28,
144 p_rec.attribute29,
145 p_rec.attribute30
146 );
147 --
148 per_chk_shd.g_api_dml := false; -- Unset the api dml status
149 --
150 hr_utility.set_location(' Leaving:'||l_proc, 10);
151 Exception
152 When hr_api.check_integrity_violated Then
153 -- A check constraint has been violated
154 per_chk_shd.g_api_dml := false; -- Unset the api dml status
155 per_chk_shd.constraint_error
156 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
157 When hr_api.parent_integrity_violated Then
158 -- Parent integrity has been violated
159 per_chk_shd.g_api_dml := false; -- Unset the api dml status
160 per_chk_shd.constraint_error
161 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
162 When hr_api.unique_integrity_violated Then
163 -- Unique integrity has been violated
164 per_chk_shd.g_api_dml := false; -- Unset the api dml status
165 per_chk_shd.constraint_error
166 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
167 When Others Then
168 per_chk_shd.g_api_dml := false; -- Unset the api dml status
169 Raise;
170 End insert_dml;
171 --
172 -- ----------------------------------------------------------------------------
173 -- |------------------------------< pre_insert >------------------------------|
174 -- ----------------------------------------------------------------------------
175 -- {Start Of Comments}
176 --
177 -- Description:
178 -- This private procedure contains any processing which is required before
179 -- the insert dml. Presently, if the entity has a corresponding primary
180 -- key which is maintained by an associating sequence, the primary key for
181 -- the entity will be populated with the next sequence value in
182 -- preparation for the insert dml.
183 --
184 -- Prerequisites:
185 -- This is an internal procedure which is called from the ins procedure.
186 --
187 -- In Parameters:
188 -- A Pl/Sql record structre.
189 --
190 -- Post Success:
191 -- Processing continues.
192 --
193 -- Post Failure:
194 -- If an error has occurred, an error message and exception will be raised
198 -- Any pre-processing required before the insert dml is issued should be
195 -- but not handled.
196 --
197 -- Developer Implementation Notes:
199 -- coded within this procedure. As stated above, a good example is the
200 -- generation of a primary key number via a corresponding sequence.
201 -- It is important to note that any 3rd party maintenance should be reviewed
202 -- before placing in this procedure.
203 --
204 -- Access Status:
205 -- Internal Row Handler Use Only.
206 --
207 -- {End Of Comments}
208 -- ----------------------------------------------------------------------------
209 Procedure pre_insert(p_rec in out nocopy per_chk_shd.g_rec_type) is
210 --
211 l_proc varchar2(72) := g_package||'pre_insert';
212 --
213 Cursor C_Sel1 is select per_checklist_items_s.nextval from sys.dual;
214 --
215 Begin
216 hr_utility.set_location('Entering:'||l_proc, 5);
217 --
218 --
219 -- Select the next sequence number
220 --
221 Open C_Sel1;
222 Fetch C_Sel1 Into p_rec.checklist_item_id;
223 Close C_Sel1;
224 --
225 hr_utility.set_location(' Leaving:'||l_proc, 10);
226 End pre_insert;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |-----------------------------< post_insert >------------------------------|
230 -- ----------------------------------------------------------------------------
231 -- {Start Of Comments}
232 --
233 -- Description:
234 -- This private procedure contains any processing which is required after the
235 -- insert dml.
236 --
237 -- Prerequisites:
238 -- This is an internal procedure which is called from the ins procedure.
239 --
240 -- In Parameters:
241 -- A Pl/Sql record structre.
242 --
243 -- Post Success:
244 -- Processing continues.
245 --
246 -- Post Failure:
247 -- If an error has occurred, an error message and exception will be raised
248 -- but not handled.
249 --
250 -- Developer Implementation Notes:
251 -- Any post-processing required after the insert dml is issued should be
252 -- coded within this procedure. It is important to note that any 3rd party
253 -- maintenance should be reviewed before placing in this procedure.
254 --
255 -- Access Status:
256 -- Internal Row Handler Use Only.
257 --
258 -- {End Of Comments}
259 -- ----------------------------------------------------------------------------
260 Procedure post_insert(p_effective_date in date,
261 p_rec in per_chk_shd.g_rec_type) is
262 --
263 l_proc varchar2(72) := g_package||'post_insert';
264 --
265 Begin
266 hr_utility.set_location('Entering:'||l_proc, 5);
267 --
268 --
269 -- Start of API User Hook for post_insert.
270 --
271 begin
272 --
273 per_chk_rki.after_insert
274 (
275 p_effective_date => p_effective_date
276 ,p_checklist_item_id =>p_rec.checklist_item_id
277 ,p_person_id =>p_rec.person_id
278 ,p_item_code =>p_rec.item_code
279 ,p_date_due =>p_rec.date_due
280 ,p_date_done =>p_rec.date_done
281 ,p_status =>p_rec.status
282 ,p_notes =>p_rec.notes
283 ,p_object_version_number =>p_rec.object_version_number
284 ,p_attribute_category =>p_rec.attribute_category
285 ,p_attribute1 =>p_rec.attribute1
286 ,p_attribute2 =>p_rec.attribute2
287 ,p_attribute3 =>p_rec.attribute3
288 ,p_attribute4 =>p_rec.attribute4
289 ,p_attribute5 =>p_rec.attribute5
290 ,p_attribute6 =>p_rec.attribute6
291 ,p_attribute7 =>p_rec.attribute7
292 ,p_attribute8 =>p_rec.attribute8
293 ,p_attribute9 =>p_rec.attribute9
294 ,p_attribute10 =>p_rec.attribute10
295 ,p_attribute11 =>p_rec.attribute11
296 ,p_attribute12 =>p_rec.attribute12
297 ,p_attribute13 =>p_rec.attribute13
298 ,p_attribute14 =>p_rec.attribute14
299 ,p_attribute15 =>p_rec.attribute15
300 ,p_attribute16 =>p_rec.attribute16
301 ,p_attribute17 =>p_rec.attribute17
302 ,p_attribute18 =>p_rec.attribute18
303 ,p_attribute19 =>p_rec.attribute19
304 ,p_attribute20 =>p_rec.attribute20
305 ,p_attribute21 =>p_rec.attribute21
306 ,p_attribute22 =>p_rec.attribute22
307 ,p_attribute23 =>p_rec.attribute23
308 ,p_attribute24 =>p_rec.attribute24
309 ,p_attribute25 =>p_rec.attribute25
310 ,p_attribute26 =>p_rec.attribute26
311 ,p_attribute27 =>p_rec.attribute27
312 ,p_attribute28 =>p_rec.attribute28
313 ,p_attribute29 =>p_rec.attribute29
314 ,p_attribute30 =>p_rec.attribute30
315 );
316 --
317 exception
318 --
319 when hr_api.cannot_find_prog_unit then
320 --
321 hr_api.cannot_find_prog_unit_error
322 (p_module_name => 'per_checklist_items'
323 ,p_hook_type => 'AI');
324 --
325 end;
326 --
327 -- End of API User Hook for post_insert.
328 --
329 --
330 hr_utility.set_location(' Leaving:'||l_proc, 10);
331 End post_insert;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |---------------------------------< ins >----------------------------------|
335 -- ----------------------------------------------------------------------------
336 Procedure ins
337 (
338 p_effective_date in date,
339 p_rec in out nocopy per_chk_shd.g_rec_type
340 ) is
341 --
342 l_proc varchar2(72) := g_package||'ins';
343 --
344 Begin
345 hr_utility.set_location('Entering:'||l_proc, 5);
346 --
347 -- Call the supporting insert validate operations
348 --
349 per_chk_bus.insert_validate(p_effective_date,
350 p_rec);
351 --
352 -- Call the supporting pre-insert operation
353 --
354 pre_insert(p_rec);
355 --
356 -- Insert the row
357 --
358 insert_dml(p_rec);
359 --
360 -- Call the supporting post-insert operation
361 --
362 post_insert(p_effective_date,
363 p_rec);
364 end ins;
365 --
366 -- ----------------------------------------------------------------------------
367 -- |---------------------------------< ins >----------------------------------|
368 -- ----------------------------------------------------------------------------
369 Procedure ins
370 (
371 p_effective_date in date,
372 p_checklist_item_id out nocopy number,
373 p_person_id in number,
374 p_item_code in varchar2,
375 p_date_due in date default null,
376 p_date_done in date default null,
377 -- Made this mandatory
378 p_status in varchar2 default null,
379 p_notes in varchar2 default null,
380 p_object_version_number out nocopy number,
381 p_attribute_category in varchar2 default null,
382 p_attribute1 in varchar2 default null,
383 p_attribute2 in varchar2 default null,
384 p_attribute3 in varchar2 default null,
385 p_attribute4 in varchar2 default null,
386 p_attribute5 in varchar2 default null,
387 p_attribute6 in varchar2 default null,
388 p_attribute7 in varchar2 default null,
389 p_attribute8 in varchar2 default null,
390 p_attribute9 in varchar2 default null,
391 p_attribute10 in varchar2 default null,
392 p_attribute11 in varchar2 default null,
393 p_attribute12 in varchar2 default null,
394 p_attribute13 in varchar2 default null,
395 p_attribute14 in varchar2 default null,
396 p_attribute15 in varchar2 default null,
397 p_attribute16 in varchar2 default null,
398 p_attribute17 in varchar2 default null,
399 p_attribute18 in varchar2 default null,
400 p_attribute19 in varchar2 default null,
401 p_attribute20 in varchar2 default null,
402 p_attribute21 in varchar2 default null,
403 p_attribute22 in varchar2 default null,
404 p_attribute23 in varchar2 default null,
405 p_attribute24 in varchar2 default null,
406 p_attribute25 in varchar2 default null,
407 p_attribute26 in varchar2 default null,
408 p_attribute27 in varchar2 default null,
409 p_attribute28 in varchar2 default null,
410 p_attribute29 in varchar2 default null,
411 p_attribute30 in varchar2 default null
412 ) is
413 --
414 l_rec per_chk_shd.g_rec_type;
415 l_proc varchar2(72) := g_package||'ins';
416 --
417 Begin
418 hr_utility.set_location('Entering:'||l_proc, 5);
419 --
420 -- Call conversion function to turn arguments into the
421 -- p_rec structure.
422 --
423 l_rec :=
424 per_chk_shd.convert_args
425 (
426 null,
427 p_person_id,
428 p_item_code,
429 p_date_due,
430 p_date_done,
431 p_status,
432 p_notes,
433 null,
434 p_attribute_category,
435 p_attribute1,
436 p_attribute2,
437 p_attribute3,
438 p_attribute4,
439 p_attribute5,
440 p_attribute6,
441 p_attribute7,
442 p_attribute8,
443 p_attribute9,
444 p_attribute10,
445 p_attribute11,
446 p_attribute12,
447 p_attribute13,
448 p_attribute14,
449 p_attribute15,
450 p_attribute16,
451 p_attribute17,
452 p_attribute18,
453 p_attribute19,
454 p_attribute20,
455 p_attribute21,
456 p_attribute22,
457 p_attribute23,
458 p_attribute24,
459 p_attribute25,
460 p_attribute26,
461 p_attribute27,
462 p_attribute28,
463 p_attribute29,
464 p_attribute30
465 );
466 --
467 -- Having converted the arguments into the per_chk_rec
468 -- plsql record structure we call the corresponding record business process.
469 --
470 ins(p_effective_date,
471 l_rec);
472 --
473 -- As the primary key argument(s)
474 -- are specified as an OUT's we must set these values.
475 --
476 p_checklist_item_id := l_rec.checklist_item_id;
477 p_object_version_number := l_rec.object_version_number;
478 --
479 hr_utility.set_location(' Leaving:'||l_proc, 10);
480 End ins;
481 --
482 end per_chk_ins;