1 Package Body pqh_vld_ins as
2 /* $Header: pqvldrhi.pkb 115.2 2002/12/13 00:33:20 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_vld_ins.'; -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_validation_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_validation_id in number) is
20 --
21 l_proc varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24 hr_utility.set_location('Entering:'||l_proc, 10);
25 --
26 pqh_vld_ins.g_validation_id_i := p_validation_id;
27 --
28 hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 -- This procedure controls the actual dml insert logic. The processing of
39 -- this procedure are as follows:
40 -- 1) Initialise the object_version_number to 1 if the object_version_number
41 -- is defined as an attribute for this entity.
42 -- 2) To set and unset the g_api_dml status as required (as we are about to
43 -- perform dml).
44 -- 3) To insert the row into the schema.
45 -- 4) To trap any constraint violations that may have occurred.
46 -- 5) To raise any other errors.
47 --
48 -- Prerequisites:
49 -- This is an internal private procedure which must be called from the ins
50 -- procedure and must have all mandatory attributes set (except the
51 -- object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 -- A Pl/Sql record structre.
55 --
56 -- Post Success:
57 -- The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 -- On the insert dml failure it is important to note that we always reset the
61 -- g_api_dml status to false.
62 -- If a check, unique or parent integrity constraint violation is raised the
63 -- constraint_error procedure will be called.
64 -- If any other error is reported, the error will be raised after the
65 -- g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 -- None.
69 --
70 -- Access Status:
71 -- Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76 (p_rec in out nocopy pqh_vld_shd.g_rec_type
77 ) is
78 --
79 l_proc varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82 hr_utility.set_location('Entering:'||l_proc, 5);
83 p_rec.object_version_number := 1; -- Initialise the object version
84 --
85 --
86 --
87 -- Insert the row into: pqh_fr_validations
88 --
89 insert into pqh_fr_validations
90 (validation_id
91 ,pension_fund_type_code
92 ,pension_fund_id
93 ,business_group_id
94 ,person_id
95 ,request_date
96 ,completion_date
97 ,previous_employer_id
98 ,previously_validated_flag
99 ,status
100 ,employer_amount
101 ,employer_currency_code
102 ,employee_amount
103 ,employee_currency_code
104 ,deduction_per_period
105 ,deduction_currency_code
106 ,percent_of_salary
107 ,object_version_number
108 )
109 Values
110 (p_rec.validation_id
111 ,p_rec.pension_fund_type_code
112 ,p_rec.pension_fund_id
113 ,p_rec.business_group_id
114 ,p_rec.person_id
115 ,p_rec.request_date
116 ,p_rec.completion_date
117 ,p_rec.previous_employer_id
118 ,p_rec.previously_validated_flag
119 ,p_rec.status
120 ,p_rec.employer_amount
121 ,p_rec.employer_currency_code
122 ,p_rec.employee_amount
123 ,p_rec.employee_currency_code
124 ,p_rec.deduction_per_period
125 ,p_rec.deduction_currency_code
126 ,p_rec.percent_of_salary
127 ,p_rec.object_version_number
128 );
129 --
130 --
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 --
137 pqh_vld_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 --
142 pqh_vld_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 --
147 pqh_vld_shd.constraint_error
148 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
149 When Others Then
150 --
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 -- Prerequisites:
167 -- This is an internal procedure which is called from the ins procedure.
168 --
169 -- In Parameters:
170 -- A Pl/Sql record structure.
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 Row Handler Use Only.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure pre_insert
192 (p_rec in out nocopy pqh_vld_shd.g_rec_type
193 ) is
194 --
195 Cursor C_Sel1 is select pqh_fr_validations_s.nextval from sys.dual;
196 --
197 Cursor C_Sel2 is
198 Select null
199 from pqh_fr_validations
200 where validation_id =
201 pqh_vld_ins.g_validation_id_i;
202 --
203 l_proc varchar2(72) := g_package||'pre_insert';
204 l_exists varchar2(1);
205 --
206 Begin
207 hr_utility.set_location('Entering:'||l_proc, 5);
208 --
209 If (pqh_vld_ins.g_validation_id_i is not null) Then
210 --
211 -- Verify registered primary key values not already in use
212 --
213 Open C_Sel2;
214 Fetch C_Sel2 into l_exists;
215 If C_Sel2%found Then
216 Close C_Sel2;
217 --
218 -- The primary key values are already in use.
219 --
220 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
221 fnd_message.set_token('TABLE_NAME','pqh_fr_validations');
222 fnd_message.raise_error;
223 End If;
224 Close C_Sel2;
225 --
226 -- Use registered key values and clear globals
227 --
228 p_rec.validation_id :=
229 pqh_vld_ins.g_validation_id_i;
230 pqh_vld_ins.g_validation_id_i := null;
231 Else
232 --
233 -- No registerd key values, so select the next sequence number
234 --
235 --
236 -- Select the next sequence number
237 --
238 Open C_Sel1;
239 Fetch C_Sel1 Into p_rec.validation_id;
240 Close C_Sel1;
241 End If;
242 --
243 hr_utility.set_location(' Leaving:'||l_proc, 10);
244 End pre_insert;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |-----------------------------< post_insert >------------------------------|
248 -- ----------------------------------------------------------------------------
249 -- {Start Of Comments}
250 --
251 -- Description:
252 -- This private procedure contains any processing which is required after
253 -- the insert dml.
254 --
255 -- Prerequisites:
256 -- This is an internal procedure which is called from the ins procedure.
257 --
258 -- In Parameters:
259 -- A Pl/Sql record structre.
260 --
261 -- Post Success:
262 -- Processing continues.
263 --
264 -- Post Failure:
265 -- If an error has occurred, an error message and exception will be raised
266 -- but not handled.
267 --
268 -- Developer Implementation Notes:
269 -- Any post-processing required after the insert dml is issued should be
270 -- coded within this procedure. It is important to note that any 3rd party
271 -- maintenance should be reviewed before placing in this procedure.
272 --
273 -- Access Status:
274 -- Internal Row Handler Use Only.
275 --
276 -- {End Of Comments}
277 -- ----------------------------------------------------------------------------
278 Procedure post_insert
279 (p_effective_date in date
280 ,p_rec in pqh_vld_shd.g_rec_type
281 ) is
282 --
283 l_proc varchar2(72) := g_package||'post_insert';
284 --
285 Begin
286 hr_utility.set_location('Entering:'||l_proc, 5);
287 begin
288 --
289 pqh_vld_rki.after_insert
290 (p_effective_date => p_effective_date
291 ,p_validation_id
292 => p_rec.validation_id
293 ,p_pension_fund_type_code
294 => p_rec.pension_fund_type_code
295 ,p_pension_fund_id
296 => p_rec.pension_fund_id
297 ,p_business_group_id
298 => p_rec.business_group_id
299 ,p_person_id
300 => p_rec.person_id
301 ,p_request_date
302 => p_rec.request_date
303 ,p_completion_date
304 => p_rec.completion_date
305 ,p_previous_employer_id
306 => p_rec.previous_employer_id
307 ,p_previously_validated_flag
308 => p_rec.previously_validated_flag
309 ,p_status
310 => p_rec.status
311 ,p_employer_amount
312 => p_rec.employer_amount
313 ,p_employer_currency_code
314 => p_rec.employer_currency_code
315 ,p_employee_amount
316 => p_rec.employee_amount
317 ,p_employee_currency_code
318 => p_rec.employee_currency_code
319 ,p_deduction_per_period
320 => p_rec.deduction_per_period
321 ,p_deduction_currency_code
322 => p_rec.deduction_currency_code
323 ,p_percent_of_salary
324 => p_rec.percent_of_salary
325 ,p_object_version_number
326 => p_rec.object_version_number
327 );
328 --
329 exception
330 --
331 when hr_api.cannot_find_prog_unit then
332 --
333 hr_api.cannot_find_prog_unit_error
334 (p_module_name => 'PQH_FR_VALIDATIONS'
335 ,p_hook_type => 'AI');
336 --
337 end;
338 --
339 hr_utility.set_location(' Leaving:'||l_proc, 10);
340 End post_insert;
341 --
342 -- ----------------------------------------------------------------------------
343 -- |---------------------------------< ins >----------------------------------|
344 -- ----------------------------------------------------------------------------
345 Procedure ins
346 (p_effective_date in date
347 ,p_rec in out nocopy pqh_vld_shd.g_rec_type
348 ) is
349 --
350 l_proc varchar2(72) := g_package||'ins';
351 --
352 Begin
353 hr_utility.set_location('Entering:'||l_proc, 5);
354 --
355 -- Call the supporting insert validate operations
356 --
357 pqh_vld_bus.insert_validate
358 (p_effective_date
359 ,p_rec
360 );
361 --
362 -- Call to raise any errors on multi-message list
363 hr_multi_message.end_validation_set;
364 --
365 -- Call the supporting pre-insert operation
366 --
367 pqh_vld_ins.pre_insert(p_rec);
368 --
369 -- Insert the row
370 --
371 pqh_vld_ins.insert_dml(p_rec);
372 --
373 -- Call the supporting post-insert operation
374 --
375 pqh_vld_ins.post_insert
376 (p_effective_date
377 ,p_rec
378 );
379 --
380 -- Call to raise any errors on multi-message list
381 hr_multi_message.end_validation_set;
382 --
383 hr_utility.set_location('Leaving:'||l_proc, 20);
384 end ins;
385 --
386 -- ----------------------------------------------------------------------------
387 -- |---------------------------------< ins >----------------------------------|
388 -- ----------------------------------------------------------------------------
389 Procedure ins
390 (p_effective_date in date
391 ,p_pension_fund_type_code in varchar2
392 ,p_pension_fund_id in number
393 ,p_business_group_id in number
394 ,p_person_id in number
395 ,p_previously_validated_flag in varchar2
396 ,p_request_date in date default null
397 ,p_completion_date in date default null
398 ,p_previous_employer_id in number default null
399 ,p_status in varchar2 default null
400 ,p_employer_amount in number default null
401 ,p_employer_currency_code in varchar2 default null
402 ,p_employee_amount in number default null
403 ,p_employee_currency_code in varchar2 default null
404 ,p_deduction_per_period in number default null
405 ,p_deduction_currency_code in varchar2 default null
406 ,p_percent_of_salary in number default null
407 ,p_validation_id out nocopy number
408 ,p_object_version_number out nocopy number
409 ) is
410 --
411 l_rec pqh_vld_shd.g_rec_type;
412 l_proc varchar2(72) := g_package||'ins';
413 --
414 Begin
415 hr_utility.set_location('Entering:'||l_proc, 5);
416 --
417 -- Call conversion function to turn arguments into the
418 -- p_rec structure.
419 --
420 l_rec :=
421 pqh_vld_shd.convert_args
422 (null
423 ,p_pension_fund_type_code
424 ,p_pension_fund_id
425 ,p_business_group_id
426 ,p_person_id
427 ,p_request_date
428 ,p_completion_date
429 ,p_previous_employer_id
430 ,p_previously_validated_flag
431 ,p_status
432 ,p_employer_amount
433 ,p_employer_currency_code
434 ,p_employee_amount
435 ,p_employee_currency_code
436 ,p_deduction_per_period
437 ,p_deduction_currency_code
438 ,p_percent_of_salary
439 ,null
440 );
441 --
442 -- Having converted the arguments into the pqh_vld_rec
443 -- plsql record structure we call the corresponding record business process.
444 --
445 pqh_vld_ins.ins
446 (p_effective_date
447 ,l_rec
448 );
449 --
450 -- As the primary key argument(s)
451 -- are specified as an OUT's we must set these values.
452 --
453 p_validation_id := l_rec.validation_id;
454 p_object_version_number := l_rec.object_version_number;
455 --
456 hr_utility.set_location(' Leaving:'||l_proc, 10);
457 End ins;
458 --
459 end pqh_vld_ins;