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