DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_FCU_INS

Source


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