1 Package Body hxc_rtc_upd as
2 /* $Header: hxcrtcrhi.pkb 120.2 2005/09/23 08:51:07 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_rtc_upd.'; -- Global package name
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |------------------------------< update_dml >------------------------------|
14 -- ----------------------------------------------------------------------------
15 -- {Start Of Comments}
16 --
17 -- Description:
18 -- This procedure controls the actual dml update logic. The processing of
19 -- this procedure is:
20 -- 1) Increment the object_version_number by 1 if the object_version_number
21 -- is defined as an attribute for this entity.
22 -- 2) To set and unset the g_api_dml status as required (as we are about to
23 -- perform dml).
24 -- 3) To update the specified row in the schema using the primary key in
25 -- the predicates.
26 -- 4) To trap any constraint violations that may have occurred.
27 -- 5) To raise any other errors.
28 --
29 -- Prerequisites:
30 -- This is an internal private procedure which must be called from the upd
31 -- procedure.
32 --
33 -- In Parameters:
34 -- A Pl/Sql record structre.
35 --
36 -- Post Success:
37 -- The specified row will be updated in the schema.
38 --
39 -- Post Failure:
40 -- On the update dml failure it is important to note that we always reset the
41 -- g_api_dml status to false.
42 -- If a check, unique or parent integrity constraint violation is raised the
43 -- constraint_error procedure will be called.
44 -- If any other error is reported, the error will be raised after the
45 -- g_api_dml status is reset.
46 --
47 -- Developer Implementation Notes:
48 -- The update 'set' attribute list should be modified if any of your
49 -- attributes are not updateable.
50 --
51 -- Access Status:
52 -- Internal Row Handler Use Only.
53 --
54 -- {End Of Comments}
55 -- ----------------------------------------------------------------------------
56 Procedure update_dml
57 (p_rec in out nocopy hxc_rtc_shd.g_rec_type
58 ) is
59 --
60 l_proc varchar2(72);
61 --
62 Begin
63
64
65 if g_debug then
66 l_proc := g_package||'update_dml';
67 hr_utility.set_location('Entering:'||l_proc, 5);
68 end if;
69 --
70 -- Increment the object version
71 p_rec.object_version_number := p_rec.object_version_number + 1;
72 --
73 hxc_rtc_shd.g_api_dml := true; -- Set the api dml status
74 --
75 -- Update the hxc_retrieval_rule_comps Row
76 --
77 update hxc_retrieval_rule_comps
78 set
79 retrieval_rule_comp_id = p_rec.retrieval_rule_comp_id
80 ,retrieval_rule_id = p_rec.retrieval_rule_id
81 ,status = p_rec.status
82 ,object_version_number = p_rec.object_version_number
83 ,time_recipient_id = p_rec.time_recipient_id
84 ,last_updated_by = fnd_global.user_id
85 ,last_update_date = sysdate
86 ,last_update_login = fnd_global.login_id
87
88 where retrieval_rule_comp_id = p_rec.retrieval_rule_comp_id;
89 --
90 hxc_rtc_shd.g_api_dml := false; -- Unset the api dml status
91 --
92 if g_debug then
93 hr_utility.set_location(' Leaving:'||l_proc, 10);
94 end if;
95 --
96 Exception
97 When hr_api.check_integrity_violated Then
98 -- A check constraint has been violated
99 hxc_rtc_shd.g_api_dml := false; -- Unset the api dml status
100 hxc_rtc_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When hr_api.parent_integrity_violated Then
103 -- Parent integrity has been violated
104 hxc_rtc_shd.g_api_dml := false; -- Unset the api dml status
105 hxc_rtc_shd.constraint_error
106 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107 When hr_api.unique_integrity_violated Then
108 -- Unique integrity has been violated
109 hxc_rtc_shd.g_api_dml := false; -- Unset the api dml status
110 hxc_rtc_shd.constraint_error
111 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
112 When Others Then
113 hxc_rtc_shd.g_api_dml := false; -- Unset the api dml status
114 Raise;
115 End update_dml;
116 --
117 -- ----------------------------------------------------------------------------
118 -- |------------------------------< pre_update >------------------------------|
119 -- ----------------------------------------------------------------------------
120 -- {Start Of Comments}
121 --
122 -- Description:
123 -- This private procedure contains any processing which is required before
124 -- the update dml.
125 --
126 -- Prerequisites:
127 -- This is an internal procedure which is called from the upd procedure.
128 --
129 -- In Parameters:
130 -- A Pl/Sql record structure.
131 --
132 -- Post Success:
133 -- Processing continues.
134 --
135 -- Post Failure:
136 -- If an error has occurred, an error message and exception wil be raised
137 -- but not handled.
138 --
139 -- Developer Implementation Notes:
140 -- Any pre-processing required before the update dml is issued should be
141 -- coded within this procedure. It is important to note that any 3rd party
142 -- maintenance should be reviewed before placing in this procedure.
143 --
144 -- Access Status:
145 -- Internal Row Handler Use Only.
146 --
147 -- {End Of Comments}
148 -- ----------------------------------------------------------------------------
149 Procedure pre_update
150 (p_rec in hxc_rtc_shd.g_rec_type
151 ) is
152 --
153 l_proc varchar2(72);
154 --
155 Begin
156
157
158 if g_debug then
159 l_proc := g_package||'pre_update';
160 hr_utility.set_location('Entering:'||l_proc, 5);
161 --
162 hr_utility.set_location(' Leaving:'||l_proc, 10);
163 end if;
164 End pre_update;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |-----------------------------< post_update >------------------------------|
168 -- ----------------------------------------------------------------------------
169 -- {Start Of Comments}
170 --
171 -- Description:
172 -- This private procedure contains any processing which is required after the
173 -- update dml.
174 --
175 -- Prerequisites:
176 -- This is an internal procedure which is called from the upd procedure.
177 --
178 -- In Parameters:
179 -- A Pl/Sql record structure.
180 --
181 -- Post Success:
182 -- Processing continues.
183 --
184 -- Post Failure:
185 -- If an error has occurred, an error message and exception will be raised
186 -- but not handled.
187 --
188 -- Developer Implementation Notes:
189 -- Any post-processing required after the update dml is issued should be
190 -- coded within this procedure. It is important to note that any 3rd party
191 -- maintenance should be reviewed before placing in this procedure.
192 --
193 -- Access Status:
194 -- Internal Row Handler Use Only.
195 --
196 -- {End Of Comments}
197 -- ----------------------------------------------------------------------------
198 Procedure post_update
199 (p_effective_date in date
200 ,p_rec in hxc_rtc_shd.g_rec_type
201 ) is
202 --
203 l_proc varchar2(72);
204 --
205 Begin
206
207
208 if g_debug then
209 l_proc := g_package||'post_update';
210 hr_utility.set_location('Entering:'||l_proc, 5);
211 end if;
212 begin
213 --
214 hxc_rtc_rku.after_update
215 (p_effective_date => p_effective_date
216 ,p_retrieval_rule_comp_id
217 => p_rec.retrieval_rule_comp_id
218 ,p_retrieval_rule_id
219 => p_rec.retrieval_rule_id
220 ,p_status
221 => p_rec.status
222 ,p_object_version_number
223 => p_rec.object_version_number
224 ,p_time_recipient_id
225 => p_rec.time_recipient_id
226 ,p_retrieval_rule_id_o
227 => hxc_rtc_shd.g_old_rec.retrieval_rule_id
228 ,p_status_o
229 => hxc_rtc_shd.g_old_rec.status
230 ,p_object_version_number_o
231 => hxc_rtc_shd.g_old_rec.object_version_number
232 ,p_time_recipient_id_o
233 => hxc_rtc_shd.g_old_rec.time_recipient_id
234 );
235 --
236 exception
237 --
238 when hr_api.cannot_find_prog_unit then
239 --
240 hr_api.cannot_find_prog_unit_error
241 (p_module_name => 'HXC_RETRIEVAL_RULE_COMPS'
242 ,p_hook_type => 'AU');
243 --
244 end;
245 --
246 if g_debug then
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 end if;
249 End post_update;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |-----------------------------< convert_defs >-----------------------------|
253 -- ----------------------------------------------------------------------------
254 -- {Start Of Comments}
255 --
256 -- Description:
257 -- The Convert_Defs procedure has one very important function:
258 -- It must return the record structure for the row with all system defaulted
259 -- values converted into its corresponding parameter value for update. When
260 -- we attempt to update a row through the Upd process , certain
261 -- parameters can be defaulted which enables flexibility in the calling of
262 -- the upd process (e.g. only attributes which need to be updated need to be
263 -- specified). For the upd process to determine which attributes
264 -- have NOT been specified we need to check if the parameter has a reserved
265 -- system default value. Therefore, for all parameters which have a
266 -- corresponding reserved system default mechanism specified we need to
267 -- check if a system default is being used. If a system default is being
268 -- used then we convert the defaulted value into its corresponding attribute
269 -- value held in the g_old_rec data structure.
270 --
271 -- Prerequisites:
272 -- This private function can only be called from the upd process.
273 --
274 -- In Parameters:
275 -- A Pl/Sql record structure.
276 --
277 -- Post Success:
278 -- The record structure will be returned with all system defaulted parameter
279 -- values converted into its current row attribute value.
280 --
281 -- Post Failure:
282 -- No direct error handling is required within this function. Any possible
283 -- errors within this procedure will be a PL/SQL value error due to
284 -- conversion of datatypes or data lengths.
285 --
286 -- Developer Implementation Notes:
287 -- None.
288 --
289 -- Access Status:
290 -- Internal Row Handler Use Only.
291 --
292 -- {End Of Comments}
293 -- ----------------------------------------------------------------------------
294 Procedure convert_defs
295 (p_rec in out nocopy hxc_rtc_shd.g_rec_type
296 ) is
297 --
298 Begin
299 --
300 -- We must now examine each argument value in the
301 -- p_rec plsql record structure
302 -- to see if a system default is being used. If a system default
303 -- is being used then we must set to the 'current' argument value.
304 --
305 If (p_rec.retrieval_rule_id = hr_api.g_number) then
306 p_rec.retrieval_rule_id :=
307 hxc_rtc_shd.g_old_rec.retrieval_rule_id;
308 End If;
309 If (p_rec.status = hr_api.g_varchar2) then
310 p_rec.status :=
311 hxc_rtc_shd.g_old_rec.status;
312 End If;
313 If (p_rec.time_recipient_id = hr_api.g_number) then
314 p_rec.time_recipient_id :=
315 hxc_rtc_shd.g_old_rec.time_recipient_id;
316 End If;
317 --
318 End convert_defs;
319 --
320 -- ----------------------------------------------------------------------------
321 -- |---------------------------------< upd >----------------------------------|
322 -- ----------------------------------------------------------------------------
323 Procedure upd
324 (p_effective_date in date
325 ,p_rec in out nocopy hxc_rtc_shd.g_rec_type
326 ) is
327 --
328 l_proc varchar2(72);
329 --
330 Begin
331 g_debug := hr_utility.debug_enabled;
332
333 if g_debug then
334 l_proc := g_package||'upd';
335 hr_utility.set_location('Entering:'||l_proc, 5);
336 end if;
337 --
338 -- We must lock the row which we need to update.
339 --
340 hxc_rtc_shd.lck
341 (p_rec.retrieval_rule_comp_id
342 ,p_rec.object_version_number
343 );
344 --
345 -- 1. During an update system defaults are used to determine if
346 -- arguments have been defaulted or not. We must therefore
347 -- derive the full record structure values to be updated.
348 --
349 -- 2. Call the supporting update validate operations.
350 --
351 convert_defs(p_rec);
352 hxc_rtc_bus.update_validate
353 (p_effective_date
354 ,p_rec
355 );
356 --
357 -- Call the supporting pre-update operation
358 --
359 hxc_rtc_upd.pre_update(p_rec);
360 --
361 -- Update the row.
362 --
363 hxc_rtc_upd.update_dml(p_rec);
364 --
365 -- Call the supporting post-update operation
366 --
367 hxc_rtc_upd.post_update
368 (p_effective_date
369 ,p_rec
370 );
371 End upd;
372 --
373 -- ----------------------------------------------------------------------------
374 -- |---------------------------------< upd >----------------------------------|
375 -- ----------------------------------------------------------------------------
376 Procedure upd
377 (p_effective_date in date
378 ,p_retrieval_rule_comp_id in number
379 ,p_object_version_number in out nocopy number
380 ,p_retrieval_rule_id in number default hr_api.g_number
381 ,p_status in varchar2 default hr_api.g_varchar2
382 ,p_time_recipient_id in number default hr_api.g_number
383 ) is
384 --
385 l_rec hxc_rtc_shd.g_rec_type;
386 l_proc varchar2(72);
387 --
388 Begin
389 g_debug := hr_utility.debug_enabled;
390
391 if g_debug then
392 l_proc := g_package||'upd';
393 hr_utility.set_location('Entering:'||l_proc, 5);
394 end if;
395 --
396 -- Call conversion function to turn arguments into the
397 -- l_rec structure.
398 --
399 l_rec :=
400 hxc_rtc_shd.convert_args
401 (p_retrieval_rule_comp_id
402 ,p_retrieval_rule_id
403 ,p_status
404 ,p_object_version_number
405 ,p_time_recipient_id
406 );
407 --
408 -- Having converted the arguments into the
409 -- plsql record structure we call the corresponding record
410 -- business process.
411 --
412 hxc_rtc_upd.upd
413 (p_effective_date
414 ,l_rec
415 );
416 p_object_version_number := l_rec.object_version_number;
417 --
418 if g_debug then
419 hr_utility.set_location(' Leaving:'||l_proc, 10);
420 end if;
421 End upd;
422 --
423 end hxc_rtc_upd;