1 PACKAGE BODY hr_loc_del AS
2 /* $Header: hrlocrhi.pkb 120.11.12020000.2 2012/07/04 23:08:51 amnaraya ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package VARCHAR2(33) := ' hr_loc_del.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< delete_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml delete logic. The functions of
17 -- this procedure are as follows:
18 -- 1) To set and unset the g_api_dml status as required (as we are about to
19 -- perform dml).
20 -- 2) To delete the specified row from the schema using the primary key in
21 -- the predicates.
22 -- 3) To trap any constraint violations that may have occurred.
23 -- 4) To raise any other errors.
24 --
25 -- Pre Conditions:
26 -- This is an internal private procedure which must be called from the del
27 -- procedure.
28 --
29 -- In Parameters:
30 -- A Pl/Sql record structre.
31 --
32 -- Post Success:
33 -- The specified row will be delete from the schema.
34 --
35 -- Post Failure:
36 -- On the delete dml failure it is important to note that we always reset the
37 -- g_api_dml status to false.
38 -- If a child integrity constraint violation is raised the
39 -- constraint_error procedure will be called.
40 -- If any other error is reported, the error will be raised after the
41 -- g_api_dml status is reset.
42 --
43 -- Developer Implementation Notes:
44 -- None.
45 --
46 -- Access Status:
47 -- Internal Table Handler Use Only.
48 --
49 -- {End Of Comments}
50 -- ----------------------------------------------------------------------------
51 PROCEDURE delete_dml(p_rec IN hr_loc_shd.g_rec_type) IS
52 --
53 l_proc VARCHAR2(72) := g_package||'delete_dml';
54 --
55 BEGIN
56 hr_utility.set_location('Entering:'||l_proc, 5);
57 --
58 hr_loc_shd.g_api_dml := true; -- Set the api dml status
59 --
60 -- Delete the location row.
61 --
62 DELETE FROM hr_locations_all
63 WHERE location_id = p_rec.location_id;
64 --
65 hr_loc_shd.g_api_dml := false; -- Unset the api dml status
66 --
67 hr_utility.set_location(' Leaving:'||l_proc, 10);
68 --
69 EXCEPTION
70 WHEN hr_api.child_integrity_violated THEN
71 -- Child integrity has been violated
72 hr_loc_shd.g_api_dml := false; -- Unset the api dml status
73 hr_loc_shd.constraint_error
74 (p_constraint_name => hr_api.strip_constraint_name(sqlerrm));
75 WHEN OTHERS THEN
76 hr_loc_shd.g_api_dml := false; -- Unset the api dml status
77 RAISE;
78 END delete_dml;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |------------------------------< pre_delete >------------------------------|
82 -- ----------------------------------------------------------------------------
83 -- {Start Of Comments}
84 --
85 -- Description:
86 -- This private procedure contains any processing which is required before
87 -- the delete dml.
88 --
89 -- Pre Conditions:
90 -- This is an internal procedure which is called from the del procedure.
91 --
92 -- In Parameters:
93 -- A Pl/Sql record structre.
94 --
95 -- Post Success:
96 -- Processing continues.
97 --
98 -- Post Failure:
99 -- If an error has occurred, an error message and exception will be raised
100 -- but not handled.
101 --
102 -- Developer Implementation Notes:
103 -- Any pre-processing required before the delete dml is issued should be
104 -- coded within this procedure. It is important to note that any 3rd party
105 -- maintenance should be reviewed before placing in this procedure.
106 --
107 -- Access Status:
108 -- Internal Table Handler Use Only.
109 --
110 -- {End Of Comments}
111 -- ----------------------------------------------------------------------------
112 PROCEDURE pre_delete(p_rec IN hr_loc_shd.g_rec_type) IS
113 --
114 l_proc VARCHAR2(72) := g_package||'pre_delete';
115 --
116 BEGIN
117 hr_utility.set_location('Entering:'||l_proc, 5);
118 --
119 hr_utility.set_location(' Leaving:'||l_proc, 10);
120 END pre_delete;
121 --
122 -- ----------------------------------------------------------------------------
123 -- |-----------------------------< post_delete >------------------------------|
124 -- ----------------------------------------------------------------------------
125 -- {Start Of Comments}
126 --
127 -- Description:
128 -- This private procedure contains any processing which is required after the
129 -- delete dml.
130 --
131 -- Pre Conditions:
132 -- This is an internal procedure which is called from the del procedure.
133 --
134 -- In Parameters:
135 -- A Pl/Sql record structre.
136 --
137 -- Post Success:
138 -- Processing continues.
139 --
140 -- Post Failure:
141 -- If an error has occurred, an error message and exception will be raised
142 -- but not handled.
143 --
144 -- Developer Implementation Notes:
145 -- Any post-processing required after the delete dml is issued should be
146 -- coded within this procedure. It is important to note that any 3rd party
147 -- maintenance should be reviewed before placing in this procedure.
148 --
149 -- Access Status:
150 -- Internal table Handler Use Only.
151 --
152 -- {End Of Comments}
153 -- ----------------------------------------------------------------------------
154 PROCEDURE post_delete(p_rec IN hr_loc_shd.g_rec_type) IS
155 --
156 l_proc VARCHAR2(72) := g_package||'post_delete';
157 --
158 BEGIN
159 hr_utility.set_location('Entering:'||l_proc, 5);
160 --
161 --
162 -- Start of API User Hook for the after delete hook
163 --
164 hr_loc_rkd.after_delete
165 ( p_location_id => p_rec.location_id
166 --
167 ,p_location_code_o => hr_loc_shd.g_old_rec.location_code
168 ,p_address_line_1_o => hr_loc_shd.g_old_rec.address_line_1
169 ,p_address_line_2_o => hr_loc_shd.g_old_rec.address_line_2
170 ,p_address_line_3_o => hr_loc_shd.g_old_rec.address_line_3
171 ,p_bill_to_site_flag_o => hr_loc_shd.g_old_rec.bill_to_site_flag
172 ,p_country_o => hr_loc_shd.g_old_rec.country
173 ,p_description_o => hr_loc_shd.g_old_rec.description
174 ,p_designated_receiver_id_o => hr_loc_shd.g_old_rec.designated_receiver_id
175 ,p_in_organization_flag_o => hr_loc_shd.g_old_rec.in_organization_flag
176 ,p_inactive_date_o => hr_loc_shd.g_old_rec.inactive_date
177 ,p_inventory_organization_id_o => hr_loc_shd.g_old_rec.inventory_organization_id
178 ,p_office_site_flag_o => hr_loc_shd.g_old_rec.office_site_flag
179 ,p_postal_code_o => hr_loc_shd.g_old_rec.postal_code
180 ,p_receiving_site_flag_o => hr_loc_shd.g_old_rec.receiving_site_flag
181 ,p_region_1_o => hr_loc_shd.g_old_rec.region_1
182 ,p_region_2_o => hr_loc_shd.g_old_rec.region_2
183 ,p_region_3_o => hr_loc_shd.g_old_rec.region_3
184 ,p_ship_to_location_id_o => hr_loc_shd.g_old_rec.ship_to_location_id
185 ,p_ship_to_site_flag_o => hr_loc_shd.g_old_rec.ship_to_site_flag
186 ,p_style_o => hr_loc_shd.g_old_rec.style
187 ,p_tax_name_o => hr_loc_shd.g_old_rec.tax_name
188 ,p_telephone_number_1_o => hr_loc_shd.g_old_rec.telephone_number_1
189 ,p_telephone_number_2_o => hr_loc_shd.g_old_rec.telephone_number_2
190 ,p_telephone_number_3_o => hr_loc_shd.g_old_rec.telephone_number_3
191 ,p_town_or_city_o => hr_loc_shd.g_old_rec.town_or_city
192 ,p_loc_information13_o => hr_loc_shd.g_old_rec.loc_information13
193 ,p_loc_information14_o => hr_loc_shd.g_old_rec.loc_information14
194 ,p_loc_information15_o => hr_loc_shd.g_old_rec.loc_information15
195 ,p_loc_information16_o => hr_loc_shd.g_old_rec.loc_information16
196 ,p_loc_information17_o => hr_loc_shd.g_old_rec.loc_information17
197 ,p_loc_information18_o => hr_loc_shd.g_old_rec.loc_information18
198 ,p_loc_information19_o => hr_loc_shd.g_old_rec.loc_information19
199 ,p_loc_information20_o => hr_loc_shd.g_old_rec.loc_information20
200 ,p_attribute_category_o => hr_loc_shd.g_old_rec.attribute_category
201 ,p_attribute1_o => hr_loc_shd.g_old_rec.attribute1
202 ,p_attribute2_o => hr_loc_shd.g_old_rec.attribute2
203 ,p_attribute3_o => hr_loc_shd.g_old_rec.attribute3
204 ,p_attribute4_o => hr_loc_shd.g_old_rec.attribute4
205 ,p_attribute5_o => hr_loc_shd.g_old_rec.attribute5
206 ,p_attribute6_o => hr_loc_shd.g_old_rec.attribute6
207 ,p_attribute7_o => hr_loc_shd.g_old_rec.attribute7
208 ,p_attribute8_o => hr_loc_shd.g_old_rec.attribute8
209 ,p_attribute9_o => hr_loc_shd.g_old_rec.attribute9
210 ,p_attribute10_o => hr_loc_shd.g_old_rec.attribute10
211 ,p_attribute11_o => hr_loc_shd.g_old_rec.attribute11
212 ,p_attribute12_o => hr_loc_shd.g_old_rec.attribute12
213 ,p_attribute13_o => hr_loc_shd.g_old_rec.attribute13
214 ,p_attribute14_o => hr_loc_shd.g_old_rec.attribute14
215 ,p_attribute15_o => hr_loc_shd.g_old_rec.attribute15
216 ,p_attribute16_o => hr_loc_shd.g_old_rec.attribute16
217 ,p_attribute17_o => hr_loc_shd.g_old_rec.attribute17
218 ,p_attribute18_o => hr_loc_shd.g_old_rec.attribute18
219 ,p_attribute19_o => hr_loc_shd.g_old_rec.attribute19
220 ,p_attribute20_o => hr_loc_shd.g_old_rec.attribute20
221 ,p_global_attribute_category_o => hr_loc_shd.g_old_rec.global_attribute_category
222 ,p_global_attribute1_o => hr_loc_shd.g_old_rec.global_attribute1
223 ,p_global_attribute2_o => hr_loc_shd.g_old_rec.global_attribute2
224 ,p_global_attribute3_o => hr_loc_shd.g_old_rec.global_attribute3
225 ,p_global_attribute4_o => hr_loc_shd.g_old_rec.global_attribute4
226 ,p_global_attribute5_o => hr_loc_shd.g_old_rec.global_attribute5
227 ,p_global_attribute6_o => hr_loc_shd.g_old_rec.global_attribute6
228 ,p_global_attribute7_o => hr_loc_shd.g_old_rec.global_attribute7
229 ,p_global_attribute8_o => hr_loc_shd.g_old_rec.global_attribute8
230 ,p_global_attribute9_o => hr_loc_shd.g_old_rec.global_attribute9
231 ,p_global_attribute10_o => hr_loc_shd.g_old_rec.global_attribute10
232 ,p_global_attribute11_o => hr_loc_shd.g_old_rec.global_attribute11
233 ,p_global_attribute12_o => hr_loc_shd.g_old_rec.global_attribute12
234 ,p_global_attribute13_o => hr_loc_shd.g_old_rec.global_attribute13
235 ,p_global_attribute14_o => hr_loc_shd.g_old_rec.global_attribute14
236 ,p_global_attribute15_o => hr_loc_shd.g_old_rec.global_attribute15
237 ,p_global_attribute16_o => hr_loc_shd.g_old_rec.global_attribute16
238 ,p_global_attribute17_o => hr_loc_shd.g_old_rec.global_attribute17
239 ,p_global_attribute18_o => hr_loc_shd.g_old_rec.global_attribute18
240 ,p_global_attribute19_o => hr_loc_shd.g_old_rec.global_attribute19
241 ,p_global_attribute20_o => hr_loc_shd.g_old_rec.global_attribute20
242 ,p_legal_address_flag_o => hr_loc_shd.g_old_rec.legal_address_flag
243 ,p_tp_header_id_o => hr_loc_shd.g_old_rec.tp_header_id
244 ,p_ece_tp_location_code_o => hr_loc_shd.g_old_rec.ece_tp_location_code
245 ,p_object_version_number_o => hr_loc_shd.g_old_rec.object_version_number
246 ,p_business_group_id_o => hr_loc_shd.g_old_rec.business_group_id
247 );
248 EXCEPTION
249 WHEN hr_api.cannot_find_prog_unit THEN
250 hr_api.cannot_find_prog_unit_error
251 (p_module_name => 'HR_LOCATIONS_ALL'
252 ,p_hook_type => 'AD'
253 );
254 --
255 -- End of API User Hook for the after_delete hook
256 --
257 --
258 hr_utility.set_location(' Leaving:'||l_proc, 10);
259 END post_delete;
260 --
261 -- ----------------------------------------------------------------------------
262 -- |---------------------------------< del >----------------------------------|
263 -- ----------------------------------------------------------------------------
264 -- {Start Of Comments}
265 --
266 -- Description:
267 -- This procedure is the record interface for the delete process
268 -- for the specified entity. The role of this process is to delete the
269 -- row from the HR schema. This process is the main backbone of the del
270 -- business process. The processing of this procedure is as follows:
271 --
272 -- 1) The controlling validation process delete_validate is then executed
273 -- which will execute all private and public validation business rule
274 -- processes.
275 -- 2) The pre_delete process is then executed which enables any
276 -- logic to be processed before the delete dml process is executed.
277 -- 3) The delete_dml process will physical perform the delete dml for the
278 -- specified row.
279 -- 4) The post_delete process is then executed which enables any
280 -- logic to be processed after the delete dml process.
281 --
282 -- Pre Conditions:
283 -- The main parameters to the business process have to be in the record
284 -- format.
285 --
286 -- In Parameters:
287 --
288 -- Post Success:
289 -- The specified row will be fully validated and deleted for the specified
290 -- entity without being committed.
291 --
292 -- Post Failure:
293 -- If an error has occurred, an error message will be supplied with the work
294 -- rolled back.
295 --
296 -- Developer Implementation Notes:
297 -- None.
298 --
299 -- Access Status:
300 -- Internal Development Use Only.
301 --
302 -- {End Of Comments}
303 -- ----------------------------------------------------------------------------
304 --
305 PROCEDURE del
306 (
307 p_rec IN hr_loc_shd.g_rec_type
308 ) IS
309 --
310 l_proc VARCHAR2(72) := g_package||'del';
311 --
312 BEGIN
313 hr_utility.set_location('Entering:'||l_proc, 5);
314 --
315 -- We must lock the row which we need to delete.
316 --
317 hr_loc_shd.lck ( p_rec.location_id,
318 p_rec.object_version_number );
319 hr_utility.set_location(l_proc, 10);
320 --
321 -- Call the supporting delete validate operation
322 --
323 hr_loc_bus.delete_validate( p_rec => p_rec );
324 hr_utility.set_location(l_proc, 15);
325 --
326 -- Call the supporting pre-delete operation
327 --
328 pre_delete(p_rec);
329 hr_utility.set_location(l_proc, 20);
330 --
331 -- Delete the row.
332 --
333 delete_dml(p_rec);
334 hr_utility.set_location(l_proc, 25);
335 --
336 -- Call the supporting post-delete operation
337 --
338 post_delete(p_rec);
339 --
340 hr_utility.set_location(' Leaving:'||l_proc, 35);
341
342 END del;
343 --
344 -- ----------------------------------------------------------------------------
345 -- |---------------------------------< del >----------------------------------|
346 -- ----------------------------------------------------------------------------
347 -- {Start Of Comments}
348 --
349 -- Description:
350 -- This procedure is the attribute interface for the delete
351 -- process for the specified entity and is the outermost layer. The role
352 -- of this process is to validate and delete the specified row from the
353 -- HR schema. The processing of this procedure is as follows:
354 -- 1) The attributes are converted into a local record structure by
355 -- explicitly coding the attribute parameters into the g_rec_type
356 -- datatype.
357 -- 2) After the conversion has taken place, the corresponding record del
358 -- interface process is executed.
359 --
360 -- Pre Conditions:
361 --
362 -- In Parameters:
363
364 -- Post Success:
365 -- The specified row will be fully validated and deleted for the specified
366 -- entity without being committed
367 --
368 -- Post Failure:
369 -- If an error has occurred, an error message will be supplied with the work
370 -- rolled back.
371 --
372 -- Developer Implementation Notes:
373 -- The attrbute in parameters should be modified as to the business process
374 -- requirements.
375 --
376 -- Access Status:
377 -- Internal Development Use Only.
378 --
379 -- {End Of Comments}
380 -- ----------------------------------------------------------------------------
381 --
382 PROCEDURE del
383 (
384 p_location_id IN NUMBER,
385 p_object_version_number IN NUMBER
386 ) IS
387 --
388 l_rec hr_loc_shd.g_rec_type;
389 l_proc VARCHAR2(72) := g_package||'del';
390 --
391 BEGIN
392 hr_utility.set_location('Entering:'||l_proc, 5);
393 --
394 -- As the delete procedure accepts a plsql record structure we do need to
395 -- convert the arguments into the record structure.
396 -- We don't need to call the supplied conversion argument routine as we
397 -- only need a few attributes.
398 --
399 l_rec.location_id := p_location_id;
400 l_rec.object_version_number := p_object_version_number;
401 --
402 -- Having converted the arguments into the hr_loc_rec
403 -- plsql record structure we must call the corresponding entity
404 -- business process
405 --
406 del(p_rec => l_rec );
407 --
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 END del;
410 --
411 END hr_loc_del;