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