1 Package Body hxc_hac_ins as
2 /* $Header: hxchacrhi.pkb 120.4 2006/06/13 08:42:23 gsirigin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_hac_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_hac_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 hxc_hac_shd.g_api_dml := true; -- Set the api dml status
68 --
69 -- Insert the row into: hxc_approval_comps
70 --
71 insert into hxc_approval_comps
72 (approval_comp_id
73 ,approval_style_id
74 ,time_recipient_id
75 ,approval_mechanism
76 ,approval_mechanism_id
77 ,wf_item_type
78 ,wf_name
79 ,start_date
80 ,end_date
81 ,object_version_number
82 ,approval_order
83 ,time_category_id
84 ,parent_comp_id
85 ,parent_comp_ovn
86 ,run_recipient_extensions
87 ,creation_date
88 ,created_by
89 ,last_updated_by
90 ,last_update_date
91 ,last_update_login
92 )
93 Values
94 (p_rec.approval_comp_id
95 ,p_rec.approval_style_id
96 ,p_rec.time_recipient_id
97 ,p_rec.approval_mechanism
98 ,p_rec.approval_mechanism_id
99 ,p_rec.wf_item_type
100 ,p_rec.wf_name
101 ,p_rec.start_date
102 ,p_rec.end_date
103 ,p_rec.object_version_number
104 ,p_rec.approval_order
105 ,p_rec.time_category_id
106 ,p_rec.parent_comp_id
107 ,p_rec.parent_comp_ovn
108 ,p_rec.run_recipient_extensions
109 ,sysdate
110 ,fnd_global.user_id
111 ,fnd_global.user_id
112 ,sysdate
113 ,fnd_global.login_id
114 );
115 --
116 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
117 --
118 if g_debug then
119 hr_utility.set_location(' Leaving:'||l_proc, 10);
120 end if;
121 Exception
122 When hr_api.check_integrity_violated Then
123 -- A check constraint has been violated
124 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
125 hxc_hac_shd.constraint_error
126 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127 When hr_api.parent_integrity_violated Then
128 -- Parent integrity has been violated
129 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
130 hxc_hac_shd.constraint_error
131 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132 When hr_api.unique_integrity_violated Then
133 -- Unique integrity has been violated
134 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
135 hxc_hac_shd.constraint_error
136 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
137 When Others Then
138 hxc_hac_shd.g_api_dml := false; -- Unset the api dml status
139 Raise;
140 End insert_dml;
141 --
142 -- ----------------------------------------------------------------------------
143 -- |------------------------------< pre_insert >------------------------------|
144 -- ----------------------------------------------------------------------------
145 -- {Start Of Comments}
146 --
147 -- Description:
148 -- This private procedure contains any processing which is required before
149 -- the insert dml. Presently, if the entity has a corresponding primary
150 -- key which is maintained by an associating sequence, the primary key for
151 -- the entity will be populated with the next sequence value in
152 -- preparation for the insert dml.
153 --
154 -- Prerequisites:
155 -- This is an internal procedure which is called from the ins procedure.
156 --
157 -- In Parameters:
158 -- A Pl/Sql record structre.
159 --
160 -- Post Success:
161 -- Processing continues.
162 --
163 -- Post Failure:
164 -- If an error has occurred, an error message and exception will be raised
165 -- but not handled.
166 --
167 -- Developer Implementation Notes:
168 -- Any pre-processing required before the insert dml is issued should be
169 -- coded within this procedure. As stated above, a good example is the
170 -- generation of a primary key number via a corresponding sequence.
171 -- It is important to note that any 3rd party maintenance should be reviewed
172 -- before placing in this procedure.
173 --
174 -- Access Status:
175 -- Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure pre_insert
180 (p_rec in out nocopy hxc_hac_shd.g_rec_type
181 ) is
182 --
183 l_proc varchar2(72);
184 --
185 Cursor C_Sel1 is select hxc_approval_comps_s.nextval from sys.dual;
186 --
187 Begin
188 if g_debug then
189 l_proc := g_package||'pre_insert';
190 hr_utility.set_location('Entering:'||l_proc, 5);
191 end if;
192 --
193 --
194 -- Select the next sequence number
195 --
196 Open C_Sel1;
197 Fetch C_Sel1 Into p_rec.approval_comp_id;
198 Close C_Sel1;
199 --
200 if g_debug then
201 hr_utility.set_location(' Leaving:'||l_proc, 10);
202 end if;
203 End pre_insert;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |-----------------------------< post_insert >------------------------------|
207 -- ----------------------------------------------------------------------------
208 -- {Start Of Comments}
209 --
210 -- Description:
211 -- This private procedure contains any processing which is required after the
212 -- insert dml.
213 --
214 -- Prerequisites:
215 -- This is an internal procedure which is called from the ins procedure.
216 --
217 -- In Parameters:
218 -- A Pl/Sql record structre.
219 --
220 -- Post Success:
221 -- Processing continues.
222 --
223 -- Post Failure:
224 -- If an error has occurred, an error message and exception will be raised
225 -- but not handled.
226 --
227 -- Developer Implementation Notes:
228 -- Any post-processing required after the insert dml is issued should be
229 -- coded within this procedure. It is important to note that any 3rd party
230 -- maintenance should be reviewed before placing in this procedure.
231 --
232 -- Access Status:
233 -- Internal Row Handler Use Only.
234 --
235 -- {End Of Comments}
236 -- ----------------------------------------------------------------------------
237 Procedure post_insert
238 (p_effective_date in date
239 ,p_rec in hxc_hac_shd.g_rec_type
240 ) is
241 --
242 l_proc varchar2(72);
243 --
244 Begin
245 if g_debug then
246 l_proc := g_package||'post_insert';
247 hr_utility.set_location('Entering:'||l_proc, 5);
248 end if;
249 begin
250 --
251
252
253
254
255
256
257
258
259 hxc_hac_rki.after_insert
260 (p_effective_date => p_effective_date
261 ,p_approval_comp_id
262 => p_rec.approval_comp_id
263 ,p_approval_style_id
264 => p_rec.approval_style_id
265 ,p_time_recipient_id
266 => p_rec.time_recipient_id
267 ,p_approval_mechanism
268 => p_rec.approval_mechanism
269 ,p_approval_mechanism_id
270 => p_rec.approval_mechanism_id
271 ,p_wf_item_type
272 => p_rec.wf_item_type
273 ,p_wf_name
274 => p_rec.wf_name
275 ,p_start_date
276 => p_rec.start_date
277 ,p_end_date
278 => p_rec.end_date
279 ,p_object_version_number
280 => p_rec.object_version_number
281 ,p_approval_order
282 => p_rec.approval_order
283 ,p_time_category_id
284 => p_rec.time_category_id
285 ,p_parent_comp_id
286 => p_rec.parent_comp_id
287 ,p_parent_comp_ovn
288 => p_rec.parent_comp_ovn
289 ,p_run_recipient_extensions =>p_rec.run_recipient_extensions
290 );
291 --
292 exception
293 --
294 when hr_api.cannot_find_prog_unit then
295 --
296 hr_api.cannot_find_prog_unit_error
297 (p_module_name => 'HXC_APPROVAL_COMPS'
298 ,p_hook_type => 'AI');
299 --
300 end;
301 --
302 if g_debug then
303 hr_utility.set_location(' Leaving:'||l_proc, 10);
304 end if;
305 End post_insert;
306 --
307 -- ----------------------------------------------------------------------------
308 -- |---------------------------------< ins >----------------------------------|
309 -- ----------------------------------------------------------------------------
310 Procedure ins
311 (p_effective_date in date
312 ,p_rec in out nocopy hxc_hac_shd.g_rec_type
313 ) is
314 --
315 l_proc varchar2(72);
316 --
317 Begin
318 g_debug:=hr_utility.debug_enabled;
319 if g_debug then
320 l_proc := g_package||'ins';
321 hr_utility.set_location('Entering:'||l_proc, 5);
322 end if;
323 --
324 -- Call the supporting insert validate operations
325 --
326 hxc_hac_bus.insert_validate
327 (p_effective_date
328 ,p_rec
329 );
330 --
331 -- Call the supporting pre-insert operation
332 --
333 hxc_hac_ins.pre_insert(p_rec);
334 --
335 -- Insert the row
336 --
337 hxc_hac_ins.insert_dml(p_rec);
338 --
339 -- Call the supporting post-insert operation
340 --
341 hxc_hac_ins.post_insert
342 (p_effective_date
343 ,p_rec
344 );
345 --
346 if g_debug then
347 hr_utility.set_location('Leaving:'||l_proc, 20);
348 end if;
349 end ins;
350 --
351 -- ----------------------------------------------------------------------------
352 -- |---------------------------------< ins >----------------------------------|
353 -- ----------------------------------------------------------------------------
354 Procedure ins
355 (p_effective_date in date
356 ,p_approval_style_id in number
357 ,p_time_recipient_id in number
358 ,p_approval_mechanism in varchar2
359 ,p_start_date in date
360 ,p_end_date in date
361 ,p_approval_mechanism_id in number default null
362 ,p_wf_item_type in varchar2 default null
363 ,p_wf_name in varchar2 default null
364 ,p_approval_order in number default null
365 ,p_approval_comp_id out nocopy number
366 ,p_object_version_number out nocopy number
367 ,p_time_category_id in number default null
368 ,p_parent_comp_id in number default null
369 ,p_parent_comp_ovn in number default null
370 ,p_run_recipient_extensions in varchar2 default null
371 ) is
372 --
373 l_rec hxc_hac_shd.g_rec_type;
374 l_proc varchar2(72);
375 --
376 Begin
377 g_debug:=hr_utility.debug_enabled;
378 if g_debug then
379 l_proc := g_package||'ins';
380 hr_utility.set_location('Entering:'||l_proc, 5);
381 end if;
382 --
383 -- Call conversion function to turn arguments into the
384 -- p_rec structure.
385 --
386 l_rec :=
387 hxc_hac_shd.convert_args
388 (null
389 ,p_approval_style_id
390 ,p_time_recipient_id
391 ,p_approval_mechanism
392 ,p_approval_mechanism_id
393 ,p_wf_item_type
394 ,p_wf_name
395 ,p_start_date
396 ,p_end_date
397 ,null
398 ,p_approval_order
399 ,p_time_category_id
400 ,p_parent_comp_id
401 ,p_parent_comp_ovn
402 ,p_run_recipient_extensions
403 );
404 --
407 --
408 hxc_hac_ins.ins
409 (p_effective_date
410 ,l_rec
411 );
412 --
413 -- As the primary key argument(s)
414 -- are specified as an OUT's we must set these values.
415 --
416 p_approval_comp_id := l_rec.approval_comp_id;
417 p_object_version_number := l_rec.object_version_number;
418 --
419 if g_debug then
420 hr_utility.set_location(' Leaving:'||l_proc, 10);
421 end if;
422 End ins;
423 --
424 end hxc_hac_ins;
406 -- plsql record structure we call the corresponding record business process.
405 -- Having converted the arguments into the hxc_hac_rec