1 Package Body pqh_rap_ins as
2 /* $Header: pqraprhi.pkb 120.0 2005/05/29 02:24 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package constant varchar2(33) := ' pqh_rap_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_approval_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_rank_process_approval_id in number) is
20 --
21 l_proc constant varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24
25 hr_utility.set_location('Entering:'||l_proc, 10);
26 --
27 pqh_rap_ins.g_rank_process_approval_id_i := p_rank_process_approval_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 pqh_rap_shd.g_rec_type
78 ) is
79 --
80 l_proc constant varchar2(72):= g_package||'insert_dml';
81 --
82 Begin
83
84 hr_utility.set_location('Entering:'||l_proc, 5);
85 p_rec.object_version_number := 1; -- Initialise the object version
86 --
87 --
88 --
89 -- Insert the row into: pqh_rank_process_approvals
90 --
91 insert into pqh_rank_process_approvals
92 (rank_process_approval_id
93 ,rank_process_id
94 ,approval_date
95 ,supervisor_id
96 ,system_rank
97 ,population_count
98 ,proposed_rank
99 ,object_version_number
100 )
101 Values
102 (p_rec.rank_process_approval_id
103 ,p_rec.rank_process_id
104 ,p_rec.approval_date
105 ,p_rec.supervisor_id
106 ,p_rec.system_rank
107 ,p_rec.population_count
108 ,p_rec.proposed_rank
109 ,p_rec.object_version_number
110 );
111 --
112 --
113 --
114 hr_utility.set_location(' Leaving:'||l_proc, 10);
115 Exception
116 When hr_api.check_integrity_violated Then
117 -- A check constraint has been violated
118 --
119 pqh_rap_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When hr_api.parent_integrity_violated Then
122 -- Parent integrity has been violated
123 --
124 pqh_rap_shd.constraint_error
125 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126 When hr_api.unique_integrity_violated Then
127 -- Unique integrity has been violated
128 --
129 pqh_rap_shd.constraint_error
130 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131 When Others Then
132 --
133 Raise;
134 End insert_dml;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |------------------------------< pre_insert >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 -- This private procedure contains any processing which is required before
143 -- the insert dml. Presently, if the entity has a corresponding primary
144 -- key which is maintained by an associating sequence, the primary key for
145 -- the entity will be populated with the next sequence value in
146 -- preparation for the insert dml.
147 --
148 -- Prerequisites:
149 -- This is an internal procedure which is called from the ins procedure.
150 --
151 -- In Parameters:
152 -- A Pl/Sql record structure.
153 --
154 -- Post Success:
155 -- Processing continues.
156 --
157 -- Post Failure:
158 -- If an error has occurred, an error message and exception will be raised
159 -- but not handled.
160 --
161 -- Developer Implementation Notes:
162 -- Any pre-processing required before the insert dml is issued should be
163 -- coded within this procedure. As stated above, a good example is the
164 -- generation of a primary key number via a corresponding sequence.
165 -- It is important to note that any 3rd party maintenance should be reviewed
166 -- before placing in this procedure.
167 --
168 -- Access Status:
169 -- Internal Row Handler Use Only.
170 --
171 -- {End Of Comments}
172 -- ----------------------------------------------------------------------------
173 Procedure pre_insert
174 (p_rec in out nocopy pqh_rap_shd.g_rec_type
175 ) is
176 --
177 Cursor C_Sel1 is select pqh_rank_process_approvals_s.nextval from sys.dual;
178 --
179 Cursor C_Sel2 is
180 Select null
181 from pqh_rank_process_approvals
182 where rank_process_approval_id =
183 pqh_rap_ins.g_rank_process_approval_id_i;
184 --
185 l_proc constant varchar2(72):= g_package||'pre_insert';
186 l_exists varchar2(1);
187 --
188 Begin
189
190 hr_utility.set_location('Entering:'||l_proc, 5);
191 --
192 If (pqh_rap_ins.g_rank_process_approval_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','pqh_rank_process_approvals');
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.rank_process_approval_id :=
212 pqh_rap_ins.g_rank_process_approval_id_i;
213 pqh_rap_ins.g_rank_process_approval_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.rank_process_approval_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_effective_date in date
263 ,p_rec in pqh_rap_shd.g_rec_type
264 ) is
265 --
266 l_proc constant varchar2(72):= g_package||'post_insert';
267 --
268 Begin
269
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 begin
272 --
273 pqh_rap_rki.after_insert
274 (p_effective_date => p_effective_date
275 ,p_rank_process_approval_id
276 => p_rec.rank_process_approval_id
277 ,p_rank_process_id
278 => p_rec.rank_process_id
279 ,p_approval_date
280 => p_rec.approval_date
281 ,p_supervisor_id
282 => p_rec.supervisor_id
283 ,p_system_rank
284 => p_rec.system_rank
285 ,p_population_count
286 => p_rec.population_count
287 ,p_proposed_rank
288 => p_rec.proposed_rank
289 ,p_object_version_number
290 => p_rec.object_version_number
291 );
292 --
293 exception
294 --
295 when hr_api.cannot_find_prog_unit then
296 --
297 hr_api.cannot_find_prog_unit_error
298 (p_module_name => 'PQH_RANK_PROCESS_APPROVALS'
299 ,p_hook_type => 'AI');
300 --
301 end;
302 --
303 hr_utility.set_location(' Leaving:'||l_proc, 10);
304 End post_insert;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< ins >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure ins
310 (p_effective_date in date
311 ,p_rec in out nocopy pqh_rap_shd.g_rec_type
312 ) is
313 --
314 l_proc constant varchar2(72):= g_package||'ins';
315 --
316 Begin
317
318 hr_utility.set_location('Entering:'||l_proc, 5);
319 --
320 -- Call the supporting insert validate operations
321 --
322 pqh_rap_bus.insert_validate
323 (p_effective_date
324 ,p_rec
325 );
326 --
327 -- Call to raise any errors on multi-message list
328 hr_multi_message.end_validation_set;
329 --
330 -- Call the supporting pre-insert operation
331 --
332 pqh_rap_ins.pre_insert(p_rec);
333 --
334 -- Insert the row
335 --
336 pqh_rap_ins.insert_dml(p_rec);
337 --
338 -- Call the supporting post-insert operation
339 --
340 pqh_rap_ins.post_insert
341 (p_effective_date
342 ,p_rec
343 );
344 --
345 -- Call to raise any errors on multi-message list
346 hr_multi_message.end_validation_set;
347 --
348 hr_utility.set_location('Leaving:'||l_proc, 20);
349 end ins;
350 --
351 -- ----------------------------------------------------------------------------
352 -- |---------------------------------< ins >----------------------------------|
353 -- ----------------------------------------------------------------------------
354 Procedure ins
355 (p_effective_date in date
356 ,p_rank_process_id in number
357 ,p_approval_date in date
358 ,p_supervisor_id in number default null
359 ,p_system_rank in number default null
360 ,p_population_count in number default null
361 ,p_proposed_rank in number default null
362 ,p_rank_process_approval_id out nocopy number
363 ,p_object_version_number out nocopy number
364 ) is
365 --
366 l_rec pqh_rap_shd.g_rec_type;
367 l_proc constant varchar2(72):= g_package||'ins';
368 --
369 Begin
370
371 hr_utility.set_location('Entering:'||l_proc, 5);
372 --
373 -- Call conversion function to turn arguments into the
374 -- p_rec structure.
375 --
376 l_rec :=
377 pqh_rap_shd.convert_args
378 (null
379 ,p_rank_process_id
380 ,p_approval_date
381 ,p_supervisor_id
382 ,p_system_rank
383 ,p_population_count
384 ,p_proposed_rank
385 ,null
386 );
387 --
388 -- Having converted the arguments into the pqh_rap_rec
389 -- plsql record structure we call the corresponding record business process.
390 --
391 pqh_rap_ins.ins
392 (p_effective_date
393 ,l_rec
394 );
395 --
396 -- As the primary key argument(s)
397 -- are specified as an OUT's we must set these values.
398 --
399 p_rank_process_approval_id := l_rec.rank_process_approval_id;
400 p_object_version_number := l_rec.object_version_number;
401 --
402 hr_utility.set_location(' Leaving:'||l_proc, 10);
403 End ins;
404 --
405 end pqh_rap_ins;