DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_FFA_INS

Source


1 Package Body pqp_ffa_ins as
2 /* $Header: pqffarhi.pkb 120.0 2006/04/26 23:47 pbhure noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqp_ffa_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_flxdu_func_attribute_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_flxdu_func_attribute_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   pqp_ffa_ins.g_flxdu_func_attribute_id_i := p_flxdu_func_attribute_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 pqp_ffa_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: pqp_flxdu_func_attributes
88   --
89   insert into pqp_flxdu_func_attributes
90       (flxdu_func_attribute_id
91       ,flxdu_func_name
92       ,flxdu_func_source_type
93       ,flxdu_func_integrator_code
94       ,flxdu_func_xml_data
95       ,legislation_code
96       ,description
97       ,object_version_number
98       )
99   Values
100     (p_rec.flxdu_func_attribute_id
101     ,p_rec.flxdu_func_name
102     ,p_rec.flxdu_func_source_type
103     ,p_rec.flxdu_func_integrator_code
107     ,p_rec.object_version_number
104     ,p_rec.flxdu_func_xml_data
105     ,p_rec.legislation_code
106     ,p_rec.description
108     );
109   --
110   --
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     --
117     pqp_ffa_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     --
122     pqp_ffa_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     --
127     pqp_ffa_shd.constraint_error
128       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
129   When Others Then
130     --
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 pqp_ffa_shd.g_rec_type
173   ) is
174 --
175   Cursor C_Sel1 is select pqp_flxdu_func_attributes_s.nextval from sys.dual;
176 --
177   Cursor C_Sel2 is
178     Select null
179       from pqp_flxdu_func_attributes
180      where flxdu_func_attribute_id =
181              pqp_ffa_ins.g_flxdu_func_attribute_id_i;
182 --
183   l_proc   varchar2(72) := g_package||'pre_insert';
184   l_exists varchar2(1);
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   If (pqp_ffa_ins.g_flxdu_func_attribute_id_i is not null) Then
190     --
191     -- Verify registered primary key values not already in use
192     --
193     Open C_Sel2;
194     Fetch C_Sel2 into l_exists;
195     If C_Sel2%found Then
196        Close C_Sel2;
197        --
198        -- The primary key values are already in use.
199        --
200        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
201        fnd_message.set_token('TABLE_NAME','pqp_flxdu_func_attributes');
202        fnd_message.raise_error;
203     End If;
204     Close C_Sel2;
205     --
206     -- Use registered key values and clear globals
207     --
208     p_rec.flxdu_func_attribute_id :=
209       pqp_ffa_ins.g_flxdu_func_attribute_id_i;
210     pqp_ffa_ins.g_flxdu_func_attribute_id_i := null;
211   Else
212     --
213     -- No registerd key values, so select the next sequence number
214     --
215     --
216     -- Select the next sequence number
217     --
218     Open C_Sel1;
219     Fetch C_Sel1 Into p_rec.flxdu_func_attribute_id;
220     Close C_Sel1;
221   End If;
222   --
223   hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End pre_insert;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< post_insert >------------------------------|
228 -- ----------------------------------------------------------------------------
229 -- {Start Of Comments}
230 --
231 -- Description:
232 --   This private procedure contains any processing which is required after
233 --   the insert dml.
234 --
235 -- Prerequisites:
236 --   This is an internal procedure which is called from the ins procedure.
237 --
238 -- In Parameters:
239 --   A Pl/Sql record structre.
240 --
241 -- Post Success:
242 --   Processing continues.
243 --
244 -- Post Failure:
245 --   If an error has occurred, an error message and exception will be raised
246 --   but not handled.
247 --
248 -- Developer Implementation Notes:
249 --   Any post-processing required after the insert dml is issued should be
250 --   coded within this procedure. It is important to note that any 3rd party
251 --   maintenance should be reviewed before placing in this procedure.
252 --
253 -- Access Status:
254 --   Internal Row Handler Use Only.
255 --
256 -- {End Of Comments}
260   ) is
257 -- ----------------------------------------------------------------------------
258 Procedure post_insert
259   (p_rec                          in pqp_ffa_shd.g_rec_type
261 --
262   l_proc  varchar2(72) := g_package||'post_insert';
263 --
264 Begin
265   hr_utility.set_location('Entering:'||l_proc, 5);
266   begin
267     --
268     pqp_ffa_rki.after_insert
269       (p_flxdu_func_attribute_id
270       => p_rec.flxdu_func_attribute_id
271       ,p_flxdu_func_name
272       => p_rec.flxdu_func_name
273       ,p_flxdu_func_source_type
274       => p_rec.flxdu_func_source_type
275       ,p_flxdu_func_integrator_code
276       => p_rec.flxdu_func_integrator_code
277       ,p_flxdu_func_xml_data
278       => p_rec.flxdu_func_xml_data
279       ,p_legislation_code
280       => p_rec.legislation_code
281       ,p_description
282       => p_rec.description
283       ,p_object_version_number
284       => p_rec.object_version_number
285       );
286     --
287   exception
288     --
289     when hr_api.cannot_find_prog_unit then
290       --
291       hr_api.cannot_find_prog_unit_error
292         (p_module_name => 'PQP_FLXDU_FUNC_ATTRIBUTES'
293         ,p_hook_type   => 'AI');
294       --
295   end;
296   --
297   hr_utility.set_location(' Leaving:'||l_proc, 10);
298 End post_insert;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< ins >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure ins
304   (p_rec                          in out nocopy pqp_ffa_shd.g_rec_type
305   ) is
306 --
307   l_proc  varchar2(72) := g_package||'ins';
308 --
309 Begin
310   hr_utility.set_location('Entering:'||l_proc, 5);
311   --
312   -- Call the supporting insert validate operations
313   --
314   pqp_ffa_bus.insert_validate
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   pqp_ffa_ins.pre_insert(p_rec);
324   --
325   -- Insert the row
326   --
327   pqp_ffa_ins.insert_dml(p_rec);
328   --
329   -- Call the supporting post-insert operation
330   --
331   pqp_ffa_ins.post_insert
332      (p_rec
333      );
334   --
335   -- Call to raise any errors on multi-message list
336   hr_multi_message.end_validation_set;
337   --
338   hr_utility.set_location('Leaving:'||l_proc, 20);
339 end ins;
340 --
341 -- ----------------------------------------------------------------------------
342 -- |---------------------------------< ins >----------------------------------|
343 -- ----------------------------------------------------------------------------
344 Procedure ins
345   (p_flxdu_func_name                in     varchar2
346   ,p_flxdu_func_source_type         in     varchar2
347   ,p_flxdu_func_integrator_code     in     varchar2
348   ,p_flxdu_func_xml_data            in     varchar2 default null
349   ,p_legislation_code               in     varchar2 default null
350   ,p_description                    in     varchar2 default null
351   ,p_flxdu_func_attribute_id           out nocopy number
352   ,p_object_version_number             out nocopy number
353   ) is
354 --
355   l_rec   pqp_ffa_shd.g_rec_type;
356   l_proc  varchar2(72) := g_package||'ins';
357 --
358 Begin
359   hr_utility.set_location('Entering:'||l_proc, 5);
360   --
361   -- Call conversion function to turn arguments into the
362   -- p_rec structure.
363   --
364   l_rec :=
365   pqp_ffa_shd.convert_args
366     (null
367     ,p_flxdu_func_name
368     ,p_flxdu_func_source_type
369     ,p_flxdu_func_integrator_code
370     ,p_flxdu_func_xml_data
371     ,p_legislation_code
372     ,p_description
373     ,null
374     );
375   --
376   -- Having converted the arguments into the pqp_ffa_rec
377   -- plsql record structure we call the corresponding record business process.
378   --
379   pqp_ffa_ins.ins
380      (l_rec
381      );
382   --
383   -- As the primary key argument(s)
384   -- are specified as an OUT's we must set these values.
385   --
386   p_flxdu_func_attribute_id := l_rec.flxdu_func_attribute_id;
387   p_object_version_number := l_rec.object_version_number;
388   --
389   hr_utility.set_location(' Leaving:'||l_proc, 10);
390 End ins;
391 --
392 end pqp_ffa_ins;