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