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