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