DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_TAV_INS

Source


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