1 Package Body ghr_dut_del as
2 /* $Header: ghdutrhi.pkb 120.0.12000000.1 2007/01/18 13:42:07 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_dut_del.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_delete_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml delete logic for the datetrack
17 -- delete modes: ZAP, DELETE, FUTURE_CHANGE and DELETE_NEXT_CHANGE. The
18 -- execution is as follows:
19 -- 1) To set and unset the g_api_dml status as required (as we are about to
20 -- perform dml).
21 -- 2) If the delete mode is DELETE_NEXT_CHANGE then delete where the
22 -- effective start date is equal to the validation start date.
23 -- 3) If the delete mode is not DELETE_NEXT_CHANGE then delete
24 -- all rows for the entity where the effective start date is greater
25 -- than or equal to the validation start date.
26 -- 4) To raise any errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the
30 -- delete_dml procedure.
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be delete from the schema.
37 --
38 -- Post Failure:
39 -- On the delete dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If any other error is reported, the error will be raised after the
42 -- g_api_dml status is reset.
43 --
44 -- Developer Implementation Notes:
45 -- This is an internal private procedure which must be called from the
46 -- delete_dml procedure.
47 --
48 -- Access Status:
49 -- Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure dt_delete_dml
54 (p_rec in out nocopy ghr_dut_shd.g_rec_type,
55 p_effective_date in date,
56 p_datetrack_mode in varchar2,
57 p_validation_start_date in date,
58 p_validation_end_date in date) is
59 --
60 l_proc varchar2(72) := g_package||'dt_delete_dml';
61 --
62 Begin
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 If (p_datetrack_mode = 'DELETE_NEXT_CHANGE') then
65 hr_utility.set_location(l_proc, 10);
66 ghr_dut_shd.g_api_dml := true; -- Set the api dml status
67 --
68 -- Delete the where the effective start date is equal
69 -- to the validation end date.
70 --
71 hr_utility.set_location('dt_delete_dml NAR IF ',10);
72 delete from ghr_duty_stations_f
73 where duty_station_id = p_rec.duty_station_id
74 and effective_start_date = p_validation_start_date;
75 --
76 ghr_dut_shd.g_api_dml := false; -- Unset the api dml status
77 Else
78 hr_utility.set_location(l_proc, 15);
79 ghr_dut_shd.g_api_dml := true; -- Set the api dml status
80 --
81 -- Delete the row(s) where the effective start date is greater than
82 -- or equal to the validation start date.
83 --
84 hr_utility.set_location('dt_delete_dml NAR ELSE ',15);
85 delete from ghr_duty_stations_f
86 where duty_station_id = p_rec.duty_station_id
87 and effective_start_date >= p_validation_start_date;
88 --
89 ghr_dut_shd.g_api_dml := false; -- Unset the api dml status
90 End If;
91 --
92 hr_utility.set_location(' Leaving:'||l_proc, 20);
93 --
94 Exception
95 When Others Then
96 ghr_dut_shd.g_api_dml := false; -- Unset the api dml status
97 Raise;
98 End dt_delete_dml;
99 --
100 -- ----------------------------------------------------------------------------
101 -- |------------------------------< delete_dml >------------------------------|
102 -- ----------------------------------------------------------------------------
103 Procedure delete_dml
104 (p_rec in out nocopy ghr_dut_shd.g_rec_type,
105 p_effective_date in date,
106 p_datetrack_mode in varchar2,
107 p_validation_start_date in date,
108 p_validation_end_date in date) is
109 --
110 l_proc varchar2(72) := g_package||'delete_dml';
111 --
112 Begin
113 hr_utility.set_location('Entering:'||l_proc, 5);
114 --
115 dt_delete_dml(p_rec => p_rec,
116 p_effective_date => p_effective_date,
117 p_datetrack_mode => p_datetrack_mode,
118 p_validation_start_date => p_validation_start_date,
119 p_validation_end_date => p_validation_end_date);
120 --
121 hr_utility.set_location(' Leaving:'||l_proc, 10);
122 End delete_dml;
123 --
124 -- ----------------------------------------------------------------------------
125 -- |----------------------------< dt_pre_delete >-----------------------------|
126 -- ----------------------------------------------------------------------------
127 -- {Start Of Comments}
128 --
129 -- Description:
130 -- The dt_pre_delete process controls the execution of dml
131 -- for the datetrack modes: DELETE, FUTURE_CHANGE
132 -- and DELETE_NEXT_CHANGE only.
133 --
134 -- Prerequisites:
135 -- This is an internal procedure which is called from the pre_delete
136 -- procedure.
137 --
138 -- In Parameters:
139 -- A Pl/Sql record structre.
140 --
141 -- Post Success:
142 -- Processing continues.
143 --
144 -- Post Failure:
145 -- If an error has occurred, an error message and exception will be raised
146 -- but not handled.
147 --
148 -- Developer Implementation Notes:
149 -- This is an internal procedure which is required by Datetrack. Don't
150 -- remove or modify.
151 --
152 -- Access Status:
153 -- Internal Row Handler Use Only.
154 --
155 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure dt_pre_delete
158 (p_rec in out nocopy ghr_dut_shd.g_rec_type,
159 p_effective_date in date,
160 p_datetrack_mode in varchar2,
161 p_validation_start_date in date,
162 p_validation_end_date in date) is
163 --
164 l_proc varchar2(72) := g_package||'dt_pre_delete';
165 --
166 Begin
167 hr_utility.set_location('Entering:'||l_proc, 5);
168 --
169 If (p_datetrack_mode <> 'ZAP') then
170 --
171 p_rec.effective_start_date := ghr_dut_shd.g_old_rec.effective_start_date;
172 --
173 If (p_datetrack_mode = 'DELETE') then
174 p_rec.effective_end_date := p_validation_start_date - 1;
175 Else
176 p_rec.effective_end_date := p_validation_end_date;
177 End If;
178 --
179 -- Update the current effective end date record
180 --
181 ghr_dut_shd.upd_effective_end_date
182 (p_effective_date => p_effective_date,
183 p_base_key_value => p_rec.duty_station_id,
184 p_new_effective_end_date => p_rec.effective_end_date,
185 p_validation_start_date => p_validation_start_date,
186 p_validation_end_date => p_validation_end_date,
187 p_object_version_number => p_rec.object_version_number);
188 Else
189 p_rec.effective_start_date := null;
190 p_rec.effective_end_date := null;
191 End If;
192 hr_utility.set_location(' Leaving:'||l_proc, 10);
193 End dt_pre_delete;
194 --
195 -- ----------------------------------------------------------------------------
196 -- |------------------------------< pre_delete >------------------------------|
197 -- ----------------------------------------------------------------------------
198 -- {Start Of Comments}
199 --
200 -- Description:
201 -- This private procedure contains any processing which is required before
202 -- the delete dml.
203 --
204 -- Prerequisites:
205 -- This is an internal procedure which is called from the del procedure.
206 --
207 -- In Parameters:
208 -- A Pl/Sql record structre.
209 --
210 -- Post Success:
211 -- Processing continues.
212 --
213 -- Post Failure:
214 -- If an error has occurred, an error message and exception will be raised
215 -- but not handled.
216 --
217 -- Developer Implementation Notes:
218 -- Any pre-processing required before the delete dml is issued should be
219 -- coded within this procedure. It is important to note that any 3rd party
220 -- maintenance should be reviewed before placing in this procedure. The call
221 -- to the dt_delete_dml procedure should NOT be removed.
222 --
223 -- Access Status:
224 -- Internal Row Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure pre_delete
229 (p_rec in out nocopy ghr_dut_shd.g_rec_type,
230 p_effective_date in date,
231 p_datetrack_mode in varchar2,
232 p_validation_start_date in date,
233 p_validation_end_date in date) is
234 --
235 l_proc varchar2(72) := g_package||'pre_delete';
236 --
237 --
238 --
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 --
242 --
243 --
244 dt_pre_delete
245 (p_rec => p_rec,
246 p_effective_date => p_effective_date,
247 p_datetrack_mode => p_datetrack_mode,
248 p_validation_start_date => p_validation_start_date,
249 p_validation_end_date => p_validation_end_date);
250 --
251 hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End pre_delete;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< post_delete >------------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 -- This private procedure contains any processing which is required after the
261 -- delete dml.
262 --
263 -- Prerequisites:
264 -- This is an internal procedure which is called from the del procedure.
265 --
266 -- In Parameters:
267 -- A Pl/Sql record structre.
268 --
269 -- Post Success:
270 -- Processing continues.
271 --
272 -- Post Failure:
273 -- If an error has occurred, an error message and exception will be raised
274 -- but not handled.
275 --
276 -- Developer Implementation Notes:
277 -- Any post-processing required after the delete dml is issued should be
278 -- coded within this procedure. It is important to note that any 3rd party
279 -- maintenance should be reviewed before placing in this procedure.
280 --
281 -- Access Status:
282 -- Internal Row Handler Use Only.
283 --
284 -- {End Of Comments}
285 -- ----------------------------------------------------------------------------
286 Procedure post_delete
287 (p_rec in ghr_dut_shd.g_rec_type,
288 p_effective_date in date,
289 p_datetrack_mode in varchar2,
290 p_validation_start_date in date,
291 p_validation_end_date in date) is
292 --
293 l_proc varchar2(72) := g_package||'post_delete';
294 --
295 Begin
296 hr_utility.set_location('Entering:'||l_proc, 5);
297 --
298 ghr_dut_rkd.after_delete(
299 p_duty_station_id => p_rec.duty_station_id
300 ,p_object_version_number => p_rec. object_version_number
301 );
302 hr_utility.set_location(' Leaving:'||l_proc, 10);
303 End post_delete;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< del >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure del
309 (
310 p_rec in out nocopy ghr_dut_shd.g_rec_type,
311 p_effective_date in date,
312 p_datetrack_mode in varchar2
313 ) is
314 --
315 l_proc varchar2(72) := g_package||'del';
316 l_validation_start_date date;
317 l_validation_end_date date;
318 --
319 Begin
320 hr_utility.set_location('Entering:'||l_proc, 5);
321 --
322 -- Ensure that the DateTrack delete mode is valid
323 --
324 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
325 --
326 -- We must lock the row which we need to delete.
327 --
328 ghr_dut_shd.lck
329 (p_effective_date => p_effective_date,
330 p_datetrack_mode => p_datetrack_mode,
331 p_duty_station_id => p_rec.duty_station_id,
332 p_object_version_number => p_rec.object_version_number,
333 p_validation_start_date => l_validation_start_date,
334 p_validation_end_date => l_validation_end_date);
335 --
336 -- Call the supporting delete validate operation
337 --
338 ghr_dut_bus.delete_validate
339 (p_rec => p_rec,
340 p_effective_date => p_effective_date,
341 p_datetrack_mode => p_datetrack_mode,
342 p_validation_start_date => l_validation_start_date,
343 p_validation_end_date => l_validation_end_date);
344
345 --
346 -- Call the supporting pre-delete operation
347 --
348 pre_delete
349 (p_rec => p_rec,
350 p_effective_date => p_effective_date,
351 p_datetrack_mode => p_datetrack_mode,
352 p_validation_start_date => l_validation_start_date,
353 p_validation_end_date => l_validation_end_date);
354 --
355 -- Delete the row.
356 --
357 delete_dml
358 (p_rec => p_rec,
359 p_effective_date => p_effective_date,
360 p_datetrack_mode => p_datetrack_mode,
361 p_validation_start_date => l_validation_start_date,
362 p_validation_end_date => l_validation_end_date);
363 --
364 -- Call the supporting post-delete operation
365 --
366 post_delete
367 (p_rec => p_rec,
368 p_effective_date => p_effective_date,
369 p_datetrack_mode => p_datetrack_mode,
370 p_validation_start_date => l_validation_start_date,
371 p_validation_end_date => l_validation_end_date);
372 End del;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------------< del >----------------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure del
378 (
379 p_duty_station_id in number,
380 p_effective_start_date out nocopy date,
381 p_effective_end_date out nocopy date,
382 p_object_version_number in number,
383 p_effective_date in date,
384 p_datetrack_mode in varchar2
385 ) is
386 --
387 l_rec ghr_dut_shd.g_rec_type;
388 l_proc varchar2(72) := g_package||'del';
389 --
390 Begin
391 hr_utility.set_location('Entering:'||l_proc, 5);
392 --
393 -- As the delete procedure accepts a plsql record structure we do need to
394 -- convert the arguments into the record structure.
395 -- We don't need to call the supplied conversion argument routine as we
396 -- only need a few attributes.
397 --
398 l_rec.duty_station_id := p_duty_station_id;
399 l_rec.object_version_number := p_object_version_number;
400 --
401 -- Having converted the arguments into the ghr_dut_rec
402 -- plsql record structure we must call the corresponding entity
403 -- business process
404 --
405 del(l_rec, p_effective_date, p_datetrack_mode);
406 --
407 -- Set the out arguments
408 --
409 p_effective_start_date := l_rec.effective_start_date;
410 p_effective_end_date := l_rec.effective_end_date;
411 --
412 hr_utility.set_location(' Leaving:'||l_proc, 10);
413 End del;
414 --
415 end ghr_dut_del;