1 PACKAGE BODY ota_tav_ins as
2 /* $Header: ottav01t.pkb 120.2.12010000.2 2008/12/19 09:26:32 shwnayak ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_tav_ins.'; -- Global package name
9 g_activity_version_id_i number default null;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------< set_base_key_value >----------------------------|
13 -- ----------------------------------------------------------------------------
14 procedure set_base_key_value
15 (p_activity_version_id in number) is
16 --
17 l_proc varchar2(72) := g_package||'set_base_key_value';
18 --
19 Begin
20 hr_utility.set_location('Entering:'||l_proc, 10);
21 --
22 ota_tav_ins.g_activity_version_id_i := p_activity_version_id;
23 --
24 hr_utility.set_location(' Leaving:'||l_proc, 20);
25 End set_base_key_value;
26 -- ----------------------------------------------------------------------------
27 -- |------------------------------< insert_dml >------------------------------|
28 -- ----------------------------------------------------------------------------
29 -- {Start Of Comments}
30 --
31 -- Description:
32 -- This procedure controls the actual dml insert logic. The functions of this
33 -- procedure are as follows:
34 -- 1) Initialise the object_version_number to 1 if the object_version_number
35 -- is defined as an attribute for this entity.
36 -- 2) To set and unset the g_api_dml status as required (as we are about to
37 -- perform dml).
38 -- 3) To insert the row into the schema.
39 -- 4) To trap any constraint violations that may have occurred.
40 -- 5) To raise any other errors.
41 --
42 -- Pre Conditions:
43 -- This is an internal private procedure which must be called from the ins
44 -- procedure and must have all mandatory arguments set (except the
45 -- object_version_number which is initialised within this procedure).
46 --
47 -- In Arguments:
48 -- A Pl/Sql record structre.
49 --
50 -- Post Success:
51 -- The specified row will be inserted into the schema.
52 --
53 -- Post Failure:
54 -- On the insert dml failure it is important to note that we always reset the
55 -- g_api_dml status to false.
56 -- If a check, unique or parent integrity constraint violation is raised the
57 -- constraint_error procedure will be called.
58 -- If any other error is reported, the error will be raised after the
59 -- g_api_dml status is reset.
60 --
61 -- Developer Implementation Notes:
62 -- None.
63 --
64 -- Access Status:
65 -- Internal Development Use Only.
66 --
67 -- {End Of Comments}
68 -- ----------------------------------------------------------------------------
69 Procedure insert_dml(p_rec in out nocopy ota_tav_shd.g_rec_type) is
70 --
71 l_proc varchar2(72) := g_package||'insert_dml';
72 --
73 Begin
74 hr_utility.set_location('Entering:'||l_proc, 5);
75 p_rec.object_version_number := 1; -- Initialise the object version
76 --
77 ota_tav_shd.g_api_dml := true; -- Set the api dml status
78 --
79 -- Insert the row into: ota_activity_versions
80 --
81 insert into ota_activity_versions
82 ( activity_version_id,
83 activity_id,
84 superseded_by_act_version_id,
85 developer_organization_id,
86 controlling_person_id,
87 object_version_number,
88 version_name,
89 comments,
90 description,
91 duration,
92 duration_units,
93 end_date,
94 intended_audience,
95 language_id,
96 maximum_attendees,
97 minimum_attendees,
98 objectives,
99 start_date,
100 success_criteria,
101 user_status,
102 vendor_id,
103 actual_cost,
104 budget_cost,
105 budget_currency_code,
106 expenses_allowed,
107 professional_credit_type,
108 professional_credits,
109 maximum_internal_attendees,
110 tav_information_category,
111 tav_information1,
112 tav_information2,
113 tav_information3,
114 tav_information4,
115 tav_information5,
116 tav_information6,
117 tav_information7,
118 tav_information8,
119 tav_information9,
120 tav_information10,
121 tav_information11,
122 tav_information12,
123 tav_information13,
124 tav_information14,
125 tav_information15,
126 tav_information16,
127 tav_information17,
128 tav_information18,
129 tav_information19,
130 tav_information20,
131 inventory_item_id,
132 organization_id,
133 rco_id,
134 version_code,
135 business_group_id,
136 data_source,
137 competency_update_level
138
139 )
140 Values
141 ( p_rec.activity_version_id,
142 p_rec.activity_id,
143 p_rec.superseded_by_act_version_id,
144 p_rec.developer_organization_id,
145 p_rec.controlling_person_id,
146 p_rec.object_version_number,
147 p_rec.version_name,
148 p_rec.comments,
149 p_rec.description,
150 p_rec.duration,
151 p_rec.duration_units,
152 p_rec.end_date,
153 p_rec.intended_audience,
154 p_rec.language_id,
155 p_rec.maximum_attendees,
156 p_rec.minimum_attendees,
157 p_rec.objectives,
158 p_rec.start_date,
159 p_rec.success_criteria,
160 p_rec.user_status,
161 p_rec.vendor_id,
162 p_rec.actual_cost,
163 p_rec.budget_cost,
164 p_rec.budget_currency_code,
165 p_rec.expenses_allowed,
166 p_rec.professional_credit_type,
167 p_rec.professional_credits,
168 p_rec.maximum_internal_attendees,
169 p_rec.tav_information_category,
170 p_rec.tav_information1,
171 p_rec.tav_information2,
172 p_rec.tav_information3,
173 p_rec.tav_information4,
174 p_rec.tav_information5,
175 p_rec.tav_information6,
176 p_rec.tav_information7,
177 p_rec.tav_information8,
178 p_rec.tav_information9,
179 p_rec.tav_information10,
180 p_rec.tav_information11,
181 p_rec.tav_information12,
182 p_rec.tav_information13,
183 p_rec.tav_information14,
184 p_rec.tav_information15,
185 p_rec.tav_information16,
186 p_rec.tav_information17,
187 p_rec.tav_information18,
188 p_rec.tav_information19,
189 p_rec.tav_information20,
190 p_rec.inventory_item_id,
191 p_rec.organization_id,
192 p_rec.rco_id,
193 p_rec.version_code,
194 p_rec.business_group_id,
195 p_rec.data_source ,
196 p_rec.competency_update_level
197 );
198 --
199 ota_tav_shd.g_api_dml := false; -- Unset the api dml status
200 --
201 hr_utility.set_location(' Leaving:'||l_proc, 10);
202 Exception
203 When hr_api.check_integrity_violated Then
204 -- A check constraint has been violated
205 ota_tav_shd.g_api_dml := false; -- Unset the api dml status
206 ota_tav_shd.constraint_error
207 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
208 When hr_api.parent_integrity_violated Then
209 -- Parent integrity has been violated
210 ota_tav_shd.g_api_dml := false; -- Unset the api dml status
211 ota_tav_shd.constraint_error
212 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
213 When hr_api.unique_integrity_violated Then
214 -- Unique integrity has been violated
215 ota_tav_shd.g_api_dml := false; -- Unset the api dml status
216 ota_tav_shd.constraint_error
217 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
218 When Others Then
219 ota_tav_shd.g_api_dml := false; -- Unset the api dml status
220 Raise;
221 End insert_dml;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |------------------------------< pre_insert >------------------------------|
225 -- ----------------------------------------------------------------------------
226 -- {Start Of Comments}
227 --
228 -- Description:
229 -- This private procedure contains any processing which is required before
230 -- the insert dml. Presently, if the entity has a corresponding primary
231 -- key which is maintained by an associating sequence, the primary key for
232 -- the entity will be populated with the next sequence value in
233 -- preparation for the insert dml.
234 --
235 -- Pre Conditions:
236 -- This is an internal procedure which is called from the ins procedure.
237 --
238 -- In Arguments:
239 -- A Pl/Sql record structre.
240 --
241 -- Post Success:
242 -- Processing continues.
243 --
244 -- Post Failure:
245 -- If an error has occurred, an error message and exception will be raised
246 -- but not handled.
247 --
248 -- Developer Implementation Notes:
249 -- Any pre-processing required before the insert dml is issued should be
250 -- coded within this procedure. As stated above, a good example is the
251 -- generation of a primary key number via a corresponding sequence.
252 -- It is important to note that any 3rd party maintenance should be reviewed
253 -- before placing in this procedure.
254 --
255 -- Access Status:
256 -- Internal Development Use Only.
257 --
258 -- {End Of Comments}
259 -- ----------------------------------------------------------------------------
260 Procedure pre_insert(p_rec in out nocopy ota_tav_shd.g_rec_type) is
261 --
262 l_proc varchar2(72) := g_package||'pre_insert';
263 --
264 Cursor C_Sel1 is select ota_activity_versions_s.nextval from sys.dual;
265 --
266 --
267 Cursor C_Sel2 is
268 Select null
269 from ota_activity_versions
270 where activity_version_id =
271 ota_tav_ins.g_activity_version_id_i;
272 --
273 l_exists varchar2(1);
274 Begin
275 hr_utility.set_location('Entering:'||l_proc, 5);
276 If (ota_tav_ins.g_activity_version_id_i is not null) Then
277 --
278 -- Verify registered primary key values not already in use
279 --
280 Open C_Sel2;
281 Fetch C_Sel2 into l_exists;
282 If C_Sel2%found Then
283 Close C_Sel2;
284 --
285 -- The primary key values are already in use.
286 --
287 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
288 fnd_message.set_token('TABLE_NAME','irc_documents');
289 fnd_message.raise_error;
290 End If;
291 Close C_Sel2;
292 --
293 -- Use registered key values and clear globals
294 --
295 p_rec.activity_version_id :=
296 ota_tav_ins.g_activity_version_id_i;
297 ota_tav_ins.g_activity_version_id_i := null;
298 Else
299 --
300 -- No registerd key values, so select the next sequence number
301 --
302 --
303 --
304 -- Select the next sequence number
305 --
306 Open C_Sel1;
307 Fetch C_Sel1 Into p_rec.activity_version_id;
308 Close C_Sel1;
309 --
310
311 END IF;
312
313 hr_utility.set_location(' Leaving:'||l_proc, 10);
314 End pre_insert;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |-----------------------------< post_insert >------------------------------|
318 -- ----------------------------------------------------------------------------
319 -- {Start Of Comments}
320 --
321 -- Description:
322 -- This private procedure contains any processing which is required after the
323 -- insert dml.
324 --
325 -- Pre Conditions:
326 -- This is an internal procedure which is called from the ins procedure.
327 --
328 -- In Arguments:
329 -- A Pl/Sql record structre.
330 --
331 -- Post Success:
332 -- Processing continues.
333 --
334 -- Post Failure:
335 -- If an error has occurred, an error message and exception will be raised
336 -- but not handled.
337 --
338 -- Developer Implementation Notes:
339 -- Any post-processing required after the insert dml is issued should be
340 -- coded within this procedure. It is important to note that any 3rd party
341 -- maintenance should be reviewed before placing in this procedure.
342 --
343 -- Access Status:
344 -- Internal Development Use Only.
345 --
346 -- {End Of Comments}
347 -- ----------------------------------------------------------------------------
348 Procedure post_insert(p_rec in ota_tav_shd.g_rec_type) is
349 --
350 l_proc varchar2(72) := g_package||'post_insert';
351 --
352 Begin
353 hr_utility.set_location('Entering:'||l_proc, 5);
354 ota_tav_api_business_rules.set_superseding_version
355 (p_rec.activity_id
356 ,p_rec.activity_version_id
357 ,p_rec.start_date);
358 hr_utility.set_location(' Leaving:'||l_proc, 10);
359 End post_insert;
360 --
361 -- ----------------------------------------------------------------------------
362 -- |---------------------------------< ins >----------------------------------|
363 -- ----------------------------------------------------------------------------
364 Procedure ins
365 (
366 p_rec in out nocopy ota_tav_shd.g_rec_type,
367 p_validate in boolean
368 ) is
369 --
370 l_proc varchar2(72) := g_package||'ins';
371 --
372 Begin
373 hr_utility.set_location('Entering:'||l_proc, 5);
374 --
375 -- Determine if the business process is to be validated.
376 --
377 If p_validate then
378 --
379 -- Issue the savepoint.
380 --
381 SAVEPOINT ins_ota_tav;
382 End If;
383 --
384 -- Call the supporting insert validate operations
385 --
386 ota_tav_bus.insert_validate(p_rec);
387 --
388 -- Call to raise any errors on multi-message list
389 hr_multi_message.end_validation_set;
390 --
391 -- Call the supporting pre-insert operation
392 --
393 pre_insert(p_rec);
394 --
395 -- Insert the row
396 --
397 insert_dml(p_rec);
398 --
399 -- Call the supporting post-insert operation
400 --
401 post_insert(p_rec);
402 --
403 -- Call to raise any errors on multi-message list
404 hr_multi_message.end_validation_set;
405 --
406 -- If we are validating then raise the Validate_Enabled exception
407 --
408 If p_validate then
409 Raise HR_Api.Validate_Enabled;
410 End If;
411 --
412 hr_utility.set_location(' Leaving:'||l_proc, 10);
413 Exception
414 When HR_Api.Validate_Enabled Then
415 --
416 -- As the Validate_Enabled exception has been raised
417 -- we must rollback to the savepoint
418 --
419 ROLLBACK TO ins_ota_tav;
420 end ins;
421 --
422 -- ----------------------------------------------------------------------------
423 -- |---------------------------------< ins >----------------------------------|
424 -- ----------------------------------------------------------------------------
425 Procedure ins
426 (
427 p_activity_version_id out nocopy number,
428 p_activity_id in number,
429 p_superseded_by_act_version_id in number ,
430 p_developer_organization_id in number,
431 p_controlling_person_id in number ,
432 p_object_version_number out nocopy number,
433 p_version_name in varchar2,
434 p_comments in varchar2 ,
435 p_description in varchar2 ,
436 p_duration in number ,
437 p_duration_units in varchar2 ,
438 p_end_date in date ,
439 p_intended_audience in varchar2 ,
440 p_language_id in number ,
441 p_maximum_attendees in number ,
442 p_minimum_attendees in number ,
443 p_objectives in varchar2 ,
444 p_start_date in date ,
445 p_success_criteria in varchar2 ,
446 p_user_status in varchar2 ,
447 p_vendor_id in number ,
448 p_actual_cost in number ,
449 p_budget_cost in number ,
450 p_budget_currency_code in varchar2 ,
451 p_expenses_allowed in varchar2 ,
452 p_professional_credit_type in varchar2 ,
453 p_professional_credits in number ,
454 p_maximum_internal_attendees in number ,
455 p_tav_information_category in varchar2 ,
456 p_tav_information1 in varchar2 ,
457 p_tav_information2 in varchar2 ,
458 p_tav_information3 in varchar2 ,
459 p_tav_information4 in varchar2 ,
460 p_tav_information5 in varchar2 ,
461 p_tav_information6 in varchar2 ,
462 p_tav_information7 in varchar2 ,
463 p_tav_information8 in varchar2 ,
464 p_tav_information9 in varchar2 ,
465 p_tav_information10 in varchar2 ,
466 p_tav_information11 in varchar2 ,
467 p_tav_information12 in varchar2 ,
468 p_tav_information13 in varchar2 ,
469 p_tav_information14 in varchar2 ,
470 p_tav_information15 in varchar2 ,
471 p_tav_information16 in varchar2 ,
472 p_tav_information17 in varchar2 ,
473 p_tav_information18 in varchar2 ,
474 p_tav_information19 in varchar2 ,
475 p_tav_information20 in varchar2 ,
476 p_inventory_item_id in number ,
477 p_organization_id in number ,
478 p_rco_id in number ,
479 p_version_code in varchar2,
480 p_business_group_id in number,
481 p_validate in boolean,
482 p_data_source in varchar2
483 ,p_competency_update_level in varchar2
484
485 ) is
486 --
487 l_rec ota_tav_shd.g_rec_type;
488 l_proc varchar2(72) := g_package||'ins';
489 --
490 Begin
491 hr_utility.set_location('Entering:'||l_proc, 5);
492 --
493 -- Call conversion function to turn arguments into the
494 -- p_rec structure.
495 --
496 l_rec :=
497 ota_tav_shd.convert_args
498 (
499 null,
500 p_activity_id,
501 p_superseded_by_act_version_id,
502 p_developer_organization_id,
503 p_controlling_person_id,
504 null,
505 p_version_name,
506 p_comments,
507 p_description,
508 p_duration,
509 p_duration_units,
510 p_end_date,
511 p_intended_audience,
512 p_language_id,
513 p_maximum_attendees,
514 p_minimum_attendees,
515 p_objectives,
516 p_start_date,
517 p_success_criteria,
518 p_user_status,
519 p_vendor_id,
520 p_actual_cost,
521 p_budget_cost,
522 p_budget_currency_code,
523 p_expenses_allowed,
524 p_professional_credit_type,
525 p_professional_credits,
526 p_maximum_internal_attendees,
527 p_tav_information_category,
528 p_tav_information1,
529 p_tav_information2,
530 p_tav_information3,
531 p_tav_information4,
532 p_tav_information5,
533 p_tav_information6,
534 p_tav_information7,
535 p_tav_information8,
536 p_tav_information9,
537 p_tav_information10,
538 p_tav_information11,
539 p_tav_information12,
540 p_tav_information13,
541 p_tav_information14,
542 p_tav_information15,
543 p_tav_information16,
544 p_tav_information17,
545 p_tav_information18,
546 p_tav_information19,
547 p_tav_information20,
548 p_inventory_item_id,
549 p_organization_id,
550 p_rco_id,
551 p_version_code,
552 p_business_group_id,
553 p_data_source
554 ,p_competency_update_level
555
556 );
557 --
558 -- Having converted the arguments into the ota_tav_rec
559 -- plsql record structure we call the corresponding record business process.
560 --
561 ins(l_rec, p_validate);
562 --
563 -- As the primary key argument(s)
564 -- are specified as an OUT's we must set these values.
565 --
566 p_activity_version_id:=l_rec.activity_version_id;
567 p_object_version_number:=l_rec.object_version_number;
568 --
569 hr_utility.set_location(' Leaving:'||l_proc, 10);
570 End ins;
571 --
572 end ota_tav_ins;