DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FRM_INS

Source


1 Package Body ota_frm_ins as
2 /* $Header: otfrmrhi.pkb 120.3 2006/04/27 00:19 aabalakr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_frm_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 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_forum_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   ota_frm_ins.g_forum_id_i := p_forum_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy ota_frm_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: ota_forums_b
88   --
89   insert into ota_forums_b
90       (forum_id
91       ,business_group_id
92       ,start_date_active
93       ,end_date_active
94       ,message_type_flag
95       ,allow_html_flag
96       ,allow_attachment_flag
97       ,auto_notification_flag
98       ,public_flag
99       ,object_version_number
100       )
101   Values
102     (p_rec.forum_id
103     ,p_rec.business_group_id
104     ,p_rec.start_date_active
105     ,p_rec.end_date_active
106     ,p_rec.message_type_flag
110     ,p_rec.public_flag
107     ,p_rec.allow_html_flag
108     ,p_rec.allow_attachment_flag
109     ,p_rec.auto_notification_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_frm_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_frm_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_frm_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_frm_shd.g_rec_type
177   ) is
178 --
179   Cursor C_Sel1 is select ota_forums_b_s.nextval from sys.dual;
180 --
181   Cursor C_Sel2 is
182     Select null
183       from ota_forums_b
184      where forum_id =
185              ota_frm_ins.g_forum_id_i;
186 --
187   l_proc   varchar2(72) := g_package||'pre_insert';
188   l_exists varchar2(1);
189 --
190 Begin
191   hr_utility.set_location('Entering:'||l_proc, 5);
192   --
193   If (ota_frm_ins.g_forum_id_i is not null) Then
194     --
195     -- Verify registered primary key values not already in use
196     --
197     Open C_Sel2;
198     Fetch C_Sel2 into l_exists;
199     If C_Sel2%found Then
200        Close C_Sel2;
201        --
202        -- The primary key values are already in use.
203        --
204        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
205        fnd_message.set_token('TABLE_NAME','ota_forums_b');
206        fnd_message.raise_error;
207     End If;
208     Close C_Sel2;
209     --
210     -- Use registered key values and clear globals
211     --
212     p_rec.forum_id :=
213       ota_frm_ins.g_forum_id_i;
214     ota_frm_ins.g_forum_id_i := null;
215   Else
216     --
217     -- No registerd key values, so select the next sequence number
218     --
219     --
220     -- Select the next sequence number
221     --
222     Open C_Sel1;
223     Fetch C_Sel1 Into p_rec.forum_id;
224     Close C_Sel1;
225   End If;
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End pre_insert;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< post_insert >------------------------------|
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 --   This private procedure contains any processing which is required after
237 --   the insert dml.
238 --
239 -- Prerequisites:
240 --   This is an internal procedure which is called from the ins procedure.
241 --
242 -- In Parameters:
243 --   A Pl/Sql record structre.
244 --
245 -- Post Success:
246 --   Processing continues.
247 --
248 -- Post Failure:
249 --   If an error has occurred, an error message and exception will be raised
250 --   but not handled.
251 --
252 -- Developer Implementation Notes:
253 --   Any post-processing required after the insert dml is issued should be
254 --   coded within this procedure. It is important to note that any 3rd party
255 --   maintenance should be reviewed before placing in this procedure.
256 --
257 -- Access Status:
258 --   Internal Row Handler Use Only.
259 --
260 -- {End Of Comments}
261 -- ----------------------------------------------------------------------------
262 Procedure post_insert
263   (p_effective_date               in date
264   ,p_rec                          in ota_frm_shd.g_rec_type
265   ) is
266 --
267   l_proc  varchar2(72) := g_package||'post_insert';
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   begin
272     --
273     ota_frm_rki.after_insert
274       (p_effective_date              => p_effective_date
275       ,p_forum_id
276       => p_rec.forum_id
277       ,p_business_group_id
278       => p_rec.business_group_id
279       ,p_start_date_active
280       => p_rec.start_date_active
281       ,p_end_date_active
282       => p_rec.end_date_active
283       ,p_message_type_flag
284       => p_rec.message_type_flag
285       ,p_allow_html_flag
286       => p_rec.allow_html_flag
287       ,p_allow_attachment_flag
288       => p_rec.allow_attachment_flag
289       ,p_auto_notification_flag
290       => p_rec.auto_notification_flag
291       ,p_public_flag
292       => p_rec.public_flag
293       ,p_object_version_number
294       => p_rec.object_version_number
295       );
296     --
297   exception
298     --
299     when hr_api.cannot_find_prog_unit then
300       --
301       hr_api.cannot_find_prog_unit_error
302         (p_module_name => 'OTA_FORUMS_B'
303         ,p_hook_type   => 'AI');
304       --
305   end;
306   --
307   hr_utility.set_location(' Leaving:'||l_proc, 10);
308 End post_insert;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |---------------------------------< ins >----------------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure ins
314   (p_effective_date               in date
315   ,p_rec                          in out nocopy ota_frm_shd.g_rec_type
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   -- Call the supporting insert validate operations
324   --
325   ota_frm_bus.insert_validate
326      (p_effective_date
327      ,p_rec
328      );
329   --
330   -- Call to raise any errors on multi-message list
331   hr_multi_message.end_validation_set;
332   --
333   -- Call the supporting pre-insert operation
334   --
335   ota_frm_ins.pre_insert(p_rec);
336   --
337   -- Insert the row
338   --
339   ota_frm_ins.insert_dml(p_rec);
340   --
341   -- Call the supporting post-insert operation
342   --
343   ota_frm_ins.post_insert
344      (p_effective_date
345      ,p_rec
346      );
347   --
348   -- Call to raise any errors on multi-message list
349   hr_multi_message.end_validation_set;
350   --
351   hr_utility.set_location('Leaving:'||l_proc, 20);
352 end ins;
353 --
354 -- ----------------------------------------------------------------------------
355 -- |---------------------------------< ins >----------------------------------|
356 -- ----------------------------------------------------------------------------
357 Procedure ins
358   (p_effective_date               in     date
359   ,p_business_group_id              in     number
360   ,p_message_type_flag              in     varchar2
361   ,p_allow_html_flag                in     varchar2
362   ,p_allow_attachment_flag          in     varchar2
363   ,p_auto_notification_flag         in     varchar2
364   ,p_public_flag                    in     varchar2
365   ,p_start_date_active              in     date     default null
366   ,p_end_date_active                in     date     default null
367   ,p_forum_id                          out nocopy number
368   ,p_object_version_number             out nocopy number
369   ) is
370 --
371   l_rec   ota_frm_shd.g_rec_type;
372   l_proc  varchar2(72) := g_package||'ins';
373 --
374 Begin
375   hr_utility.set_location('Entering:'||l_proc, 5);
376   --
377   -- Call conversion function to turn arguments into the
378   -- p_rec structure.
379   --
380   l_rec :=
381   ota_frm_shd.convert_args
382     (null
383     ,p_business_group_id
384     ,p_start_date_active
385     ,p_end_date_active
386     ,p_message_type_flag
387     ,p_allow_html_flag
388     ,p_allow_attachment_flag
389     ,p_auto_notification_flag
390     ,p_public_flag
391     ,null
392     );
393   --
394   -- Having converted the arguments into the ota_frm_rec
395   -- plsql record structure we call the corresponding record business process.
396   --
397   ota_frm_ins.ins
398      (p_effective_date
399      ,l_rec
400      );
401   --
402   -- As the primary key argument(s)
403   -- are specified as an OUT's we must set these values.
404   --
405   p_forum_id := l_rec.forum_id;
406   p_object_version_number := l_rec.object_version_number;
407   --
408   hr_utility.set_location(' Leaving:'||l_proc, 10);
409 End ins;
410 --
411 end ota_frm_ins;