4 -- ----------------------------------------------------------------------------
1 Package Body pay_cnu_ins as
2 /* $Header: pycnurhi.pkb 120.0 2005/05/29 04:04:56 appldev noship $ */
3 --
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_cnu_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
54 (p_rec in out nocopy pay_cnu_shd.g_rec_type
55 ) is
56 --
57 l_proc varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60 hr_utility.set_location('Entering:'||l_proc, 5);
61 p_rec.object_version_number := 1; -- Initialise the object version
62 --
63 --
64 --
65 -- Insert the row into: pay_fr_contribution_usages
66 --
67 insert into pay_fr_contribution_usages
68 (contribution_usage_id
69 ,date_from
70 ,date_to
71 ,group_code
72 ,process_type
73 ,element_name
74 ,rate_type
75 ,contribution_code
76 ,retro_contribution_code
77 ,contribution_type
78 ,contribution_usage_type
79 ,rate_category
80 ,business_group_id
81 ,object_version_number
82 ,code_rate_id
83 )
84 Values
85 (p_rec.contribution_usage_id
86 ,p_rec.date_from
87 ,p_rec.date_to
88 ,p_rec.group_code
89 ,p_rec.process_type
90 ,p_rec.element_name
91 ,p_rec.rate_type
92 ,p_rec.contribution_code
93 ,p_rec.retro_contribution_code
94 ,p_rec.contribution_type
95 ,p_rec.contribution_usage_type
96 ,p_rec.rate_category
97 ,p_rec.business_group_id
98 ,p_rec.object_version_number
99 ,p_rec.code_rate_id
100 );
101 --
102 --
103 --
104 hr_utility.set_location(' Leaving:'||l_proc, 10);
105 Exception
106 When hr_api.check_integrity_violated Then
107 -- A check constraint has been violated
108 --
109 pay_cnu_shd.constraint_error
110 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111 When hr_api.parent_integrity_violated Then
112 -- Parent integrity has been violated
113 --
114 pay_cnu_shd.constraint_error
115 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116 When hr_api.unique_integrity_violated Then
117 -- Unique integrity has been violated
118 --
119 pay_cnu_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When Others Then
122 --
123 Raise;
124 End insert_dml;
125 --
126 -- ----------------------------------------------------------------------------
127 -- |------------------------------< pre_insert >------------------------------|
128 -- ----------------------------------------------------------------------------
129 -- {Start Of Comments}
130 --
131 -- Description:
132 -- This private procedure contains any processing which is required before
133 -- the insert dml. Presently, if the entity has a corresponding primary
134 -- key which is maintained by an associating sequence, the primary key for
135 -- the entity will be populated with the next sequence value in
136 -- preparation for the insert dml.
137 --
138 -- Prerequisites:
139 -- This is an internal procedure which is called from the ins procedure.
140 --
141 -- In Parameters:
142 -- A Pl/Sql record structre.
143 --
144 -- Post Success:
145 -- Processing continues.
146 --
147 -- Post Failure:
148 -- If an error has occurred, an error message and exception will be raised
149 -- but not handled.
150 --
154 -- generation of a primary key number via a corresponding sequence.
151 -- Developer Implementation Notes:
152 -- Any pre-processing required before the insert dml is issued should be
153 -- coded within this procedure. As stated above, a good example is the
155 -- It is important to note that any 3rd party maintenance should be reviewed
156 -- before placing in this procedure.
157 --
158 -- Access Status:
159 -- Internal Row Handler Use Only.
160 --
161 -- {End Of Comments}
162 -- ----------------------------------------------------------------------------
163 Procedure pre_insert
164 (p_rec in out nocopy pay_cnu_shd.g_rec_type
165 ) is
166 --
167 l_proc varchar2(72) := g_package||'pre_insert';
168 --
169 Cursor C_Sel1 is select pay_fr_contribution_usages_s.nextval from sys.dual;
170 --
171 Begin
172 hr_utility.set_location('Entering:'||l_proc, 5);
173 --
174 --
175 -- Select the next sequence number
176 --
177 Open C_Sel1;
178 Fetch C_Sel1 Into p_rec.contribution_usage_id;
179 Close C_Sel1;
180 --
181 hr_utility.set_location(' Leaving:'||l_proc, 10);
182 End pre_insert;
183 --
184 -- ----------------------------------------------------------------------------
185 -- |-----------------------------< post_insert >------------------------------|
186 -- ----------------------------------------------------------------------------
187 -- {Start Of Comments}
188 --
189 -- Description:
190 -- This private procedure contains any processing which is required after the
191 -- insert dml.
192 --
193 -- Prerequisites:
194 -- This is an internal procedure which is called from the ins procedure.
195 --
196 -- In Parameters:
197 -- A Pl/Sql record structre.
198 --
199 -- Post Success:
200 -- Processing continues.
201 --
202 -- Post Failure:
203 -- If an error has occurred, an error message and exception will be raised
204 -- but not handled.
205 --
206 -- Developer Implementation Notes:
207 -- Any post-processing required after the insert dml is issued should be
208 -- coded within this procedure. It is important to note that any 3rd party
209 -- maintenance should be reviewed before placing in this procedure.
210 --
211 -- Access Status:
212 -- Internal Row Handler Use Only.
213 --
214 -- {End Of Comments}
215 -- ----------------------------------------------------------------------------
216 Procedure post_insert
217 (p_rec in pay_cnu_shd.g_rec_type
218 ) is
219 --
220 l_proc varchar2(72) := g_package||'post_insert';
221 --
222 Begin
223 hr_utility.set_location('Entering:'||l_proc, 5);
224 begin
225 --
226 PAY_cnu_RKI.AFTER_INSERT(
227 p_contribution_usage_id => p_rec.contribution_usage_id
228 ,p_date_from => p_rec.date_from
229 ,p_date_to => p_rec.date_to
230 ,p_group_code => p_rec.group_code
231 ,p_process_type => p_rec.process_type
232 ,p_element_name => p_rec.element_name
233 ,p_rate_type => p_rec.rate_type
234 ,p_contribution_code => p_rec.contribution_code
235 ,p_retro_contribution_code => p_rec.retro_contribution_code
236 ,p_contribution_type => p_rec.contribution_type
237 ,p_contribution_usage_type => p_rec.contribution_usage_type
238 ,p_rate_category => p_rec.rate_category
239 ,p_business_group_id => p_rec.business_group_id
240 ,p_object_version_number => p_rec.object_version_number
241 ,p_code_rate_id => p_rec.code_Rate_id
242 );
243 --
244 exception
245 --
246 when hr_api.cannot_find_prog_unit then
247 --
248 hr_api.cannot_find_prog_unit_error
249 (p_module_name => 'PAY_FR_CONTRIBUTION_USAGES'
250 ,p_hook_type => 'AI');
251 --
252 end;
253 --
254 hr_utility.set_location(' Leaving:'||l_proc, 10);
255 End post_insert;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |---------------------------------< ins >----------------------------------|
259 -- ----------------------------------------------------------------------------
260 Procedure ins
261 (p_effective_date in date
262 ,p_rec in out nocopy pay_cnu_shd.g_rec_type
263 ) is
264 --
265 l_proc varchar2(72) := g_package||'ins';
266 l_code_Rate_id number;
267 --
268 Begin
269 hr_utility.set_location('Entering:'||l_proc, 5);
270 --
271 -- Call the supporting insert validate operations
272 --
273 pay_cnu_bus.insert_validate
274 (p_effective_date
275 ,p_rec
276 ,l_code_rate_id
277 );
278 --
279 -- update the row to the derived code_Rate_id
280 --
281 p_rec.code_Rate_id := l_code_Rate_id;
282 --
283 -- Call the supporting pre-insert operation
284 --
285 pay_cnu_ins.pre_insert(p_rec);
286 --
287 -- Insert the row
288 --
289 pay_cnu_ins.insert_dml(p_rec);
290 --
291 -- Call the supporting post-insert operation
292 --
293 pay_cnu_ins.post_insert
294 (p_rec
295 );
296 --
297 hr_utility.set_location('Leaving:'||l_proc, 20);
298 end ins;
299 --
300 -- ----------------------------------------------------------------------------
304 (p_effective_date in date
301 -- |---------------------------------< ins >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure ins
305 ,p_date_from in date
306 ,p_group_code in varchar2
307 ,p_process_type in varchar2
308 ,p_element_name in varchar2
309 ,p_contribution_type in varchar2
310 ,p_contribution_usage_type in varchar2
311 ,p_rate_category in varchar2
312 ,p_date_to in date default null
313 ,p_rate_type in varchar2 default null
314 ,p_contribution_code in varchar2 default null
315 ,p_retro_contribution_code in varchar2 default null
316 ,p_business_group_id in number default null
317 ,p_contribution_usage_id out nocopy number
318 ,p_object_version_number out nocopy number
319 ,p_code_rate_id in out nocopy number
320 ) is
321 --
322 l_rec pay_cnu_shd.g_rec_type;
323 l_proc varchar2(72) := g_package||'ins';
324 --
325 Begin
326 hr_utility.set_location('Entering:'||l_proc, 5);
327 --
328 -- Call conversion function to turn arguments into the
329 -- p_rec structure.
330 --
331 l_rec :=
332 pay_cnu_shd.convert_args
333 (null
334 ,p_date_from
335 ,p_date_to
336 ,p_group_code
337 ,p_process_type
338 ,p_element_name
339 ,p_rate_type
340 ,p_contribution_code
341 ,p_retro_contribution_code
342 ,p_contribution_type
343 ,p_contribution_usage_type
344 ,p_rate_category
345 ,p_business_group_id
346 ,null
347 ,p_code_Rate_id
348 );
349 --
350 -- Having converted the arguments into the pay_cnu_rec
351 -- plsql record structure we call the corresponding record business process.
352 --
353 pay_cnu_ins.ins
354 ( p_effective_date
355 ,l_rec
356 );
357 --
358 -- As the primary key argument(s)
359 -- are specified as an OUT's we must set these values.
360 --
361 p_contribution_usage_id := l_rec.contribution_usage_id;
362 p_object_version_number := l_rec.object_version_number;
363 p_code_rate_id := l_rec.code_Rate_id;
364 --
365 -- The code rate id is IN OUT so it's value will be automatically passed back.
366 --
367 hr_utility.set_location(' Leaving:'||l_proc, 10);
368 End ins;
369 --
370 end pay_cnu_ins;