1 Package Body pay_ran_ins as
2 /* $Header: pyranrhi.pkb 120.0.12000000.2 2007/02/10 10:03:01 vetsrini noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_ran_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_range_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_range_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 pay_ran_ins.g_range_id_i := p_range_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 pay_ran_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: pay_ranges_f
88 --
89 insert into pay_ranges_f
90 (range_id
91 ,range_table_id
92 ,low_band
93 ,high_band
94 ,amount1
95 ,amount2
96 ,amount3
97 ,amount4
98 ,amount5
99 ,amount6
100 ,amount7
101 ,amount8
102 ,effective_start_date
103 ,effective_end_date
104 ,object_version_number
105 )
106 Values
107 (p_rec.range_id
108 ,p_rec.range_table_id
109 ,p_rec.low_band
110 ,p_rec.high_band
111 ,p_rec.amount1
112 ,p_rec.amount2
113 ,p_rec.amount3
114 ,p_rec.amount4
115 ,p_rec.amount5
116 ,p_rec.amount6
117 ,p_rec.amount7
118 ,p_rec.amount8
119 ,p_rec.effective_start_date
120 ,p_rec.effective_end_date
121 ,p_rec.object_version_number
122 );
123 --
124 --
125 --
126 hr_utility.set_location(' Leaving:'||l_proc, 10);
127 Exception
128 When hr_api.check_integrity_violated Then
129 -- A check constraint has been violated
130 --
131 pay_ran_shd.constraint_error
132 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
133 When hr_api.parent_integrity_violated Then
134 -- Parent integrity has been violated
135 --
136 pay_ran_shd.constraint_error
137 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
138 When hr_api.unique_integrity_violated Then
139 -- Unique integrity has been violated
140 --
141 pay_ran_shd.constraint_error
142 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
143 When Others Then
144 --
145 Raise;
146 End insert_dml;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |------------------------------< pre_insert >------------------------------|
150 -- ----------------------------------------------------------------------------
151 -- {Start Of Comments}
152 --
153 -- Description:
154 -- This private procedure contains any processing which is required before
155 -- the insert dml. Presently, if the entity has a corresponding primary
156 -- key which is maintained by an associating sequence, the primary key for
157 -- the entity will be populated with the next sequence value in
158 -- preparation for the insert dml.
159 --
160 -- Prerequisites:
161 -- This is an internal procedure which is called from the ins procedure.
162 --
163 -- In Parameters:
164 -- A Pl/Sql record structure.
165 --
166 -- Post Success:
167 -- Processing continues.
168 --
169 -- Post Failure:
170 -- If an error has occurred, an error message and exception will be raised
171 -- but not handled.
172 --
173 -- Developer Implementation Notes:
174 -- Any pre-processing required before the insert dml is issued should be
175 -- coded within this procedure. As stated above, a good example is the
176 -- generation of a primary key number via a corresponding sequence.
177 -- It is important to note that any 3rd party maintenance should be reviewed
178 -- before placing in this procedure.
179 --
180 -- Access Status:
181 -- Internal Row Handler Use Only.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure pre_insert
186 (p_rec in out nocopy pay_ran_shd.g_rec_type
187 ) is
188 --
189 Cursor C_Sel1 is select pay_ranges_f_s.nextval from sys.dual;
190 --
191 Cursor C_Sel2 is
192 Select null
193 from pay_ranges_f
194 where range_id =
195 pay_ran_ins.g_range_id_i;
196 --
197 l_proc varchar2(72) := g_package||'pre_insert';
198 l_exists varchar2(1);
199 --
200 Begin
201 hr_utility.set_location('Entering:'||l_proc, 5);
202 --
203 If (pay_ran_ins.g_range_id_i is not null) Then
204 --
205 -- Verify registered primary key values not already in use
206 --
207 Open C_Sel2;
208 Fetch C_Sel2 into l_exists;
209 If C_Sel2%found Then
210 Close C_Sel2;
211 --
212 -- The primary key values are already in use.
213 --
214 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
215 fnd_message.set_token('TABLE_NAME','pay_ranges_f');
216 fnd_message.raise_error;
217 End If;
218 Close C_Sel2;
219 --
220 -- Use registered key values and clear globals
221 --
222 p_rec.range_id :=
223 pay_ran_ins.g_range_id_i;
224 pay_ran_ins.g_range_id_i := null;
225 Else
226 --
227 -- No registerd key values, so select the next sequence number
228 --
229 --
230 -- Select the next sequence number
231 --
232 Open C_Sel1;
233 Fetch C_Sel1 Into p_rec.range_id;
234 Close C_Sel1;
235 End If;
236 --
237 hr_utility.set_location(' Leaving:'||l_proc, 10);
238 End pre_insert;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |-----------------------------< post_insert >------------------------------|
242 -- ----------------------------------------------------------------------------
243 -- {Start Of Comments}
244 --
245 -- Description:
246 -- This private procedure contains any processing which is required after
247 -- the insert dml.
248 --
249 -- Prerequisites:
250 -- This is an internal procedure which is called from the ins procedure.
251 --
252 -- In Parameters:
253 -- A Pl/Sql record structre.
254 --
255 -- Post Success:
256 -- Processing continues.
257 --
258 -- Post Failure:
259 -- If an error has occurred, an error message and exception will be raised
260 -- but not handled.
261 --
262 -- Developer Implementation Notes:
263 -- Any post-processing required after the insert dml is issued should be
264 -- coded within this procedure. It is important to note that any 3rd party
265 -- maintenance should be reviewed before placing in this procedure.
266 --
267 -- Access Status:
268 -- Internal Row Handler Use Only.
269 --
270 -- {End Of Comments}
271 -- ----------------------------------------------------------------------------
272 Procedure post_insert
273 (p_rec in pay_ran_shd.g_rec_type
274 ) is
275 --
276 l_proc varchar2(72) := g_package||'post_insert';
277 --
278 Begin
279 hr_utility.set_location('Entering:'||l_proc, 5);
280 begin
281 --
282
283 pay_ran_rki.after_insert
284 (p_range_id => p_rec.range_id
285 ,p_range_table_id => p_rec.range_table_id
286 ,p_low_band => p_rec.low_band
287 ,p_high_band => p_rec.high_band
288 ,p_amount1 => p_rec.amount1
289 ,p_amount2 => p_rec.amount2
290 ,p_amount3 => p_rec.amount3
291 ,p_amount4 => p_rec.amount4
292 ,p_amount5 => p_rec.amount5
293 ,p_amount6 => p_rec.amount6
294 ,p_amount7 => p_rec.amount7
295 ,p_amount8 => p_rec.amount8
296 ,p_effective_start_date => p_rec.effective_start_date
297 ,p_effective_end_date => p_rec.effective_end_date
298 ,p_object_version_number => p_rec.object_version_number
299 );
300 --
301 exception
302 --
303 when hr_api.cannot_find_prog_unit then
304 --
305 hr_api.cannot_find_prog_unit_error
306 (p_module_name => 'PAY_RANGES_F'
307 ,p_hook_type => 'AI');
308 --
309 end;
310 --
311 hr_utility.set_location(' Leaving:'||l_proc, 10);
312 End post_insert;
313 --
314 -- ----------------------------------------------------------------------------
315 -- |---------------------------------< ins >----------------------------------|
316 -- ----------------------------------------------------------------------------
317 Procedure ins
318 (p_rec in out nocopy pay_ran_shd.g_rec_type
319 ) is
320 --
321 l_proc varchar2(72) := g_package||'ins';
322 --
323 Begin
324 hr_utility.set_location('Entering:'||l_proc, 5);
325 --
326 -- Call the supporting insert validate operations
327 --
328 pay_ran_bus.insert_validate
329 (p_rec
330 );
331 --
332 -- Call to raise any errors on multi-message list
333 hr_multi_message.end_validation_set;
334 --
335 -- Call the supporting pre-insert operation
336 --
337 pay_ran_ins.pre_insert(p_rec);
338 --
339 -- Insert the row
340 --
341 pay_ran_ins.insert_dml(p_rec);
342 --
343 -- Call the supporting post-insert operation
344 --
345
346 -- Commented Because the User Hook is not provided now
347 /*
348 pay_ran_ins.post_insert
349 (p_rec
350 );
351 */
352
353 --
354 -- Call to raise any errors on multi-message list
355 hr_multi_message.end_validation_set;
356 --
357 hr_utility.set_location('Leaving:'||l_proc, 20);
358 end ins;
359 --
360 -- ----------------------------------------------------------------------------
361 -- |---------------------------------< ins >----------------------------------|
362 -- ----------------------------------------------------------------------------
363 Procedure ins
364 (p_range_table_id in number default null
365 ,p_low_band in number default null
366 ,p_high_band in number default null
367 ,p_amount1 in number default null
368 ,p_amount2 in number default null
369 ,p_amount3 in number default null
370 ,p_amount4 in number default null
371 ,p_amount5 in number default null
372 ,p_amount6 in number default null
373 ,p_amount7 in number default null
374 ,p_amount8 in number default null
375 ,p_effective_start_date in date default null
376 ,p_effective_end_date in date default null
377 ,p_range_id out nocopy number
378 ,p_object_version_number out nocopy number
379 ) is
380 --
381 l_rec pay_ran_shd.g_rec_type;
382 l_proc varchar2(72) := g_package||'ins';
383 --
384 Begin
385 hr_utility.set_location('Entering:'||l_proc, 5);
386 --
387 -- Call conversion function to turn arguments into the
388 -- p_rec structure.
389 --
390 l_rec :=
391 pay_ran_shd.convert_args
392 (null
393 ,p_range_table_id
394 ,p_low_band
395 ,p_high_band
396 ,p_amount1
397 ,p_amount2
398 ,p_amount3
399 ,p_amount4
400 ,p_amount5
401 ,p_amount6
402 ,p_amount7
403 ,p_amount8
404 ,p_effective_start_date
405 ,p_effective_end_date
406 ,null
407 );
408 --
409 -- Having converted the arguments into the pay_ran_rec
410 -- plsql record structure we call the corresponding record business process.
411 --
412 pay_ran_ins.ins
413 (l_rec
414 );
415 --
416 -- As the primary key argument(s)
417 -- are specified as an OUT's we must set these values.
418 --
419 p_range_id := l_rec.range_id;
420 p_object_version_number := l_rec.object_version_number;
421 --
422 hr_utility.set_location(' Leaving:'||l_proc, 10);
423 End ins;
424 --
425 end pay_ran_ins;