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