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