1 Package Body hr_trs_ins as
2 /* $Header: hrtrsrhi.pkb 120.2 2005/10/11 02:10:33 hpandya noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_trs_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_transaction_step_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_transaction_step_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 hr_trs_ins.g_transaction_step_id_i := p_transaction_step_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 -- Pre Conditions:
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 Table Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml(p_rec in out nocopy hr_trs_shd.g_rec_type) is
76 --
77 l_proc varchar2(72) := g_package||'insert_dml';
78 --
79 Begin
80 hr_utility.set_location('Entering:'||l_proc, 5);
81 p_rec.object_version_number := 1; -- Initialise the object version
82 --
83 hr_trs_shd.g_api_dml := true; -- Set the api dml status
84 --
85 -- Insert the row into: hr_api_transaction_steps
86 --
87 insert into hr_api_transaction_steps
88 ( transaction_step_id,
89 transaction_id,
90 api_name,
91 api_display_name,
92 processing_order,
93 item_type,
94 item_key,
95 activity_id,
96 creator_person_id,
97 update_person_id,
98 object_version_number,
99 object_type,
100 object_name,
101 object_identifier,
102 object_state,
103 pk1,
104 pk2,
105 pk3,
106 pk4,
107 pk5,
108 information_category,
109 information1,
110 information2,
111 information3,
112 information4,
113 information5,
114 information6,
115 information7,
116 information8,
117 information9,
118 information10,
119 information11,
120 information12,
121 information13,
122 information14,
123 information15,
124 information16,
125 information17,
126 information18,
127 information19,
128 information20,
129 information21,
130 information22,
131 information23,
132 information24,
133 information25,
134 information26,
135 information27,
136 information28,
137 information29,
138 information30
139
140 )
141 Values
142 ( p_rec.transaction_step_id,
143 p_rec.transaction_id,
144 p_rec.api_name,
145 p_rec.api_display_name,
146 p_rec.processing_order,
147 p_rec.item_type,
148 p_rec.item_key,
149 p_rec.activity_id,
150 p_rec.creator_person_id,
151 p_rec.update_person_id,
152 p_rec.object_version_number,
153 p_rec.object_type,
154 p_rec.object_name,
155 p_rec.object_identifier,
156 p_rec.object_state,
157 p_rec.pk1,
158 p_rec.pk2,
159 p_rec.pk3,
160 p_rec.pk4,
161 p_rec.pk5,
162 p_rec.information_category,
163 p_rec.information1,
164 p_rec.information2,
165 p_rec.information3,
166 p_rec.information4,
167 p_rec.information5,
168 p_rec.information6,
169 p_rec.information7,
170 p_rec.information8,
171 p_rec.information9,
172 p_rec.information10,
173 p_rec.information11,
174 p_rec.information12,
175 p_rec.information13,
176 p_rec.information14,
177 p_rec.information15,
178 p_rec.information16,
179 p_rec.information17,
180 p_rec.information18,
181 p_rec.information19,
182 p_rec.information20,
183 p_rec.information21,
184 p_rec.information22,
185 p_rec.information23,
186 p_rec.information24,
187 p_rec.information25,
188 p_rec.information26,
189 p_rec.information27,
190 p_rec.information28,
191 p_rec.information29,
192 p_rec.information30
193
194 );
195 --
196 hr_trs_shd.g_api_dml := false; -- Unset the api dml status
197 --
198 hr_utility.set_location(' Leaving:'||l_proc, 10);
199 Exception
200 When hr_api.check_integrity_violated Then
201 -- A check constraint has been violated
202 hr_trs_shd.g_api_dml := false; -- Unset the api dml status
203 hr_trs_shd.constraint_error
204 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
205 When hr_api.parent_integrity_violated Then
206 -- Parent integrity has been violated
207 hr_trs_shd.g_api_dml := false; -- Unset the api dml status
208 hr_trs_shd.constraint_error
209 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
210 When hr_api.unique_integrity_violated Then
211 -- Unique integrity has been violated
212 hr_trs_shd.g_api_dml := false; -- Unset the api dml status
213 hr_trs_shd.constraint_error
214 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
215 When Others Then
216 hr_trs_shd.g_api_dml := false; -- Unset the api dml status
217 Raise;
218 End insert_dml;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |------------------------------< pre_insert >------------------------------|
222 -- ----------------------------------------------------------------------------
223 -- {Start Of Comments}
224 --
225 -- Description:
226 -- This private procedure contains any processing which is required before
227 -- the insert dml. Presently, if the entity has a corresponding primary
228 -- key which is maintained by an associating sequence, the primary key for
229 -- the entity will be populated with the next sequence value in
230 -- preparation for the insert dml.
231 --
232 -- Pre Conditions:
233 -- This is an internal procedure which is called from the ins procedure.
234 --
235 -- In Parameters:
236 -- A Pl/Sql record structre.
237 --
238 -- Post Success:
239 -- Processing continues.
240 --
241 -- Post Failure:
242 -- If an error has occurred, an error message and exception will be raised
243 -- but not handled.
244 --
245 -- Developer Implementation Notes:
246 -- Any pre-processing required before the insert dml is issued should be
247 -- coded within this procedure. As stated above, a good example is the
248 -- generation of a primary key number via a corresponding sequence.
249 -- It is important to note that any 3rd party maintenance should be reviewed
250 -- before placing in this procedure.
251 --
252 -- Access Status:
253 -- Internal Table Handler Use Only.
254 --
255 -- {End Of Comments}
256 -- ----------------------------------------------------------------------------
257 Procedure pre_insert(p_rec in out nocopy hr_trs_shd.g_rec_type) is
258 --
259 l_proc varchar2(72) := g_package||'pre_insert';
260 l_exists varchar2(1);
261 --
262 Cursor C_Sel1 is select hr_api_transaction_steps_s.nextval from sys.dual;
263
264 Cursor C_Sel2 is
265 select null
266 from hr_api_transaction_steps
267 where transaction_step_id = hr_trs_ins.g_transaction_step_id_i;
268 --
269 --
270 Begin
271 hr_utility.set_location('Entering:'||l_proc, 5);
272
273 If hr_trs_ins.g_transaction_step_id_i is not null then
274 --
275 -- Verify registered primary key values not already in use
276 --
277 Open C_Sel2;
278 Fetch C_Sel2 into l_exists;
279 If C_Sel2%found then
280 Close C_Sel2;
281 --
282 -- The primary key values are already in use.
283 --
284 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
285 fnd_message.set_token('TABLE_NAME','hr_api_transaction_steps');
286 fnd_message.raise_error;
287 end if;
288 Close C_Sel2;
289 --
290 -- Use registered key values and clear globals
291 --
292 p_rec.transaction_step_id := hr_trs_ins.g_transaction_step_id_i;
293 hr_trs_ins.g_transaction_step_id_i := null;
294 --
295 else
296 --
297 --
298 -- Select the next sequence number
299 --
300 Open C_Sel1;
301 Fetch C_Sel1 Into p_rec.transaction_step_id;
302 Close C_Sel1;
303 End If;
304
305 if p_rec.processing_order is null then
306 p_rec.processing_order := 0;
307 end if;
308
309 --
310 hr_utility.set_location(' Leaving:'||l_proc, 10);
311 End pre_insert;
312 --
313 -- ----------------------------------------------------------------------------
314 -- |-----------------------------< post_insert >------------------------------|
315 -- ----------------------------------------------------------------------------
316 -- {Start Of Comments}
317 --
318 -- Description:
319 -- This private procedure contains any processing which is required after the
320 -- insert dml.
321 --
322 -- Pre Conditions:
323 -- This is an internal procedure which is called from the ins procedure.
324 --
325 -- In Parameters:
326 -- A Pl/Sql record structre.
327 --
328 -- Post Success:
329 -- Processing continues.
330 --
331 -- Post Failure:
332 -- If an error has occurred, an error message and exception will be raised
333 -- but not handled.
334 --
335 -- Developer Implementation Notes:
336 -- Any post-processing required after the insert dml is issued should be
337 -- coded within this procedure. It is important to note that any 3rd party
338 -- maintenance should be reviewed before placing in this procedure.
339 --
340 -- Access Status:
341 -- Internal Table Handler Use Only.
342 --
343 -- {End Of Comments}
344 -- ----------------------------------------------------------------------------
345 Procedure post_insert(p_rec in hr_trs_shd.g_rec_type) is
346 --
347 l_proc varchar2(72) := g_package||'post_insert';
348 --
349 Begin
350 hr_utility.set_location('Entering:'||l_proc, 5);
351 --
352 hr_utility.set_location(' Leaving:'||l_proc, 10);
353 End post_insert;
354 --
355 -- ----------------------------------------------------------------------------
356 -- |---------------------------------< ins >----------------------------------|
357 -- ----------------------------------------------------------------------------
358 Procedure ins
359 (
360 p_rec in out nocopy hr_trs_shd.g_rec_type,
361 p_validate in boolean default false
362 ) is
363 --
364 l_proc varchar2(72) := g_package||'ins';
365 --
366 Begin
367 hr_utility.set_location('Entering:'||l_proc, 5);
368 --
369 -- Determine if the business process is to be validated.
370 --
371 If p_validate then
372 --
373 -- Issue the savepoint.
374 --
375 SAVEPOINT ins_hr_trs;
376 End If;
377 --
378 -- Call the supporting insert validate operations
379 --
380 hr_trs_bus.insert_validate(p_rec);
381 --
382 -- Call the supporting pre-insert operation
383 --
384 pre_insert(p_rec);
385 --
386 -- Insert the row
387 --
388 insert_dml(p_rec);
389 --
390 -- Call the supporting post-insert operation
391 --
392 post_insert(p_rec);
393 --
394 -- If we are validating then raise the Validate_Enabled exception
395 --
396 If p_validate then
397 Raise HR_Api.Validate_Enabled;
398 End If;
399 --
400 hr_utility.set_location(' Leaving:'||l_proc, 10);
401 Exception
402 When HR_Api.Validate_Enabled Then
403 --
404 -- As the Validate_Enabled exception has been raised
405 -- we must rollback to the savepoint
406 --
407 ROLLBACK TO ins_hr_trs;
408 end ins;
409 --
410 -- ----------------------------------------------------------------------------
411 -- |---------------------------------< ins >----------------------------------|
412 -- ----------------------------------------------------------------------------
413 Procedure ins
414 (
415 p_transaction_step_id out nocopy number,
416 p_transaction_id in number default null,
417 p_api_name in varchar2,
418 p_api_display_name in varchar2 default null,
419 p_processing_order in number,
420 p_item_type in varchar2 default null,
421 p_item_key in varchar2 default null,
422 p_activity_id in number default null,
423 p_creator_person_id in number,
424 p_update_person_id in number default null,
425 p_object_version_number out nocopy number,
426 p_validate in boolean default false,
427 p_OBJECT_TYPE in VARCHAR2 default null,
428 p_OBJECT_NAME in VARCHAR2 default null,
429 p_OBJECT_IDENTIFIER in VARCHAR2 default null,
430 p_OBJECT_STATE in VARCHAR2 default null,
431 p_PK1 in VARCHAR2 default null,
432 p_PK2 in VARCHAR2 default null,
433 p_PK3 in VARCHAR2 default null,
434 p_PK4 in VARCHAR2 default null,
435 p_PK5 in VARCHAR2 default null,
436 p_information_category in VARCHAR2 default null,
437 p_information1 in VARCHAR2 default null,
438 p_information2 in VARCHAR2 default null,
439 p_information3 in VARCHAR2 default null,
440 p_information4 in VARCHAR2 default null,
441 p_information5 in VARCHAR2 default null,
442 p_information6 in VARCHAR2 default null,
443 p_information7 in VARCHAR2 default null,
444 p_information8 in VARCHAR2 default null,
445 p_information9 in VARCHAR2 default null,
446 p_information10 in VARCHAR2 default null,
447 p_information11 in VARCHAR2 default null,
448 p_information12 in VARCHAR2 default null,
449 p_information13 in VARCHAR2 default null,
450 p_information14 in VARCHAR2 default null,
451 p_information15 in VARCHAR2 default null,
452 p_information16 in VARCHAR2 default null,
453 p_information17 in VARCHAR2 default null,
454 p_information18 in VARCHAR2 default null,
455 p_information19 in VARCHAR2 default null,
456 p_information20 in VARCHAR2 default null,
457 p_information21 in VARCHAR2 default null,
458 p_information22 in VARCHAR2 default null,
459 p_information23 in VARCHAR2 default null,
460 p_information24 in VARCHAR2 default null,
461 p_information25 in VARCHAR2 default null,
462 p_information26 in VARCHAR2 default null,
463 p_information27 in VARCHAR2 default null,
464 p_information28 in VARCHAR2 default null,
465 p_information29 in VARCHAR2 default null,
466 p_information30 in VARCHAR2 default null
467
468
469 ) is
470 --
471 l_rec hr_trs_shd.g_rec_type;
472 l_proc varchar2(72) := g_package||'ins';
473 --
474 Begin
475 hr_utility.set_location('Entering:'||l_proc, 5);
476 --
477 -- Call conversion function to turn arguments into the
478 -- p_rec structure.
479 --
480 l_rec :=
481 hr_trs_shd.convert_args
482 (
483 null,
484 p_transaction_id,
485 p_api_name,
486 p_api_display_name,
487 p_processing_order,
488 p_item_type,
489 p_item_key,
490 p_activity_id,
491 p_creator_person_id,
492 p_update_person_id,
493 null,
494 p_object_type,
495 p_object_name,
496 p_object_identifier,
497 p_object_state,
498 p_pk1,
499 p_pk2,
500 p_pk3,
501 p_pk4,
502 p_pk5,
503 p_information_category,
504 p_information1,
505 p_information2,
506 p_information3,
507 p_information4,
508 p_information5,
509 p_information6,
510 p_information7,
511 p_information8,
512 p_information9,
513 p_information10,
514 p_information11,
515 p_information12,
516 p_information13,
517 p_information14,
518 p_information15,
519 p_information16,
520 p_information17,
521 p_information18,
522 p_information19,
523 p_information20,
524 p_information21,
525 p_information22,
526 p_information23,
527 p_information24,
528 p_information25,
529 p_information26,
530 p_information27,
531 p_information28,
532 p_information29,
533 p_information30
534
535
536 );
537 --
538 -- Having converted the arguments into the hr_trs_rec
539 -- plsql record structure we call the corresponding record business process.
540 --
541 ins(l_rec, p_validate);
542 --
543 -- As the primary key argument(s)
544 -- are specified as an OUT's we must set these values.
545 --
546 p_transaction_step_id := l_rec.transaction_step_id;
547 p_object_version_number := l_rec.object_version_number;
548 --
549 hr_utility.set_location(' Leaving:'||l_proc, 10);
550 End ins;
551 --
552 end hr_trs_ins;