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