DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_APA_INS

Source


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