DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_IAS_INS

Source


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