1 Package Body hr_pft_del as
2 /* $Header: hrpftrhi.pkb 120.0 2005/05/31 02:07:40 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_pft_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
52 (p_rec in hr_pft_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 hr_all_positions_f_tl row.
63 --
64 delete from hr_all_positions_f_tl
65 where position_id = p_rec.position_id
66 and language = p_rec.language;
67 --
68 --
69 --
70 hr_utility.set_location(' Leaving:'||l_proc, 10);
71 --
72 Exception
73 When hr_api.child_integrity_violated then
74 -- Child integrity has been violated
75 --
76 hr_pft_shd.constraint_error
77 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
78 When Others Then
79 --
80 Raise;
81 End delete_dml;
82 --
83 -- ----------------------------------------------------------------------------
84 -- |------------------------------< pre_delete >------------------------------|
85 -- ----------------------------------------------------------------------------
86 -- {Start Of Comments}
87 --
88 -- Description:
89 -- This private procedure contains any processing which is required before
90 -- the delete dml.
91 --
92 -- Prerequisites:
93 -- This is an internal procedure which is called from the del procedure.
94 --
95 -- In Parameters:
96 -- A Pl/Sql record structre.
97 --
98 -- Post Success:
99 -- Processing continues.
100 --
101 -- Post Failure:
102 -- If an error has occurred, an error message and exception will be raised
103 -- but not handled.
104 --
105 -- Developer Implementation Notes:
106 -- Any pre-processing required before the delete dml is issued should be
107 -- coded within this procedure. It is important to note that any 3rd party
108 -- maintenance should be reviewed before placing in this procedure.
109 --
110 -- Access Status:
111 -- Internal Row Handler Use Only.
112 --
113 -- {End Of Comments}
114 -- ----------------------------------------------------------------------------
115 Procedure pre_delete(p_rec in hr_pft_shd.g_rec_type) is
116 --
117 l_proc varchar2(72) := g_package||'pre_delete';
118 --
119 Begin
120 hr_utility.set_location('Entering:'||l_proc, 5);
121 --
122 hr_utility.set_location(' Leaving:'||l_proc, 10);
123 End pre_delete;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |-----------------------------< post_delete >------------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 -- This private procedure contains any processing which is required after
132 -- the delete dml.
133 --
134 -- Prerequistes:
135 -- This is an internal procedure which is called from the del procedure.
136 --
137 -- In Parameters:
138 -- A Pl/Sql record structure.
139 --
140 -- Post Success:
141 -- Processing continues.
142 --
143 -- Post Failure:
144 -- If an error has occurred, an error message and exception will be raised
145 -- but not handled.
146 --
147 -- Developer Implementation Notes:
148 -- Any post-processing required after the delete dml is issued should be
149 -- coded within this procedure. It is important to note that any 3rd party
150 -- maintenance should be reviewed before placing in this procedure.
151 --
152 -- Access Status:
153 -- Internal Row Handler Use Only.
154 --
155 -- {End Of Comments}
156 -- -----------------------------------------------------------------------------
157 Procedure post_delete(p_rec in hr_pft_shd.g_rec_type) is
158 --
159 l_proc varchar2(72) := g_package||'post_delete';
160 --
161 Begin
162 hr_utility.set_location('Entering:'||l_proc, 5);
163 begin
164 --
165 hr_pft_rkd.after_delete
166 (p_position_id
167 => p_rec.position_id
168 ,p_language
169 => p_rec.language
170 ,p_source_lang_o
171 => hr_pft_shd.g_old_rec.source_lang
172 ,p_name_o
173 => hr_pft_shd.g_old_rec.name
174 );
175 --
176 exception
177 --
178 when hr_api.cannot_find_prog_unit then
179 --
180 hr_api.cannot_find_prog_unit_error
181 (p_module_name => 'HR_ALL_POSITIONS_F_TL'
182 ,p_hook_type => 'AD');
183 --
184 end;
185 --
186 hr_utility.set_location(' Leaving:'||l_proc, 10);
187 End post_delete;
188 --
189 -- ----------------------------------------------------------------------------
190 -- |---------------------------------< del >----------------------------------|
191 -- ----------------------------------------------------------------------------
192 Procedure del
193 (p_rec in hr_pft_shd.g_rec_type
194 ) is
195 --
196 l_proc varchar2(72) := g_package||'del';
197 --
198 Begin
199 hr_utility.set_location('Entering:'||l_proc, 5);
200 --
201 -- We must lock the row which we need to delete.
202 --
203 hr_pft_shd.lck
204 (p_rec.position_id
205 ,p_rec.language
206 );
207 --
208 -- Call the supporting delete validate operation
209 --
210 hr_pft_bus.delete_validate(p_rec);
211 --
212 -- Call to raise any errors on multi-message list
213 hr_multi_message.end_validation_set;
214 --
215 -- Call the supporting pre-delete operation
216 --
217 hr_pft_del.pre_delete(p_rec);
218 --
219 -- Delete the row.
220 --
221 hr_pft_del.delete_dml(p_rec);
222 --
223 -- Call the supporting post-delete operation
224 --
225 hr_pft_del.post_delete(p_rec);
226 --
227 -- Call to raise any errors on multi-message list
228 hr_multi_message.end_validation_set;
229 --
230 End del;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |---------------------------------< del >----------------------------------|
234 -- ----------------------------------------------------------------------------
235 Procedure del
236 (p_position_id in number
237 ,p_language in varchar2
238 ) is
239 --
240 l_rec hr_pft_shd.g_rec_type;
241 l_proc varchar2(72) := g_package||'del';
242 --
243 Begin
244 hr_utility.set_location('Entering:'||l_proc, 5);
245 --
246 -- As the delete procedure accepts a plsql record structure we do need to
247 -- convert the arguments into the record structure.
248 -- We don't need to call the supplied conversion argument routine as we
249 -- only need a few attributes.
250 --
251 l_rec.position_id := p_position_id;
252 l_rec.language := p_language;
253 --
254 --
255 -- Having converted the arguments into the hr_pft_rec
256 -- plsql record structure we must call the corresponding entity
257 -- business process
258 --
259 hr_pft_del.del(l_rec);
260 --
261 hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End del;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |------------------------------< del_tl >----------------------------------|
266 -- ----------------------------------------------------------------------------
267 Procedure del_tl
268 (p_position_id in number
269 ,p_datetrack_mode in varchar2
270 ) is
271 --
272 l_position_definition_id per_position_definitions.position_definition_id%TYPE;
273 --
274 -- Cursor fetches relevant columns from latest datetrack record
275 --
276 cursor c_definition_id IS
277 select psf.position_definition_id
278 from hr_all_positions_f psf
279 where psf.position_id = p_position_id
280 and psf.effective_end_date = hr_api.g_eot;
281 --
282 -- Cursor to obtain all the translation rows.
283 --
284 cursor csr_del_langs is
285 select pft.language
286 from hr_all_positions_f_tl pft
287 where pft.position_id = p_position_id;
288 --
289 l_proc varchar2(72) := g_package||'del_tl';
290 --
291 Begin
292 hr_utility.set_location('Entering:'||l_proc,10);
293 --
294 --
295 -- Delete all the translated rows
296 --
297 for l_lang in csr_del_langs loop
298 hr_pft_del.del
299 (p_position_id => p_position_id
300 ,p_language => l_lang.language
301 );
302 end loop;
303 --
304 -- If we're not in zap mode, go get the current eot record
305 -- and insert into tl table
306 if ( p_datetrack_mode <> 'ZAP' ) then
307 open c_definition_id;
308 fetch c_definition_id into l_position_definition_id;
309 close c_definition_id;
310 --
311 hr_pft_ins.ins_tl( p_language_code => hr_api.userenv_lang
312 , p_position_id => p_position_id
313 , p_position_definition_id => l_position_definition_id
314 );
315
316 end if;
317 hr_utility.set_location(' Leaving:'||l_proc,20);
318 End del_tl;
319 --
320 end hr_pft_del;