1 Package Body hxc_hrr_ins as
2 /* $Header: hxchrrrhi.pkb 120.3 2005/09/23 10:43:47 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_hrr_ins.'; -- Global package name
9 g_debug boolean :=hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< insert_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- This procedure controls the actual dml insert logic. The processing of
18 -- this procedure are as follows:
19 -- 1) Initialise the object_version_number to 1 if the object_version_number
20 -- is defined as an attribute for this entity.
21 -- 2) To set and unset the g_api_dml status as required (as we are about to
22 -- perform dml).
23 -- 3) To insert the row into the schema.
24 -- 4) To trap any constraint violations that may have occurred.
25 -- 5) To raise any other errors.
26 --
27 -- Prerequisites:
28 -- This is an internal private procedure which must be called from the ins
29 -- procedure and must have all mandatory attributes set (except the
30 -- object_version_number which is initialised within this procedure).
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be inserted into the schema.
37 --
38 -- Post Failure:
39 -- On the insert dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If a check, unique or parent integrity constraint violation is raised the
42 -- constraint_error procedure will be called.
43 -- If any other error is reported, the error will be raised after the
44 -- g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 -- None.
48 --
49 -- Access Status:
50 -- Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure insert_dml
55 (p_rec in out nocopy hxc_hrr_shd.g_rec_type
56 ) is
57 --
58 l_proc varchar2(72);
59 --
60 Begin
61 if g_debug then
62 l_proc := g_package||'insert_dml';
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 end if;
65 p_rec.object_version_number := 1; -- Initialise the object version
66 --
67 --
68 --
69 -- Insert the row into: hxc_resource_rules
70 --
71 insert into hxc_resource_rules
72 (resource_rule_id
73 ,name
74 ,business_group_id
75 ,legislation_code
76 ,eligibility_criteria_type
77 ,eligibility_criteria_id
78 ,pref_hierarchy_id
79 ,rule_evaluation_order
80 ,resource_type
81 ,start_date
82 ,end_date
83 ,object_version_number
84 ,creation_date
85 ,created_by
86 ,last_updated_by
87 ,last_update_date
88 ,last_update_login
89 )
90 Values
91 (p_rec.resource_rule_id
92 ,p_rec.name
93 ,p_rec.business_group_id
94 ,p_rec.legislation_code
95 ,p_rec.eligibility_criteria_type
96 ,p_rec.eligibility_criteria_id
97 ,p_rec.pref_hierarchy_id
98 ,p_rec.rule_evaluation_order
99 ,p_rec.resource_type
100 ,p_rec.start_date
101 ,p_rec.end_date
102 ,p_rec.object_version_number
103 ,sysdate
104 ,fnd_global.user_id
105 ,fnd_global.user_id
106 ,sysdate
107 ,fnd_global.login_id
108 );
109 --
110 --
111 --
112 if g_debug then
113 hr_utility.set_location(' Leaving:'||l_proc, 10);
114 end if;
115 Exception
116 When hr_api.check_integrity_violated Then
117 -- A check constraint has been violated
118 --
119 hxc_hrr_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When hr_api.parent_integrity_violated Then
122 -- Parent integrity has been violated
123 --
124 hxc_hrr_shd.constraint_error
125 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126 When hr_api.unique_integrity_violated Then
127 -- Unique integrity has been violated
128 --
129 hxc_hrr_shd.constraint_error
130 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131 When Others Then
132 --
133 Raise;
134 End insert_dml;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |------------------------------< pre_insert >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 -- This private procedure contains any processing which is required before
143 -- the insert dml. Presently, if the entity has a corresponding primary
144 -- key which is maintained by an associating sequence, the primary key for
145 -- the entity will be populated with the next sequence value in
146 -- preparation for the insert dml.
147 --
148 -- Prerequisites:
149 -- This is an internal procedure which is called from the ins procedure.
150 --
151 -- In Parameters:
152 -- A Pl/Sql record structre.
153 --
154 -- Post Success:
155 -- Processing continues.
156 --
157 -- Post Failure:
158 -- If an error has occurred, an error message and exception will be raised
159 -- but not handled.
160 --
161 -- Developer Implementation Notes:
162 -- Any pre-processing required before the insert dml is issued should be
163 -- coded within this procedure. As stated above, a good example is the
164 -- generation of a primary key number via a corresponding sequence.
165 -- It is important to note that any 3rd party maintenance should be reviewed
166 -- before placing in this procedure.
167 --
168 -- Access Status:
169 -- Internal Row Handler Use Only.
170 --
171 -- {End Of Comments}
172 -- ----------------------------------------------------------------------------
173 Procedure pre_insert
174 (p_rec in out nocopy hxc_hrr_shd.g_rec_type
175 ) is
176 --
177 l_proc varchar2(72);
178 --
179 Cursor C_Sel1 is select hxc_resource_rules_s.nextval from sys.dual;
180 --
181 Begin
182 if g_debug then
183 l_proc := g_package||'pre_insert';
184 hr_utility.set_location('Entering:'||l_proc, 5);
185 end if;
186 --
187 --
188 -- Select the next sequence number
189 --
190 Open C_Sel1;
191 Fetch C_Sel1 Into p_rec.resource_rule_id;
192 Close C_Sel1;
193 --
194 if g_debug then
195 hr_utility.set_location(' Leaving:'||l_proc, 10);
196 end if;
197 End pre_insert;
198 --
199 -- ----------------------------------------------------------------------------
200 -- |-----------------------------< post_insert >------------------------------|
201 -- ----------------------------------------------------------------------------
202 -- {Start Of Comments}
203 --
204 -- Description:
205 -- This private procedure contains any processing which is required after the
206 -- insert dml.
207 --
208 -- Prerequisites:
209 -- This is an internal procedure which is called from the ins procedure.
210 --
211 -- In Parameters:
212 -- A Pl/Sql record structre.
213 --
214 -- Post Success:
215 -- Processing continues.
216 --
217 -- Post Failure:
218 -- If an error has occurred, an error message and exception will be raised
219 -- but not handled.
220 --
221 -- Developer Implementation Notes:
222 -- Any post-processing required after the insert dml is issued should be
223 -- coded within this procedure. It is important to note that any 3rd party
224 -- maintenance should be reviewed before placing in this procedure.
225 --
226 -- Access Status:
227 -- Internal Row Handler Use Only.
228 --
229 -- {End Of Comments}
230 -- ----------------------------------------------------------------------------
231 Procedure post_insert
232 (p_effective_date in date
233 ,p_rec in hxc_hrr_shd.g_rec_type
234 ) is
235 --
236 l_proc varchar2(72);
237 --
238 Begin
239 if g_debug then
240 l_proc := g_package||'post_insert';
241 hr_utility.set_location('Entering:'||l_proc, 5);
242 end if;
243 begin
244 --
245 hxc_hrr_rki.after_insert
246 (p_effective_date => p_effective_date
247 ,p_resource_rule_id
248 => p_rec.resource_rule_id
249 ,p_name
250 => p_rec.name
251 ,p_business_group_id => p_rec.business_group_id
252 ,p_legislation_code => p_rec.legislation_code
253 ,p_eligibility_criteria_type
254 => p_rec.eligibility_criteria_type
255 ,p_eligibility_criteria_id
256 => p_rec.eligibility_criteria_id
257 ,p_pref_hierarchy_id
258 => p_rec.pref_hierarchy_id
259 ,p_rule_evaluation_order
260 => p_rec.rule_evaluation_order
261 ,p_resource_type
262 => p_rec.resource_type
263 ,p_start_date
264 => p_rec.start_date
265 ,p_end_date
266 => p_rec.end_date
267 ,p_object_version_number
268 => p_rec.object_version_number
269 );
270 --
271 exception
272 --
273 when hr_api.cannot_find_prog_unit then
274 --
275 hr_api.cannot_find_prog_unit_error
276 (p_module_name => 'HXC_RESOURCE_RULES'
277 ,p_hook_type => 'AI');
278 --
279 end;
280 --
281 if g_debug then
282 hr_utility.set_location(' Leaving:'||l_proc, 10);
283 end if;
284 End post_insert;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |---------------------------------< ins >----------------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure ins
290 (p_effective_date in date
291 ,p_rec in out nocopy hxc_hrr_shd.g_rec_type
292 ) is
293 --
294 l_proc varchar2(72);
295 --
296 Begin
297 g_debug:=hr_utility.debug_enabled;
298 if g_debug then
299 l_proc := g_package||'ins';
300 hr_utility.set_location('Entering:'||l_proc, 5);
301 end if;
302 --
303 -- Call the supporting insert validate operations
304 --
305 hxc_hrr_bus.insert_validate
306 (p_effective_date
307 ,p_rec
308 );
309 --
310 -- Call the supporting pre-insert operation
311 --
312 hxc_hrr_ins.pre_insert(p_rec);
313 --
314 -- Insert the row
315 --
316 hxc_hrr_ins.insert_dml(p_rec);
317 --
318 -- Call the supporting post-insert operation
319 --
320 hxc_hrr_ins.post_insert
321 (p_effective_date
322 ,p_rec
323 );
324 --
325 if g_debug then
326 hr_utility.set_location('Leaving:'||l_proc, 20);
327 end if;
328 end ins;
329 --
330 -- ----------------------------------------------------------------------------
331 -- |---------------------------------< ins >----------------------------------|
332 -- ----------------------------------------------------------------------------
333 Procedure ins
334 (p_effective_date in date
335 ,p_name in varchar2
336 ,p_business_group_id in number default null
337 ,p_legislation_code in varchar2 default null
338 ,p_eligibility_criteria_type in varchar2
339 ,p_eligibility_criteria_id in varchar2 default null
340 ,p_pref_hierarchy_id in number
341 ,p_rule_evaluation_order in number
342 ,p_resource_type in varchar2
343 ,p_start_date in date default null
344 ,p_end_date in date default null
345 ,p_resource_rule_id out nocopy number
346 ,p_object_version_number out nocopy number
347 ) is
348 --
349 l_rec hxc_hrr_shd.g_rec_type;
350 l_proc varchar2(72);
351 --
352 Begin
353 g_debug:=hr_utility.debug_enabled;
354 if g_debug then
355 l_proc := g_package||'ins';
356 hr_utility.set_location('Entering:'||l_proc, 5);
357 end if;
358 --
359 -- Call conversion function to turn arguments into the
360 -- p_rec structure.
361 --
362 l_rec :=
363 hxc_hrr_shd.convert_args
364 (null
365 ,p_name
366 ,p_business_group_id
367 ,p_legislation_code
368 ,p_eligibility_criteria_type
369 ,p_eligibility_criteria_id
370 ,p_pref_hierarchy_id
371 ,p_rule_evaluation_order
372 ,p_resource_type
373 ,p_start_date
374 ,p_end_date
375 ,null
376 );
377 --
378 -- Having converted the arguments into the hxc_hrr_rec
379 -- plsql record structure we call the corresponding record business process.
380 --
381 hxc_hrr_ins.ins
382 (p_effective_date
383 ,l_rec
384 );
385 --
386 -- As the primary key argument(s)
387 -- are specified as an OUT's we must set these values.
388 --
389 p_resource_rule_id := l_rec.resource_rule_id;
390 p_object_version_number := l_rec.object_version_number;
391 --
392 if g_debug then
393 hr_utility.set_location(' Leaving:'||l_proc, 10);
394 end if;
395 End ins;
396 --
397 end hxc_hrr_ins;