DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ADD_DEL

Source


1 Package Body per_add_del as
2 /* $Header: peaddrhi.pkb 120.1.12010000.3 2008/08/06 08:53:04 ubhat ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_add_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 this
17 --   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 Arguments:
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 out nocopy per_add_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   per_add_shd.g_api_dml := true;  -- Set the api dml status
59   --
60   -- Delete the per_addresses row.
61   --
62   delete from per_addresses
63   where address_id = p_rec.address_id;
64   --
65   per_add_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     per_add_shd.g_api_dml := false;   -- Unset the api dml status
73     per_add_shd.constraint_error
74       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
75   When Others Then
76     per_add_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 Arguments:
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  per_add_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 Arguments:
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 per_add_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   -- Start of API User Hook for post_delete.
162   begin
163     per_add_rkd.after_delete
164       (p_address_id                   => p_rec.address_id
165       ,p_business_group_id_o
166 	  => per_add_shd.g_old_rec.business_group_id
167       ,p_date_from_o
168           => per_add_shd.g_old_rec.date_from
169       ,p_address_line1_o
170           => per_add_shd.g_old_rec.address_line1
171       ,p_address_line2_o
172           => per_add_shd.g_old_rec.address_line2
173       ,p_address_line3_o
174           => per_add_shd.g_old_rec.address_line3
175       ,p_address_type_o
176           => per_add_shd.g_old_rec.address_type
177       ,p_comments_o
178           => per_add_shd.g_old_rec.comments
179       ,p_country_o
180           => per_add_shd.g_old_rec.country
181       ,p_date_to_o
182           => per_add_shd.g_old_rec.date_to
183       ,p_postal_code_o
184           => per_add_shd.g_old_rec.postal_code
185       ,p_region_1_o
186           => per_add_shd.g_old_rec.region_1
187       ,p_region_2_o
188           => per_add_shd.g_old_rec.region_2
189       ,p_region_3_o
190           => per_add_shd.g_old_rec.region_3
191       ,p_telephone_number_1_o
192           => per_add_shd.g_old_rec.telephone_number_1
193       ,p_telephone_number_2_o
194           => per_add_shd.g_old_rec.telephone_number_2
195       ,p_telephone_number_3_o
196           => per_add_shd.g_old_rec.telephone_number_3
197       ,p_town_or_city_o
198           => per_add_shd.g_old_rec.town_or_city
199       ,p_request_id_o
200           => per_add_shd.g_old_rec.request_id
201       ,p_program_application_id_o
202           => per_add_shd.g_old_rec.program_application_id
203       ,p_program_id_o
204           => per_add_shd.g_old_rec.program_id
205       ,p_program_update_date_o
206           => per_add_shd.g_old_rec.program_update_date
207       ,p_addr_attribute_category_o
208           => per_add_shd.g_old_rec.addr_attribute_category
209       ,p_addr_attribute1_o
210           => per_add_shd.g_old_rec.addr_attribute1
211       ,p_addr_attribute2_o
212           => per_add_shd.g_old_rec.addr_attribute2
213       ,p_addr_attribute3_o
214           => per_add_shd.g_old_rec.addr_attribute3
215       ,p_addr_attribute4_o
216           => per_add_shd.g_old_rec.addr_attribute4
217       ,p_addr_attribute5_o
218           => per_add_shd.g_old_rec.addr_attribute5
219       ,p_addr_attribute6_o
220           => per_add_shd.g_old_rec.addr_attribute6
221       ,p_addr_attribute7_o
222           => per_add_shd.g_old_rec.addr_attribute7
223       ,p_addr_attribute8_o
224           => per_add_shd.g_old_rec.addr_attribute8
225       ,p_addr_attribute9_o
226           => per_add_shd.g_old_rec.addr_attribute9
227       ,p_addr_attribute10_o
228           => per_add_shd.g_old_rec.addr_attribute10
229       ,p_addr_attribute11_o
230           => per_add_shd.g_old_rec.addr_attribute11
231       ,p_addr_attribute12_o
232           => per_add_shd.g_old_rec.addr_attribute12
233       ,p_addr_attribute13_o
234           => per_add_shd.g_old_rec.addr_attribute13
235       ,p_addr_attribute14_o
236           => per_add_shd.g_old_rec.addr_attribute14
237       ,p_addr_attribute15_o
238           => per_add_shd.g_old_rec.addr_attribute15
239       ,p_addr_attribute16_o
240           => per_add_shd.g_old_rec.addr_attribute16
241       ,p_addr_attribute17_o
242           => per_add_shd.g_old_rec.addr_attribute17
243       ,p_addr_attribute18_o
244           => per_add_shd.g_old_rec.addr_attribute18
245       ,p_addr_attribute19_o
246           => per_add_shd.g_old_rec.addr_attribute19
247       ,p_addr_attribute20_o
248           => per_add_shd.g_old_rec.addr_attribute20
249       ,p_add_information13_o
250           => per_add_shd.g_old_rec.add_information13
251       ,p_add_information14_o
252           => per_add_shd.g_old_rec.add_information14
253       ,p_add_information15_o
254           => per_add_shd.g_old_rec.add_information15
255       ,p_add_information16_o
256           => per_add_shd.g_old_rec.add_information16
257       ,p_add_information17_o
258           => per_add_shd.g_old_rec.add_information17
259       ,p_add_information18_o
260           => per_add_shd.g_old_rec.add_information18
261       ,p_add_information19_o
262           => per_add_shd.g_old_rec.add_information19
263       ,p_add_information20_o
264           => per_add_shd.g_old_rec.add_information20
265       ,p_object_version_number_o
266           => per_add_shd.g_old_rec.object_version_number
267       );
268   exception
269     when hr_api.cannot_find_prog_unit then
270       hr_api.cannot_find_prog_unit_error
271         (p_module_name => 'PER_ADDRESSES'
272         ,p_hook_type   => 'AD'
273         );
274   end;
275   -- End of API User Hook for post_delete.
276   --
277   hr_utility.set_location(' Leaving:'||l_proc, 10);
278 End post_delete;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------------< del >----------------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure del
284   (
285   p_rec	      in out nocopy per_add_shd.g_rec_type,
286   p_validate  in boolean default false
287   ) is
288 --
289   l_proc  varchar2(72) := g_package||'del';
290 --
291 Begin
292   hr_utility.set_location('Entering:'||l_proc, 5);
293   --
294   -- Determine if the business process is to be validated.
295   --
296   If p_validate then
297     --
298     -- Issue the savepoint.
299     --
300     SAVEPOINT del_per_add;
301   End If;
302   --
303   -- We must lock the row which we need to delete.
304   --
305   per_add_shd.lck
306 	(
307 	p_rec.address_id,
308 	p_rec.object_version_number
309 	);
310   --
311   -- Call the supporting delete validate operation
312   --
313   per_add_bus.delete_validate(p_rec);
314   --
315   -- Call to raise any errors on multi-message list
316   hr_multi_message.end_validation_set;
317   --
318   -- Call the supporting pre-delete operation
319   --
320   pre_delete(p_rec);
321   --
322   -- Delete the row.
323   --
324   delete_dml(p_rec);
325   --
326   -- Call the supporting post-delete operation
327   --
328   post_delete(p_rec);
329   -- Call to raise any errors on multi-message list
330   hr_multi_message.end_validation_set;
331   --
332   -- If we are validating then raise the Validate_Enabled exception
333   --
334   If p_validate then
335     Raise HR_Api.Validate_Enabled;
336   End If;
337   --
338   hr_utility.set_location(' Leaving:'||l_proc, 10);
339 Exception
340   When HR_Api.Validate_Enabled Then
341     --
342     -- As the Validate_Enabled exception has been raised
343     -- we must rollback to the savepoint
344     --
345     ROLLBACK TO del_per_add;
346 End del;
347 --
348 -- ----------------------------------------------------------------------------
349 -- |---------------------------------< del >----------------------------------|
350 -- ----------------------------------------------------------------------------
351 Procedure del
352   (
353   p_address_id                         in number,
354   p_object_version_number              in number,
355   p_validate                           in boolean default false
356   ) is
357 --
358   l_rec	  per_add_shd.g_rec_type;
359   l_proc  varchar2(72) := g_package||'del';
360 --
361 Begin
362   hr_utility.set_location('Entering:'||l_proc, 5);
363   --
364   -- As the delete procedure accepts a plsql record structure we do need to
365   -- convert the  arguments into the record structure.
366   -- We don't need to call the supplied conversion argument routine as we
367   -- only need a few attributes.
368   --
369   l_rec.address_id:= p_address_id;
370   l_rec.object_version_number := p_object_version_number;
371   --
372   -- Having converted the arguments into the per_add_rec
373   -- plsql record structure we must call the corresponding entity
374   -- business process
375   --
376   del(l_rec, p_validate);
377   --
378   hr_utility.set_location(' Leaving:'||l_proc, 10);
379 End del;
380 --
381 end per_add_del;