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