1 Package Body hr_trn_ins as
2 /* $Header: hrtrnrhi.pkb 120.2 2005/09/21 04:59:16 hpandya noship $ */
3
4 --
5 -- ----------------------------------------------------------------------------
6 -- | Private Global Definitions |
7 -- ----------------------------------------------------------------------------
8 --
9 g_package varchar2(33) := ' hr_trn_ins.'; -- Global package name
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_transaction_id_i number default null;
15
16 --
17 -- ----------------------------------------------------------------------------
18 -- |------------------------< set_base_key_value >----------------------------|
19 -- ----------------------------------------------------------------------------
20 procedure set_base_key_value
21 (p_transaction_id in number) is
22 --
23 l_proc varchar2(72) := g_package||'set_base_key_value';
24 --
25 Begin
26 hr_utility.set_location('Entering:'||l_proc, 10);
27 --
28 hr_trn_ins.g_transaction_id_i := p_transaction_id;
29 --
30 hr_utility.set_location(' Leaving:'||l_proc, 20);
31 End set_base_key_value;
32
33 --
34 -- ----------------------------------------------------------------------------
35 -- |------------------------------< insert_dml >------------------------------|
36 -- ----------------------------------------------------------------------------
37 -- {Start Of Comments}
38 --
39 -- Description:
40 -- This procedure controls the actual dml insert logic. The processing of
41 -- this procedure are as follows:
42 -- 1) Initialise the object_version_number to 1 if the object_version_number
43 -- is defined as an attribute for this entity.
44 -- 2) To set and unset the g_api_dml status as required (as we are about to
45 -- perform dml).
46 -- 3) To insert the row into the schema.
47 -- 4) To trap any constraint violations that may have occurred.
48 -- 5) To raise any other errors.
49 --
50 -- Pre Conditions:
51 -- This is an internal private procedure which must be called from the ins
52 -- procedure and must have all mandatory attributes set (except the
53 -- object_version_number which is initialised within this procedure).
54 --
55 -- In Parameters:
56 -- A Pl/Sql record structre.
57 --
58 -- Post Success:
59 -- The specified row will be inserted into the schema.
60 --
61 -- Post Failure:
62 -- On the insert dml failure it is important to note that we always reset the
63 -- g_api_dml status to false.
64 -- If a check, unique or parent integrity constraint violation is raised the
65 -- constraint_error procedure will be called.
66 -- If any other error is reported, the error will be raised after the
67 -- g_api_dml status is reset.
68 --
69 -- Developer Implementation Notes:
70 -- None.
71 --
72 -- Access Status:
73 -- Internal Table Handler Use Only.
74 --
75 -- {End Of Comments}
76 -- ----------------------------------------------------------------------------
77 Procedure insert_dml(p_rec in out nocopy hr_trn_shd.g_rec_type) is
78 --
79 l_proc varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82 hr_utility.set_location('Entering:'||l_proc, 5);
83 --
84 --
85 hr_trn_shd.g_api_dml := true; -- Set the api dml status
86 --
87 -- Insert the row into: hr_api_transactions
88 --
89 insert into hr_api_transactions
90 ( transaction_id,
91 creator_person_id,
92 transaction_privilege,
93 product_code,
94 url,
95 status,
96 section_display_name,
97 function_id,
98 transaction_ref_table,
99 transaction_ref_id,
100 transaction_type,
101 assignment_id,
102 api_addtnl_info,
103 selected_person_id,
104 item_type,
105 item_key,
106 transaction_effective_date,
107 process_name,
108 plan_id ,
109 rptg_grp_id,
110 effective_date_option,
111 creator_role,
112 last_update_role,
113 parent_Transaction_id,
114 relaunch_function,
115 transaction_group,
116 transaction_identifier,
117 transaction_document
118 )
119 Values
120 ( p_rec.transaction_id,
121 p_rec.creator_person_id,
122 p_rec.transaction_privilege,
123 p_rec.product_code,
124 p_rec.url,
125 p_rec.status,
126 p_rec.section_display_name,
127 p_rec.function_id,
128 p_rec.transaction_ref_table,
129 p_rec.transaction_ref_id,
130 p_rec.transaction_type,
131 p_rec.assignment_id,
132 p_rec.api_addtnl_info,
133 p_rec.selected_person_id,
134 p_rec.item_type,
135 p_rec.item_key,
136 p_rec.transaction_effective_date,
137 p_rec.process_name,
138 p_rec.plan_id ,
139 p_rec.rptg_grp_id,
140 p_rec.effective_date_option,
141 p_rec.creator_role,
142 p_rec.last_update_role,
143 p_rec.parent_Transaction_id,
144 p_rec.relaunch_function,
145 p_rec.transaction_group,
146 p_rec.transaction_identifier,
147 p_rec.transaction_document
148 );
149 --
150 -- plan_id, rptg_grp_id, effective_date_option added by sanej
151 --
152 hr_trn_shd.g_api_dml := false; -- Unset the api dml status
153 --
154 hr_utility.set_location(' Leaving:'||l_proc, 10);
155 Exception
156 When hr_api.check_integrity_violated Then
157 -- A check constraint has been violated
158 hr_trn_shd.g_api_dml := false; -- Unset the api dml status
159 hr_trn_shd.constraint_error
160 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
161 When hr_api.parent_integrity_violated Then
162 -- Parent integrity has been violated
163 hr_trn_shd.g_api_dml := false; -- Unset the api dml status
164 hr_trn_shd.constraint_error
165 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
166 When hr_api.unique_integrity_violated Then
167 -- Unique integrity has been violated
168 hr_trn_shd.g_api_dml := false; -- Unset the api dml status
169 hr_trn_shd.constraint_error
170 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
171 When Others Then
172 hr_trn_shd.g_api_dml := false; -- Unset the api dml status
173 Raise;
174 End insert_dml;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |------------------------------< pre_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 -- This private procedure contains any processing which is required before
183 -- the insert dml. Presently, if the entity has a corresponding primary
184 -- key which is maintained by an associating sequence, the primary key for
185 -- the entity will be populated with the next sequence value in
186 -- preparation for the insert dml.
187 --
188 -- Pre Conditions:
189 -- This is an internal procedure which is called from the ins procedure.
190 --
191 -- In Parameters:
192 -- A Pl/Sql record structre.
193 --
194 -- Post Success:
195 -- Processing continues.
196 --
197 -- Post Failure:
198 -- If an error has occurred, an error message and exception will be raised
199 -- but not handled.
200 --
201 -- Developer Implementation Notes:
202 -- Any pre-processing required before the insert dml is issued should be
203 -- coded within this procedure. As stated above, a good example is the
204 -- generation of a primary key number via a corresponding sequence.
205 -- It is important to note that any 3rd party maintenance should be reviewed
206 -- before placing in this procedure.
207 --
208 -- Access Status:
209 -- Internal Table Handler Use Only.
210 --
211 -- {End Of Comments}
212 -- ----------------------------------------------------------------------------
213 Procedure pre_insert(p_rec in out nocopy hr_trn_shd.g_rec_type) is
214 --
215 l_proc varchar2(72) := g_package||'pre_insert';
216 l_exists varchar2(1);
217 --
218 Cursor C_Sel1 is select hr_api_transactions_s.nextval from sys.dual;
219
220 Cursor C_Sel2 is
221 select null
222 from hr_api_transactions
223 where transaction_id = hr_trn_ins.g_transaction_id_i;
224 --
225 Begin
226 hr_utility.set_location('Entering:'||l_proc, 5);
227
228 If hr_trn_ins.g_transaction_id_i is not null then
229 --
230 -- Verify registered primary key values not already in use
231 --
232 Open C_Sel2;
233 Fetch C_Sel2 into l_exists;
234 If C_Sel2%found then
235 Close C_Sel2;
236 --
237 -- The primary key values are already in use.
238 --
239 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
240 fnd_message.set_token('TABLE_NAME','hr_questionnaires');
241 fnd_message.raise_error;
242 end if;
243 Close C_Sel2;
244 --
245 -- Use registered key values and clear globals
246 --
247 p_rec.transaction_id := hr_trn_ins.g_transaction_id_i;
248 hr_trn_ins.g_transaction_id_i := null;
249 --
250 else
251 --
252 --
253 -- Select the next sequence number
254 --
255 Open C_Sel1;
256 Fetch C_Sel1 Into p_rec.transaction_id;
257 Close C_Sel1;
258 --
259 End If;
260 If p_rec.transaction_ref_id is null Then
261 p_rec.transaction_ref_id := p_rec.transaction_id;
262 End If;
263
264 hr_utility.set_location(' Leaving:'||l_proc, 10);
265 End pre_insert;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |-----------------------------< post_insert >------------------------------|
269 -- ----------------------------------------------------------------------------
270 -- {Start Of Comments}
271 --
272 -- Description:
273 -- This private procedure contains any processing which is required after the
274 -- insert dml.
275 --
276 -- Pre Conditions:
277 -- This is an internal procedure which is called from the ins procedure.
278 --
279 -- In Parameters:
280 -- A Pl/Sql record structre.
281 --
282 -- Post Success:
283 -- Processing continues.
284 --
285 -- Post Failure:
286 -- If an error has occurred, an error message and exception will be raised
287 -- but not handled.
288 --
289 -- Developer Implementation Notes:
290 -- Any post-processing required after the insert dml is issued should be
291 -- coded within this procedure. It is important to note that any 3rd party
292 -- maintenance should be reviewed before placing in this procedure.
293 --
294 -- Access Status:
295 -- Internal Table Handler Use Only.
296 --
297 -- {End Of Comments}
298 -- ----------------------------------------------------------------------------
299 Procedure post_insert(p_rec in hr_trn_shd.g_rec_type) is
300 --
301 l_proc varchar2(72) := g_package||'post_insert';
302 --
303 Begin
304 hr_utility.set_location('Entering:'||l_proc, 5);
305 --
306 hr_utility.set_location(' Leaving:'||l_proc, 10);
307 End post_insert;
308 --
309 -- ----------------------------------------------------------------------------
310 -- |---------------------------------< ins >----------------------------------|
311 -- ----------------------------------------------------------------------------
312 Procedure ins
313 (
314 p_rec in out nocopy hr_trn_shd.g_rec_type,
315 p_validate in boolean default false
316 ) is
317 --
318 l_proc varchar2(72) := g_package||'ins';
319 --
320 Begin
321 hr_utility.set_location('Entering:'||l_proc, 5);
322 --
323 -- Determine if the business process is to be validated.
324 --
325 If p_validate then
326 --
327 -- Issue the savepoint.
328 --
329 SAVEPOINT ins_hr_trn;
330 End If;
331 --
332 -- Call the supporting insert validate operations
333 --
334 hr_trn_bus.insert_validate(p_rec);
335 --
336 -- Call the supporting pre-insert operation
337 --
338 pre_insert(p_rec);
339 --
340 -- Insert the row
341 --
342 insert_dml(p_rec);
343 --
344 -- Call the supporting post-insert operation
345 --
346 post_insert(p_rec);
347 --
348 -- If we are validating then raise the Validate_Enabled exception
349 --
350 If p_validate then
351 Raise HR_Api.Validate_Enabled;
352 End If;
353 --
354 hr_utility.set_location(' Leaving:'||l_proc, 10);
355 Exception
356 When HR_Api.Validate_Enabled Then
357 --
358 -- As the Validate_Enabled exception has been raised
359 -- we must rollback to the savepoint
360 --
361 ROLLBACK TO ins_hr_trn;
362 end ins;
363 --
364 -- ----------------------------------------------------------------------------
365 -- |---------------------------------< ins >----------------------------------|
366 -- ----------------------------------------------------------------------------
367 Procedure ins
368 (
369 p_transaction_id out nocopy number,
370 p_creator_person_id in number,
371 p_transaction_privilege in varchar2,
372 p_validate in boolean default false
373 ) is
374 --
375 l_rec hr_trn_shd.g_rec_type;
376 l_proc varchar2(72) := g_package||'ins';
377 --
378 Begin
379 hr_utility.set_location('Entering:'||l_proc, 5);
380 --
381 -- Call conversion function to turn arguments into the
382 -- p_rec structure.
383 --
384 /*
385 l_rec :=
386 hr_trn_shd.convert_args
387 (
388 null,
389 p_creator_person_id,
390 p_transaction_privilege
391 );
392 --
393 -- Having converted the arguments into the hr_trn_rec
394 -- plsql record structure we call the corresponding record business process.
395 --
396 ins(l_rec, p_validate);
397 --
398 -- As the primary key argument(s)
399 -- are specified as an OUT's we must set these values.
400 --
401 p_transaction_id := l_rec.transaction_id;
402 */
403 --
404 --
405 ins(
406 p_transaction_id => p_transaction_id,
407 p_creator_person_id => p_creator_person_id,
408 p_transaction_privilege => p_transaction_privilege,
409 p_product_code => -1,
410 p_url => null,
411 p_status =>null,
412 p_section_display_name => null,
413 p_function_id => null,
414 p_transaction_ref_table => null,
415 p_transaction_ref_id => null,
416 p_transaction_type => null,
417 p_assignment_id => null,
418 p_api_addtnl_info => null,
419 p_selected_person_id => null,
420 p_item_type => null,
421 p_item_key => null,
422 p_transaction_effective_date => null,
423 p_process_name => null,
424 p_plan_id => null,
425 p_rptg_grp_id => null,
426 p_effective_date_option => null,
427 p_validate => p_validate,
428 p_relaunch_function => null,
429 p_transaction_group => null,
430 p_transaction_identifier => null,
431 p_transaction_document => null
432
433 );
434 --
435 -- p_plan_id, p_rptg_grp_id, p_effective_date_option added by sanej
436
437 hr_utility.set_location(' Leaving:'||l_proc, 10);
438 End ins;
439 --
440 -- Overloaded ins procedure
441 Procedure ins
442 (
443 p_transaction_id out nocopy number,
444 p_creator_person_id in number,
445 p_transaction_privilege in varchar2,
446 p_product_code in varchar2 default null,
447 p_url in varchar2 default null,
448 p_status in varchar2 default null,
449 p_section_display_name in varchar2 default null,
450 p_function_id in number,
451 p_transaction_ref_table in varchar2 default null,
452 p_transaction_ref_id in number default null,
453 p_transaction_type in varchar2 default null,
454 p_assignment_id in number default null,
455 p_api_addtnl_info in varchar2 default null,
456 p_selected_person_id in number default null,
457 p_item_type in varchar2 default null,
458 p_item_key in varchar2 default null,
459 p_transaction_effective_date in date default null,
460 p_process_name in varchar2 default null,
461 p_plan_id in number default null,
462 p_rptg_grp_id in number default null,
463 p_effective_date_option in varchar2 default null,
464 p_validate in boolean default false,
465 p_creator_role in varchar2 default null,
466 p_last_update_role in varchar2 default null,
467 p_parent_transaction_id in number default null,
468 p_relaunch_function in varchar2 default null,
469 p_transaction_group in varchar2 default null,
470 p_transaction_identifier in varchar2 default null,
471 p_transaction_document in CLOB default null
472 ) is
473 --
474 -- p_plan_id, p_rptg_grp_id, p_effective_date_option added by sanej
475 --
476 l_rec hr_trn_shd.g_rec_type;
477 l_proc varchar2(72) := g_package||'ins';
478 Begin
479 hr_utility.set_location('Entering:'||l_proc, 5);
480 --
481 -- Call conversion function to turn arguments into the
482 -- p_rec structure.
483 --
484 l_rec :=
485 hr_trn_shd.convert_args
486 (
487 null,
488 p_creator_person_id,
489 p_transaction_privilege,
490 p_product_code,
491 p_url,
492 p_status,
493 null, --ns for transaction_state
494 p_section_display_name,
495 p_function_id,
496 p_transaction_ref_table,
497 p_transaction_ref_id,
498 p_transaction_type,
499 p_assignment_id,
500 p_api_addtnl_info,
501 p_selected_person_id,
502 p_item_type,
503 p_item_key,
504 p_transaction_effective_date,
505 p_process_name,
506 p_plan_id,
507 p_rptg_grp_id,
508 p_effective_date_option,
509 p_creator_role,
510 p_last_update_role,
511 p_parent_transaction_id,
512 p_relaunch_function,
513 p_transaction_group,
514 p_transaction_identifier,
515 p_transaction_document
516 );
517 --
518 -- p_plan_id, p_rptg_grp_id, p_effective_date_option added by sanej
519 --
520 -- Having converted the arguments into the hr_trn_rec
521 -- plsql record structure we call the corresponding record business process.
522 --
523 ins(l_rec, p_validate);
524 --
525 -- As the primary key argument(s)
526 -- are specified as an OUT's we must set these values.
527 --
528 p_transaction_id := l_rec.transaction_id;
529 --
530 --
531 hr_utility.set_location(' Leaving:'||l_proc, 10);
532 End ins;
533
534 end hr_trn_ins;