DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_RTM_INS

Source


1 Package Body irc_rtm_ins as
2 /* $Header: irrtmrhi.pkb 120.3 2008/01/22 10:17:45 mkjayara noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_rtm_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_rec_team_member_id_i  number   default null;
14 -- ----------------------------------------------------------------------------
15 -- |----------------------< set_base_key_value >------------------------------|
16 -- ----------------------------------------------------------------------------
17 procedure set_base_key_value
18 (p_rec_team_member_id in number) is
19   l_proc varchar2(72):=g_package||'set_base_key_value';
20 begin
21   hr_utility.set_location('Entering'||l_proc,10);
22   irc_rtm_ins.g_rec_team_member_id_i := p_rec_team_member_id;
23   hr_utility.set_location('Leaving'||l_proc,20);
24 end set_base_key_value;
25 --
26 -- ----------------------------------------------------------------------------
27 -- |------------------------------< insert_dml >------------------------------|
28 -- ----------------------------------------------------------------------------
29 -- {Start Of Comments}
30 --
31 -- Description:
32 --   This procedure controls the actual dml insert logic. The processing of
33 --   this procedure are as follows:
34 --   1) Initialise the object_version_number to 1 if the object_version_number
35 --      is defined as an attribute for this entity.
36 --   2) To set and unset the g_api_dml status as required (as we are about to
37 --      perform dml).
38 --   3) To insert the row into the schema.
39 --   4) To trap any constraint violations that may have occurred.
40 --   5) To raise any other errors.
41 --
42 -- Prerequisites:
43 --   This is an internal private procedure which must be called from the ins
44 --   procedure and must have all mandatory attributes set (except the
45 --   object_version_number which is initialised within this procedure).
46 --
47 -- In Parameters:
48 --   A Pl/Sql record structre.
49 --
50 -- Post Success:
51 --   The specified row will be inserted into the schema.
52 --
53 -- Post Failure:
54 --   On the insert dml failure it is important to note that we always reset the
55 --   g_api_dml status to false.
56 --   If a check, unique or parent integrity constraint violation is raised the
57 --   constraint_error procedure will be called.
58 --   If any other error is reported, the error will be raised after the
59 --   g_api_dml status is reset.
60 --
61 -- Developer Implementation Notes:
62 --   None.
63 --
64 -- Access Status:
65 --   Internal Row Handler Use Only.
66 --
67 -- {End Of Comments}
68 -- ----------------------------------------------------------------------------
69 Procedure insert_dml
70   (p_rec in out nocopy irc_rtm_shd.g_rec_type
71   ) is
72 --
73   l_proc  varchar2(72) := g_package||'insert_dml';
74 --
75 Begin
76   hr_utility.set_location('Entering:'||l_proc, 5);
77   p_rec.object_version_number := 1;  -- Initialise the object version
78   --
79   --
80   --
81   -- Insert the row into: irc_rec_team_members
82   --
83   insert into irc_rec_team_members
84       (rec_team_member_id
85       ,person_id
86       ,party_id
87       ,vacancy_id
88       ,job_id
89       ,start_date
90       ,end_date
91       ,update_allowed
92       ,delete_allowed
93       ,object_version_number
94       ,interview_security
95       )
96   Values
97     (p_rec.rec_team_member_id
98     ,p_rec.person_id
99     ,p_rec.party_id
100     ,p_rec.vacancy_id
101     ,p_rec.job_id
102     ,p_rec.start_date
103     ,p_rec.end_date
104     ,p_rec.update_allowed
105     ,p_rec.delete_allowed
106     ,p_rec.object_version_number
107     ,p_rec.interview_security
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     irc_rtm_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     irc_rtm_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     irc_rtm_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 irc_rtm_shd.g_rec_type
173   ) is
174 --
175 cursor c1 is select irc_rec_team_members_s.nextval from sys.dual;
176 cursor c2 is
177 select null from irc_rec_team_members
178 where rec_team_member_id = irc_rtm_ins.g_rec_team_member_id_i;
179   l_proc   varchar2(72) := g_package||'pre_insert';
180   l_exists varchar2(1);
181 --
182 Begin
183   hr_utility.set_location('Entering:'||l_proc, 5);
184   --
185   If (irc_rtm_ins.g_rec_team_member_id_i is not null) Then
186 
187    open c2;
188    fetch c2 into l_exists;
189    if c2%found then
190     close c2;
191     fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
192     fnd_message.set_token('TABLE_NAME','irc_rec_team_members');
193     fnd_message.raise_error;
194   end if;
195   close c2;
196     --
197     -- Use registered key values and clear globals
198     --
199     p_rec.rec_team_member_id :=
200       irc_rtm_ins.g_rec_team_member_id_i;
201     irc_rtm_ins.g_rec_team_member_id_i := null;
202   --
203   else
204     open c1;
205     fetch c1 into p_rec.rec_team_member_id;
206     close c1;
207   End If;
208   --
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End pre_insert;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |-----------------------------< post_insert >------------------------------|
214 -- ----------------------------------------------------------------------------
215 -- {Start Of Comments}
216 --
217 -- Description:
218 --   This private procedure contains any processing which is required after
219 --   the insert dml.
220 --
221 -- Prerequisites:
222 --   This is an internal procedure which is called from the ins procedure.
223 --
224 -- In Parameters:
225 --   A Pl/Sql record structre.
226 --
227 -- Post Success:
228 --   Processing continues.
229 --
230 -- Post Failure:
231 --   If an error has occurred, an error message and exception will be raised
232 --   but not handled.
233 --
234 -- Developer Implementation Notes:
235 --   Any post-processing required after the insert dml is issued should be
236 --   coded within this procedure. It is important to note that any 3rd party
237 --   maintenance should be reviewed before placing in this procedure.
238 --
239 -- Access Status:
240 --   Internal Row Handler Use Only.
241 --
242 -- {End Of Comments}
243 -- ----------------------------------------------------------------------------
244 Procedure post_insert
245   (p_rec                          in irc_rtm_shd.g_rec_type
246   ) is
247 --
248   l_proc  varchar2(72) := g_package||'post_insert';
249 --
250 Begin
251   hr_utility.set_location('Entering:'||l_proc, 5);
252   begin
253     --
254     irc_rtm_rki.after_insert
255       (p_rec_team_member_id => p_rec.rec_team_member_id
256       ,p_person_id => p_rec.person_id
257       ,p_vacancy_id
258       => p_rec.vacancy_id
259       ,p_job_id
260       => p_rec.job_id
261       ,p_start_date
262       => p_rec.start_date
263       ,p_end_date
264       => p_rec.end_date
265       ,p_update_allowed
266       => p_rec.update_allowed
267       ,p_interview_security
268       => p_rec.interview_security
269       ,p_delete_allowed
270       => p_rec.delete_allowed
271       ,p_object_version_number
272       => p_rec.object_version_number
273       );
274     --
275   exception
276     --
277     when hr_api.cannot_find_prog_unit then
278       --
279       hr_api.cannot_find_prog_unit_error
280         (p_module_name => 'IRC_REC_TEAM_MEMBERS'
281         ,p_hook_type   => 'AI');
282       --
283   end;
284   --
285   hr_utility.set_location(' Leaving:'||l_proc, 10);
286 End post_insert;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |---------------------------------< ins >----------------------------------|
290 -- ----------------------------------------------------------------------------
291 Procedure ins
292   (p_rec                          in out nocopy irc_rtm_shd.g_rec_type
293   ) is
294 --
295   l_proc  varchar2(72) := g_package||'ins';
296 --
297 Begin
298   hr_utility.set_location('Entering:'||l_proc, 5);
299   --
300   -- Call the supporting insert validate operations
301   --
302   irc_rtm_bus.insert_validate
303      (p_rec
304      );
305   --
306   -- Call to raise any errors on multi-message list
307   hr_multi_message.end_validation_set;
308   --
309   -- Call the supporting pre-insert operation
310   --
311   irc_rtm_ins.pre_insert(p_rec);
312   --
313   -- Insert the row
314   --
315   irc_rtm_ins.insert_dml(p_rec);
316   --
317   -- Call the supporting post-insert operation
318   --
319   irc_rtm_ins.post_insert
320      (p_rec
321      );
322   --
323   -- Call to raise any errors on multi-message list
324   hr_multi_message.end_validation_set;
325   hr_utility.set_location('Leaving:'||l_proc, 20);
326 end ins;
327 --
328 -- ----------------------------------------------------------------------------
329 -- |---------------------------------< ins >----------------------------------|
330 -- ----------------------------------------------------------------------------
331 Procedure ins
332   (p_job_id                        in     number
333   ,p_update_allowed                 in     varchar2
334   ,p_delete_allowed                 in     varchar2
335   ,p_start_date                     in     date     default null
336   ,p_end_date                       in     date     default null
337   ,p_vacancy_id                     in     number
338   ,p_person_id                      in     number
339   ,p_object_version_number          out nocopy    number
340   ,p_rec_team_member_id             out nocopy number
341   ,p_interview_security              in    varchar2  default 'SELF'
342   ) is
343 --
344   l_rec   irc_rtm_shd.g_rec_type;
345   l_proc  varchar2(72) := g_package||'ins';
346 --
347 Begin
348   hr_utility.set_location('Entering:'||l_proc, 5);
349   --
350   -- Call conversion function to turn arguments into the
351   -- p_rec structure.
352   --
353   l_rec :=
354   irc_rtm_shd.convert_args
355     (null
356     ,p_person_id
357     ,null
358     ,p_vacancy_id
359     ,p_job_id
360     ,p_start_date
361     ,p_end_date
362     ,p_update_allowed
363     ,p_delete_allowed
364     ,null
365     ,p_interview_security
366     );
367   --
368   -- Having converted the arguments into the irc_rtm_rec
369   -- plsql record structure we call the corresponding record business process.
370   --
371   irc_rtm_ins.ins
372      (l_rec
373      );
374   --
375   -- The OUT argument's values must be set.
376   --
377   p_rec_team_member_id := l_rec.rec_team_member_id;
378   p_object_version_number := l_rec.object_version_number;
379   --
380   hr_utility.set_location(' Leaving:'||l_proc, 10);
381 End ins;
382 --
383 end irc_rtm_ins;