DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FNS_INS

Source


1 Package Body ota_fns_ins as
2 /* $Header: otfnsrhi.pkb 120.1 2005/07/18 05:29 aabalakr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_fns_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_person_id_i  number   default null;
15 g_contact_id_i  number   default null;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |------------------------< set_base_key_value >----------------------------|
19 -- ----------------------------------------------------------------------------
20 procedure set_base_key_value
21   (p_forum_id  in  number
22   ,p_person_id  in  number
23   ,p_contact_id  in  number) 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_fns_ins.g_forum_id_i := p_forum_id;
31   ota_fns_ins.g_person_id_i := p_person_id;
32   ota_fns_ins.g_contact_id_i := p_contact_id;
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_fns_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   ota_fns_shd.g_api_dml := true;  -- Set the api dml status
92   --
93   -- Insert the row into: ota_frm_notif_subscribers
94   --
95   insert into ota_frm_notif_subscribers
96       (forum_id
97       ,business_group_id
98       ,object_version_number
99       ,person_id
100       ,contact_id
101       )
102   Values
103     (p_rec.forum_id
104     ,p_rec.business_group_id
105     ,p_rec.object_version_number
106     ,p_rec.person_id
107     ,p_rec.contact_id
108     );
109   --
110   ota_fns_shd.g_api_dml := false;   -- Unset the api dml status
111   --
112   hr_utility.set_location(' Leaving:'||l_proc, 10);
113 Exception
114   When hr_api.check_integrity_violated Then
115     -- A check constraint has been violated
116     ota_fns_shd.g_api_dml := false;   -- Unset the api dml status
117     ota_fns_shd.constraint_error
118       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
119   When hr_api.parent_integrity_violated Then
120     -- Parent integrity has been violated
121     ota_fns_shd.g_api_dml := false;   -- Unset the api dml status
122     ota_fns_shd.constraint_error
123       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
124   When hr_api.unique_integrity_violated Then
125     -- Unique integrity has been violated
126     ota_fns_shd.g_api_dml := false;   -- Unset the api dml status
127     ota_fns_shd.constraint_error
128       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
129   When Others Then
130     ota_fns_shd.g_api_dml := false;   -- Unset the api dml status
131     Raise;
132 End insert_dml;
133 --
134 -- ----------------------------------------------------------------------------
135 -- |------------------------------< pre_insert >------------------------------|
136 -- ----------------------------------------------------------------------------
137 -- {Start Of Comments}
138 --
139 -- Description:
140 --   This private procedure contains any processing which is required before
141 --   the insert dml. Presently, if the entity has a corresponding primary
142 --   key which is maintained by an associating sequence, the primary key for
143 --   the entity will be populated with the next sequence value in
144 --   preparation for the insert dml.
145 --
146 -- Prerequisites:
147 --   This is an internal procedure which is called from the ins procedure.
148 --
149 -- In Parameters:
150 --   A Pl/Sql record structure.
151 --
152 -- Post Success:
153 --   Processing continues.
154 --
155 -- Post Failure:
156 --   If an error has occurred, an error message and exception will be raised
157 --   but not handled.
158 --
159 -- Developer Implementation Notes:
160 --   Any pre-processing required before the insert dml is issued should be
161 --   coded within this procedure. As stated above, a good example is the
162 --   generation of a primary key number via a corresponding sequence.
163 --   It is important to note that any 3rd party maintenance should be reviewed
164 --   before placing in this procedure.
165 --
166 -- Access Status:
167 --   Internal Row Handler Use Only.
168 --
169 -- {End Of Comments}
170 -- ----------------------------------------------------------------------------
171 Procedure pre_insert
172   (p_rec  in out nocopy ota_fns_shd.g_rec_type
173   ) is
174 --
175   /*Cursor C_Sel1 is select ota_frm_notif_subscribers_s.nextval from sys.dual;
176 --
177   Cursor C_Sel2 is
178     Select null
179       from ota_frm_notif_subscribers
180      where forum_id =
181              ota_fns_ins.g_forum_id_i
182         or person_id =
183              ota_fns_ins.g_person_id_i
184         or contact_id =
185              ota_fns_ins.g_contact_id_i;
186 */
187 --
188   l_proc   varchar2(72) := g_package||'pre_insert';
189   l_exists varchar2(1);
190 --
191 Begin
192   hr_utility.set_location('Entering:'||l_proc, 5);
193   --
194   /*
195   If (ota_fns_ins.g_forum_id_i is not null or
196       ota_fns_ins.g_person_id_i is not null or
197       ota_fns_ins.g_contact_id_i is not null) Then
198     --
199     -- Verify registered primary key values not already in use
200     --
201     Open C_Sel2;
202     Fetch C_Sel2 into l_exists;
203     If C_Sel2%found Then
204        Close C_Sel2;
205        --
206        -- The primary key values are already in use.
207        --
208        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
209        fnd_message.set_token('TABLE_NAME','ota_frm_notif_subscribers');
210        fnd_message.raise_error;
211     End If;
212     Close C_Sel2;
213     --
214     -- Use registered key values and clear globals
215     --
216     p_rec.forum_id :=
217       ota_fns_ins.g_forum_id_i;
218     ota_fns_ins.g_forum_id_i := null;
219     p_rec.person_id :=
220       ota_fns_ins.g_person_id_i;
221     ota_fns_ins.g_person_id_i := null;
222     p_rec.contact_id :=
223       ota_fns_ins.g_contact_id_i;
224     ota_fns_ins.g_contact_id_i := null;
225   Else
226     --
227     -- No registerd key values, so select the next sequence number
228     --
229     --
230     -- Select the next sequence number
231     --
232     Open C_Sel1;
233     Fetch C_Sel1 Into p_rec.contact_id;
234     Close C_Sel1;
235   End If;
236   */
237   --
238   hr_utility.set_location(' Leaving:'||l_proc, 10);
239 End pre_insert;
240 --
241 -- ----------------------------------------------------------------------------
242 -- |-----------------------------< post_insert >------------------------------|
243 -- ----------------------------------------------------------------------------
244 -- {Start Of Comments}
245 --
246 -- Description:
247 --   This private procedure contains any processing which is required after
248 --   the insert dml.
249 --
250 -- Prerequisites:
251 --   This is an internal procedure which is called from the ins procedure.
252 --
253 -- In Parameters:
254 --   A Pl/Sql record structre.
255 --
256 -- Post Success:
257 --   Processing continues.
258 --
259 -- Post Failure:
260 --   If an error has occurred, an error message and exception will be raised
261 --   but not handled.
262 --
263 -- Developer Implementation Notes:
264 --   Any post-processing required after the insert dml is issued should be
265 --   coded within this procedure. It is important to note that any 3rd party
266 --   maintenance should be reviewed before placing in this procedure.
267 --
268 -- Access Status:
269 --   Internal Row Handler Use Only.
270 --
271 -- {End Of Comments}
272 -- ----------------------------------------------------------------------------
273 Procedure post_insert
274   (p_effective_date               in date
275   ,p_rec                          in ota_fns_shd.g_rec_type
276   ) is
277 --
278   l_proc  varchar2(72) := g_package||'post_insert';
279 --
280 Begin
281   hr_utility.set_location('Entering:'||l_proc, 5);
282   begin
283     --
284     ota_fns_rki.after_insert
285       (p_effective_date              => p_effective_date
286       ,p_forum_id
287       => p_rec.forum_id
288       ,p_business_group_id
289       => p_rec.business_group_id
290       ,p_object_version_number
291       => p_rec.object_version_number
292       ,p_person_id
293       => p_rec.person_id
294       ,p_contact_id
295       => p_rec.contact_id
296       );
297     --
298   exception
299     --
300     when hr_api.cannot_find_prog_unit then
301       --
302       hr_api.cannot_find_prog_unit_error
303         (p_module_name => 'OTA_FRM_NOTIF_SUBSCRIBERS'
304         ,p_hook_type   => 'AI');
305       --
306   end;
307   --
308   hr_utility.set_location(' Leaving:'||l_proc, 10);
309 End post_insert;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |---------------------------------< ins >----------------------------------|
313 -- ----------------------------------------------------------------------------
314 Procedure ins
315   (p_effective_date               in date
316   ,p_rec                          in out nocopy ota_fns_shd.g_rec_type
317   ) is
318 --
319   l_proc  varchar2(72) := g_package||'ins';
320   l_forum_id ota_frm_notif_subscribers.forum_id%TYPE;
321   l_person_id ota_frm_notif_subscribers.person_id%TYPE;
322   l_contact_id ota_frm_notif_subscribers.contact_id%TYPE;
323 
324 --
325 Begin
326   hr_utility.set_location('Entering:'||l_proc, 5);
327     	l_forum_id := p_rec.forum_id;
328       	l_person_id := p_rec.person_id;
329       	l_contact_id := p_rec.contact_id;
330 
331   --
332       /*p_rec.forum_id := null;
333       p_rec.person_id := null;
334       p_rec.contact_id := null;*/
335 
336     ota_fns_ins.set_base_key_value(  p_forum_id  => l_forum_id
337                                      ,p_person_id => l_person_id
338                                      ,p_contact_id       => l_contact_id
339                                      );
340 
341   -- Call the supporting insert validate operations
342   --
343   ota_fns_bus.insert_validate
344      (p_effective_date
345      ,p_rec
346      ,l_forum_id
347      ,l_person_id
348      ,l_contact_id
349      );
350   --
351   -- Call to raise any errors on multi-message list
352   hr_multi_message.end_validation_set;
353   --
354   -- Call the supporting pre-insert operation
355   --
356   ota_fns_ins.pre_insert(p_rec);
357   --
358   -- Insert the row
359   --
360   ota_fns_ins.insert_dml(p_rec);
361   --
362   -- Call the supporting post-insert operation
363   --
364   ota_fns_ins.post_insert
365      (p_effective_date
366      ,p_rec
367      );
368   --
369   -- Call to raise any errors on multi-message list
370   hr_multi_message.end_validation_set;
371   --
372   hr_utility.set_location('Leaving:'||l_proc, 20);
373 end ins;
374 --
375 -- ----------------------------------------------------------------------------
376 -- |---------------------------------< ins >----------------------------------|
377 -- ----------------------------------------------------------------------------
378 Procedure ins
379   (p_effective_date               in     date
380   ,p_business_group_id              in     number
381   ,p_forum_id                          in  number
382   ,p_person_id                         in  number
383   ,p_contact_id                        in  number
384 --,p_forum_id                          out nocopy number
385 --,p_person_id                         out nocopy number
386 --,p_contact_id                        out nocopy number
387   ,p_object_version_number             out nocopy number
388   ) is
389 --
390   l_rec   ota_fns_shd.g_rec_type;
391   l_proc  varchar2(72) := g_package||'ins';
392 --
393 Begin
394   hr_utility.set_location('Entering:'||l_proc, 5);
395   --
396   -- Call conversion function to turn arguments into the
397   -- p_rec structure.
398   --
399   l_rec :=
400   ota_fns_shd.convert_args
401     (--null
402     p_forum_id
403     ,p_business_group_id
404     ,null
405     --,null
406     --,null
407     ,p_person_id
408     ,p_contact_id
409     );
410   --
411   -- Having converted the arguments into the ota_fns_rec
412   -- plsql record structure we call the corresponding record business process.
413   --
414   ota_fns_ins.ins
415      (p_effective_date
416      ,l_rec
417      );
418   --
419   -- As the primary key argument(s)
420   -- are specified as an OUT's we must set these values.
421   --
422   --p_forum_id := l_rec.forum_id;
423   --p_person_id := l_rec.person_id;
424   --p_contact_id := l_rec.contact_id;
425   p_object_version_number := l_rec.object_version_number;
426   --
427   hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End ins;
429 --
430 end ota_fns_ins;