1 Package Body ghr_evh_del as
2 /* $Header: ghevhrhi.pkb 120.0.12010000.3 2009/05/27 05:37:26 utokachi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_evh_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 -- 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(p_rec in ghr_evh_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 ghr_evh_shd.g_api_dml := true; -- Set the api dml status
59 --
60 -- Delete the ghr_event_history row.
61 --
62 delete from ghr_event_history
63 where event_history_id = p_rec.event_history_id;
64 --
65 ghr_evh_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 ghr_evh_shd.g_api_dml := false; -- Unset the api dml status
73 ghr_evh_shd.constraint_error
74 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
75 When Others Then
76 ghr_evh_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 -- Prerequisites:
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 Row Handler Use Only.
109 --
110 -- {End Of Comments}
111 -- ----------------------------------------------------------------------------
112 Procedure pre_delete(p_rec in ghr_evh_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 -- Prerequisites:
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 ghr_evh_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 post_delete.
163 --
164 begin
165 --
166 ghr_evh_rkd.after_delete
167 (
168 p_event_history_id =>p_rec.event_history_id
169 ,p_event_id_o =>ghr_evh_shd.g_old_rec.event_id
170 ,p_table_name_o =>ghr_evh_shd.g_old_rec.table_name
171 ,p_record_id_o =>ghr_evh_shd.g_old_rec.record_id
172 ,p_start_date_o =>ghr_evh_shd.g_old_rec.start_date
173 ,p_end_date_o =>ghr_evh_shd.g_old_rec.end_date
174 ,p_comments_o =>ghr_evh_shd.g_old_rec.comments
175 ,p_object_version_number_o =>ghr_evh_shd.g_old_rec.object_version_number
176 );
177 --
178 exception
179 --
180 when hr_api.cannot_find_prog_unit then
181 --
182 hr_api.cannot_find_prog_unit_error
183 (p_module_name => 'ghr_event_history'
184 ,p_hook_type => 'AD');
185 --
186 end;
187 --
188 -- End of API User Hook for post_delete.
189 --
190 --
191 hr_utility.set_location(' Leaving:'||l_proc, 10);
192 End post_delete;
193 --
194 -- ----------------------------------------------------------------------------
195 -- |---------------------------------< del >----------------------------------|
196 -- ----------------------------------------------------------------------------
197 Procedure del
198 (
199 p_rec in ghr_evh_shd.g_rec_type
200 ) is
201 --
202 l_proc varchar2(72) := g_package||'del';
203 --
204 Begin
205 hr_utility.set_location('Entering:'||l_proc, 5);
206 --
207 -- We must lock the row which we need to delete.
208 --
209 ghr_evh_shd.lck
210 (
211 p_rec.event_history_id,
212 p_rec.object_version_number
213 );
214 --
215 -- Call the supporting delete validate operation
216 --
217 ghr_evh_bus.delete_validate(p_rec);
218 --
219 -- Call the supporting pre-delete operation
220 --
221 pre_delete(p_rec);
222 --
223 -- Delete the row.
224 --
225 delete_dml(p_rec);
226 --
227 -- Call the supporting post-delete operation
228 --
229 post_delete(p_rec);
230 End del;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |---------------------------------< del >----------------------------------|
234 -- ----------------------------------------------------------------------------
235 Procedure del
236 (
237 p_event_history_id in number,
238 p_object_version_number in number
239 ) is
240 --
241 l_rec ghr_evh_shd.g_rec_type;
242 l_proc varchar2(72) := g_package||'del';
243 --
244 Begin
245 hr_utility.set_location('Entering:'||l_proc, 5);
246 --
247 -- As the delete procedure accepts a plsql record structure we do need to
248 -- convert the arguments into the record structure.
249 -- We don't need to call the supplied conversion argument routine as we
250 -- only need a few attributes.
251 --
252 l_rec.event_history_id:= p_event_history_id;
253 l_rec.object_version_number := p_object_version_number;
254 --
255 -- Having converted the arguments into the ghr_evh_rec
256 -- plsql record structure we must call the corresponding entity
257 -- business process
258 --
259 del(l_rec);
260 --
261 hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End del;
263 --
264 end ghr_evh_del;