DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FOI_INS

Source


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