DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RLS_DEL

Source


1 Package Body pqh_rls_del as
2 /* $Header: pqrlsrhi.pkb 120.0.12020000.2 2013/04/12 18:48:44 pathota ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
11 -- |------------------------------< delete_dml >------------------------------|
8 g_package  varchar2(33)	:= '  pqh_rls_del.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
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 -- Prerequisites:
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 Row Handler Use Only.
48 --
49 -- {End Of Comments}
50 -- ----------------------------------------------------------------------------
51 Procedure delete_dml
52   ( p_rec in pqh_rls_shd.g_rec_type
53   ) is
54 --
55   l_proc  varchar2(72) := g_package||'delete_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc,5);
59   --
60   --
61   --
62   -- Delete the pqh_roles row.
63   --
64   delete from pqh_roles
65   where role_id = p_rec.role_id;
66   --
67   --
68   --
69   hr_utility.set_location(' Leaving:'||l_proc,10);
70 --
71 Exception
72   When hr_api.child_integrity_violated then
73     -- Child integrity has been violated
74     --
75     pqh_rls_shd.constraint_error
76       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
77   When Others Then
78     --
79     Raise;
80 End delete_dml;
81 --
82 -- ----------------------------------------------------------------------------
83 -- |------------------------------< pre_delete >------------------------------|
84 -- ----------------------------------------------------------------------------
85 -- {Start Of Comments}
86 --
87 -- Description:
88 --   This private procedure contains any processing which is required before
89 --   the delete dml.
90 --
91 -- Prerequisites:
92 --   This is an internal procedure which is called from the del procedure.
93 --
94 -- In Parameters:
95 --   A Pl/Sql record structre.
96 --
97 -- Post Success:
98 --   Processing continues.
99 --
100 -- Post Failure:
101 --   If an error has occurred,an error message and exception will be raised
102 --   but not handled.
103 --
104 -- Developer Implementation Notes:
105 --   Any pre-processing required before the delete dml is issued should be
106 --   coded within this procedure. It is important to note that any 3rd party
107 --   maintenance should be reviewed before placing in this procedure.
108 --
109 -- Access Status:
110 --   Internal Row Handler Use Only.
111 --
112 -- {End Of Comments}
113 -- ----------------------------------------------------------------------------
114 Procedure pre_delete( p_rec in pqh_rls_shd.g_rec_type) is
115 --
116   l_proc  varchar2(72) := g_package||'pre_delete';
117 --
118 Begin
119   hr_utility.set_location('Entering:'||l_proc,5);
120   --
121   hr_utility.set_location(' Leaving:'||l_proc,10);
122 End pre_delete;
123 --
124 -- ----------------------------------------------------------------------------
125 -- |-----------------------------< post_delete >------------------------------|
126 -- ----------------------------------------------------------------------------
127 -- {Start Of Comments}
128 --
129 -- Description:
130 --   This private procedure contains any processing which is required after the
131 --   delete dml.
132 --
133 -- Prerequistes:
134 --   This is an internal procedure which is called from the del procedure.
135 --
136 -- In Parameters:
137 --   A Pl/Sql record structure.
138 --
139 -- Post Success:
140 --   Processing continues.
141 --
142 -- Post Failure:
143 --   If an error has occurred,an error message and exception will be raised
144 --   but not handled.
145 --
146 -- Developer Implementation Notes:
147 --   Any post-processing required after the delete dml is issued should be
148 --   coded within this procedure. It is important to note that any 3rd party
149 --   maintenance should be reviewed before placing in this procedure.
150 --
151 -- Access Status:
152 --   Internal Row Handler Use Only.
153 --
154 -- {End Of Comments}
155 -- -----------------------------------------------------------------------------
156 -- mvanakda
157 -- Added Developer DF Columns
158 Procedure post_delete( p_rec in pqh_rls_shd.g_rec_type) is
159 --
160   l_proc  varchar2(72) := g_package||'post_delete';
161   l_start_date         date := trunc(sysdate);
162 --
163 Begin
164   hr_utility.set_location('Entering:'||l_proc,5);
165     begin
166     --
167 
168 
169     pqh_rls_rkd.after_delete
170       (p_role_id                  => p_rec.role_id
171       ,p_role_name_o              => pqh_rls_shd.g_old_rec.role_name
172       ,p_role_type_cd_o           => pqh_rls_shd.g_old_rec.role_type_cd
173       ,p_enable_flag_o            => pqh_rls_shd.g_old_rec.enable_flag
174       ,p_object_version_number_o  => pqh_rls_shd.g_old_rec.object_version_number
175       ,p_business_group_id_o      => pqh_rls_shd.g_old_rec.business_group_id
176       ,p_information_category_o   => pqh_rls_shd.g_old_rec.information_category
177       ,p_information1_o	          => pqh_rls_shd.g_old_rec.information1
178       ,p_information2_o	          => pqh_rls_shd.g_old_rec.information2
179       ,p_information3_o	          => pqh_rls_shd.g_old_rec.information3
180       ,p_information4_o	          => pqh_rls_shd.g_old_rec.information4
181       ,p_information5_o	          => pqh_rls_shd.g_old_rec.information5
182       ,p_information6_o	          => pqh_rls_shd.g_old_rec.information6
183       ,p_information7_o	          => pqh_rls_shd.g_old_rec.information7
184       ,p_information8_o	          => pqh_rls_shd.g_old_rec.information8
185       ,p_information9_o	          => pqh_rls_shd.g_old_rec.information9
186       ,p_information10_o	  => pqh_rls_shd.g_old_rec.information10
187       ,p_information11_o	  => pqh_rls_shd.g_old_rec.information11
188       ,p_information12_o	  => pqh_rls_shd.g_old_rec.information12
189       ,p_information13_o	  => pqh_rls_shd.g_old_rec.information13
190       ,p_information14_o	  => pqh_rls_shd.g_old_rec.information14
191       ,p_information15_o	  => pqh_rls_shd.g_old_rec.information15
192       ,p_information16_o	  => pqh_rls_shd.g_old_rec.information16
193       ,p_information17_o	  => pqh_rls_shd.g_old_rec.information17
194       ,p_information18_o	  => pqh_rls_shd.g_old_rec.information18
195       ,p_information19_o	  => pqh_rls_shd.g_old_rec.information19
196       ,p_information20_o	  => pqh_rls_shd.g_old_rec.information20
197       ,p_information21_o	  => pqh_rls_shd.g_old_rec.information21
198       ,p_information22_o	  => pqh_rls_shd.g_old_rec.information22
199       ,p_information23_o	  => pqh_rls_shd.g_old_rec.information23
200       ,p_information24_o	  => pqh_rls_shd.g_old_rec.information24
201       ,p_information25_o	  => pqh_rls_shd.g_old_rec.information25
202       ,p_information26_o	  => pqh_rls_shd.g_old_rec.information26
203       ,p_information27_o	  => pqh_rls_shd.g_old_rec.information27
204       ,p_information28_o	  => pqh_rls_shd.g_old_rec.information28
205       ,p_information29_o	  => pqh_rls_shd.g_old_rec.information29
206       ,p_information30_o	  => pqh_rls_shd.g_old_rec.information30
207       );
208     --
209     if nvl(pqh_rls_shd.g_old_rec.enable_flag,'N') = 'Y'
210         then
211     declare
212       l_plist wf_parameter_list_t;
213       --
214       cursor c0 is
215       select *
216       from wf_local_user_roles
217       where ROLE_ORIG_SYSTEM = 'PQH_ROLE'
218       and ROLE_ORIG_SYSTEM_ID = p_rec.role_id;
219       --
220     begin
221      l_plist := null;
222      wf_event.AddParameterToList(
223            p_name => 'user_name',
224            p_value => 'PQH_ROLE:'|| p_rec.role_id,
225            p_parameterlist => l_plist);
226       wf_event.AddParameterToList(
227            p_name => 'DELETE',
228            p_value => 'TRUE',
229            p_parameterlist => l_plist);
230      for r1 in c0 loop
231       WF_LOCAL_SYNCH.propagate_user_role(p_user_orig_system      => 'PER',
232                               p_user_orig_system_id   => r1.user_orig_system_id,
233                               p_role_orig_system      => 'PQH_ROLE',
234                               p_role_orig_system_id   => p_rec.role_id,
235                               p_expiration_date       => l_start_date);
236      end loop;
237 
238      l_plist := null;
239      wf_event.AddParameterToList(
240            p_name => 'user_name',
241            p_value => 'PQH_ROLE:'|| p_rec.role_id,
242            p_parameterlist => l_plist);
243      wf_event.AddParameterToList(
244            p_name => 'DELETE',
245            p_value => 'TRUE',
246            p_parameterlist => l_plist);
247 
248      WF_LOCAL_SYNCH.propagate_role(p_orig_system     => 'PQH_ROLE',
249                                    p_orig_system_id  => p_rec.role_id,
250                                    p_attributes      => l_plist,
251                                    p_expiration_date => l_start_date);
252 
253     Wf_Directory.DeleteRole ( p_name         => 'PQH_ROLE:'|| p_rec.role_id,
254 		              p_origSystem   => 'PQH_ROLE',
255 		              p_origSystemID => p_rec.role_id);
256 
257     end;
258     --
259     end if;
260   exception
261     --
262     when hr_api.cannot_find_prog_unit then
263       --
264       hr_api.cannot_find_prog_unit_error
265         (p_module_name => 'PQH_ROLES'
266         ,p_hook_type   => 'AD');
267       --
268   end;
269   --
270   hr_utility.set_location(' Leaving:'||l_proc,10);
271 End post_delete;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |---------------------------------< del >----------------------------------|
275 -- ----------------------------------------------------------------------------
276 Procedure del
277   (  p_effective_date in date, p_rec	      in pqh_rls_shd.g_rec_type
278   ) is
279 --
280   l_proc  varchar2(72) := g_package||'del';
281 --
282 Begin
283   hr_utility.set_location('Entering:'||l_proc, 5);
284   --
285   -- We must lock the row which we need to delete.
286   --
287   pqh_rls_shd.lck
288     (p_rec.role_id
289     ,p_rec.object_version_number
290     );
291   --
292   -- Call the supporting delete validate operation
293   --
294   pqh_rls_bus.delete_validate(p_rec, p_effective_date);
295   --
296   -- Call the supporting pre-delete operation
297   --
298   pqh_rls_del.pre_delete(p_rec);
299   --
300   -- Delete the row.
301   --
302   pqh_rls_del.delete_dml(p_rec);
303   --
304   -- Call the supporting post-delete operation
305   --
306   pqh_rls_del.post_delete(p_rec);
307   --
308 End del;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |---------------------------------< del >----------------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure del
314   (p_effective_date			  in 	date
315   ,p_role_id                              in     number
316   ,p_object_version_number                in     number
317   ) is
318 --
319   l_rec	  pqh_rls_shd.g_rec_type;
320   l_proc  varchar2(72) := g_package||'del';
321 --
322 Begin
323   hr_utility.set_location('Entering:'||l_proc, 5);
324   --
325   -- As the delete procedure accepts a plsql record structure we do need to
326   -- convert the  arguments into the record structure.
327   -- We don't need to call the supplied conversion argument routine as we
328   -- only need a few attributes.
329   --
330   l_rec.role_id := p_role_id;
331   l_rec.object_version_number := p_object_version_number;
332   --
333   -- Having converted the arguments into the pqh_rls_rec
334   -- plsql record structure we must call the corresponding entity
335   -- business process
336   --
337   pqh_rls_del.del(p_effective_date,l_rec);
338   --
339   hr_utility.set_location(' Leaving:'||l_proc, 10);
340 End del;
341 --
342 end pqh_rls_del;