1 Package Body per_psv_ins as
2 /* $Header: pepsvrhi.pkb 115.7 2002/12/05 09:55:22 eumenyio noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_psv_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_pos_structure_version_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_pos_structure_version_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 per_psv_ins.g_pos_structure_version_id_i := p_pos_structure_version_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 per_psv_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 per_psv_shd.g_api_dml := true; -- Set the api dml status
86 --
87 -- Insert the row into: per_pos_structure_versions
88 --
89 insert into per_pos_structure_versions
90 (pos_structure_version_id
91 ,business_group_id
92 ,position_structure_id
93 ,date_from
94 ,version_number
95 ,copy_structure_version_id
96 ,date_to
97 ,request_id
98 ,program_application_id
99 ,program_id
100 ,program_update_date
101 ,object_version_number
102 )
103 Values
104 (p_rec.pos_structure_version_id
105 ,p_rec.business_group_id
106 ,p_rec.position_structure_id
107 ,p_rec.date_from
108 ,p_rec.version_number
109 ,p_rec.copy_structure_version_id
110 ,p_rec.date_to
111 ,p_rec.request_id
112 ,p_rec.program_application_id
113 ,p_rec.program_id
114 ,p_rec.program_update_date
115 ,p_rec.object_version_number
116 );
117 --
118 per_psv_shd.g_api_dml := false; -- Unset the api dml status
119 --
120 hr_utility.set_location(' Leaving:'||l_proc, 10);
121 Exception
122 When hr_api.check_integrity_violated Then
123 -- A check constraint has been violated
124 per_psv_shd.g_api_dml := false; -- Unset the api dml status
125 per_psv_shd.constraint_error
126 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127 When hr_api.parent_integrity_violated Then
128 -- Parent integrity has been violated
129 per_psv_shd.g_api_dml := false; -- Unset the api dml status
130 per_psv_shd.constraint_error
131 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132 When hr_api.unique_integrity_violated Then
133 -- Unique integrity has been violated
134 per_psv_shd.g_api_dml := false; -- Unset the api dml status
135 per_psv_shd.constraint_error
136 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
137 When Others Then
138 per_psv_shd.g_api_dml := false; -- Unset the api dml status
139 Raise;
140 End insert_dml;
141 --
142 -- ----------------------------------------------------------------------------
143 -- |------------------------------< pre_insert >------------------------------|
144 -- ----------------------------------------------------------------------------
145 -- {Start Of Comments}
146 --
147 -- Description:
148 -- This private procedure contains any processing which is required before
149 -- the insert dml. Presently, if the entity has a corresponding primary
150 -- key which is maintained by an associating sequence, the primary key for
151 -- the entity will be populated with the next sequence value in
152 -- preparation for the insert dml.
153 --
154 -- Prerequisites:
155 -- This is an internal procedure which is called from the ins procedure.
156 --
157 -- In Parameters:
158 -- A Pl/Sql record structure.
159 --
160 -- Post Success:
161 -- Processing continues.
162 --
163 -- Post Failure:
164 -- If an error has occurred, an error message and exception will be raised
165 -- but not handled.
166 --
167 -- Developer Implementation Notes:
168 -- Any pre-processing required before the insert dml is issued should be
169 -- coded within this procedure. As stated above, a good example is the
170 -- generation of a primary key number via a corresponding sequence.
171 -- It is important to note that any 3rd party maintenance should be reviewed
172 -- before placing in this procedure.
173 --
174 -- Access Status:
175 -- Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure pre_insert
180 (p_rec in out nocopy per_psv_shd.g_rec_type
181 ) is
182 --
183 Cursor C_Sel1 is select per_pos_structure_versions_s.nextval from sys.dual;
184 --
185 Cursor C_Sel2 is
186 Select null
187 from per_pos_structure_versions
188 where pos_structure_version_id =
189 per_psv_ins.g_pos_structure_version_id_i;
190 --
191 l_proc varchar2(72) := g_package||'pre_insert';
192 l_exists varchar2(1);
193 --
194 Begin
195 hr_utility.set_location('Entering:'||l_proc, 5);
196 --
197 If (per_psv_ins.g_pos_structure_version_id_i is not null) Then
198 --
199 -- Verify registered primary key values not already in use
200 --
201 Open C_Sel2;
202 Fetch C_Sel2 into l_exists;
203 If C_Sel2%found Then
204 Close C_Sel2;
205 --
206 -- The primary key values are already in use.
207 --
208 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
209 fnd_message.set_token('TABLE_NAME','per_pos_structure_versions');
210 fnd_message.raise_error;
211 End If;
212 Close C_Sel2;
213 --
214 -- Use registered key values and clear globals
215 --
216 p_rec.pos_structure_version_id :=
217 per_psv_ins.g_pos_structure_version_id_i;
218 per_psv_ins.g_pos_structure_version_id_i := null;
219 Else
220 --
221 -- No registerd key values, so select the next sequence number
222 --
223 --
224 -- Select the next sequence number
225 --
226 Open C_Sel1;
227 Fetch C_Sel1 Into p_rec.pos_structure_version_id;
228 Close C_Sel1;
229 End If;
230 --
231
232 hr_utility.set_location(' Leaving:'||l_proc, 10);
233 End pre_insert;
234 --
235 -- ----------------------------------------------------------------------------
236 -- |-----------------------------< post_insert >------------------------------|
237 -- ----------------------------------------------------------------------------
238 -- {Start Of Comments}
239 --
240 -- Description:
241 -- This private procedure contains any processing which is required after
242 -- the insert dml.
243 --
244 -- Prerequisites:
245 -- This is an internal procedure which is called from the ins procedure.
246 --
247 -- In Parameters:
248 -- A Pl/Sql record structre.
249 --
250 -- Post Success:
251 -- Processing continues.
252 --
253 -- Post Failure:
254 -- If an error has occurred, an error message and exception will be raised
255 -- but not handled.
256 --
257 -- Developer Implementation Notes:
258 -- Any post-processing required after the insert dml is issued should be
259 -- coded within this procedure. It is important to note that any 3rd party
260 -- maintenance should be reviewed before placing in this procedure.
261 --
262 -- Access Status:
263 -- Internal Row Handler Use Only.
264 --
265 -- {End Of Comments}
266 -- ----------------------------------------------------------------------------
267 Procedure post_insert
268 (p_effective_date in date
269 ,p_rec in per_psv_shd.g_rec_type
270 ) is
271 --
272 l_proc varchar2(72) := g_package||'post_insert';
273 --
274 Begin
275 hr_utility.set_location('Entering:'||l_proc, 5);
276 begin
277 --
278 per_psv_rki.after_insert
279 (p_effective_date => p_effective_date
280 ,p_pos_structure_version_id
281 => p_rec.pos_structure_version_id
282 ,p_business_group_id
283 => p_rec.business_group_id
284 ,p_position_structure_id
285 => p_rec.position_structure_id
286 ,p_date_from
287 => p_rec.date_from
288 ,p_version_number
289 => p_rec.version_number
290 ,p_copy_structure_version_id
291 => p_rec.copy_structure_version_id
292 ,p_date_to
293 => p_rec.date_to
294 ,p_request_id
295 => p_rec.request_id
296 ,p_program_application_id
297 => p_rec.program_application_id
298 ,p_program_id
299 => p_rec.program_id
300 ,p_program_update_date
301 => p_rec.program_update_date
302 ,p_object_version_number
303 => p_rec.object_version_number
304 );
305 --
306 exception
307 --
308 when hr_api.cannot_find_prog_unit then
309 --
310 hr_api.cannot_find_prog_unit_error
311 (p_module_name => 'PER_POS_STRUCTURE_VERSIONS'
312 ,p_hook_type => 'AI');
313 --
314 end;
315 --
316 hr_utility.set_location(' Leaving:'||l_proc, 10);
317 End post_insert;
318 --
319 -- ----------------------------------------------------------------------------
320 -- |---------------------------------< ins >----------------------------------|
321 -- ----------------------------------------------------------------------------
322 Procedure ins
323 (p_effective_date in date
324 ,p_rec in out nocopy per_psv_shd.g_rec_type
325 ,p_gap_warning out nocopy boolean) is
326 --
327 l_proc varchar2(72) := g_package||'ins';
328 --
329 Begin
330 hr_utility.set_location('Entering:'||l_proc, 5);
331 --
332 -- Call the supporting insert validate operations
333 --
334 per_psv_bus.insert_validate
335 (p_effective_date
336 ,p_rec
337 ,p_gap_warning
338 );
339 --
340 -- Call the supporting pre-insert operation
341 --
342 per_psv_ins.pre_insert(p_rec);
343 --
344 -- Insert the row
345 --
346 per_psv_ins.insert_dml(p_rec);
347 --
348 -- Call the supporting post-insert operation
349 --
350 per_psv_ins.post_insert
351 (p_effective_date
352 ,p_rec
353 );
354 --
355 hr_utility.set_location('Leaving:'||l_proc, 20);
356 end ins;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------------< ins >----------------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure ins
362 (p_effective_date in date
363 ,p_position_structure_id in number
364 ,p_date_from in date
365 ,p_version_number in number
366 ,p_copy_structure_version_id in number default null
367 ,p_date_to in date default null
371 ,p_program_update_date in date default null
368 ,p_request_id in number default null
369 ,p_program_application_id in number default null
370 ,p_program_id in number default null
372 ,p_pos_structure_version_id out nocopy number
373 ,p_object_version_number out nocopy number
374 ,p_gap_warning out nocopy boolean
375 ) is
376 --
377 l_rec per_psv_shd.g_rec_type;
378 l_proc varchar2(72) := g_package||'ins';
379 l_business_group_id number;
380 --
381 Begin
382 hr_utility.set_location('Entering:'||l_proc, 5);
383 --
384 -- Call conversion function to turn arguments into the
385 -- p_rec structure.
386 --
387 per_psv_bus.get_business_group_id
388 (p_position_structure_id => p_position_structure_id
389 ,p_business_group_id => l_business_group_id);
390
391 l_rec :=
392 per_psv_shd.convert_args
393 (null
394 ,l_business_group_id
395 ,p_position_structure_id
396 ,p_date_from
397 ,p_version_number
398 ,p_copy_structure_version_id
399 ,p_date_to
400 ,p_request_id
401 ,p_program_application_id
402 ,p_program_id
403 ,p_program_update_date
404 ,null
405 );
406 --
407 -- Having converted the arguments into the per_psv_rec
408 -- plsql record structure we call the corresponding record business process.
409 --
410 per_psv_ins.ins
411 (p_effective_date
412 ,l_rec
413 ,p_gap_warning
414 );
415 --
416 -- As the primary key argument(s)
417 -- are specified as an OUT's we must set these values.
418 --
419 p_pos_structure_version_id := l_rec.pos_structure_version_id;
420 p_object_version_number := l_rec.object_version_number;
421 --
422 hr_utility.set_location(' Leaving:'||l_proc, 10);
423 End ins;
424 --
425 end per_psv_ins;