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