DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FCE_INS

Source


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