1 Package Body hxc_rtr_upd as
2 /* $Header: hxcrtrrhi.pkb 120.2 2005/09/23 08:54:01 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_rtr_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_rtr_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_rtr_shd.g_api_dml := true; -- Set the api dml status
74 --
75 -- Update the hxc_retrieval_rules Row
76 --
77 update hxc_retrieval_rules
78 set
79 retrieval_rule_id = p_rec.retrieval_rule_id
80 ,retrieval_process_id = p_rec.retrieval_process_id
81 ,object_version_number = p_rec.object_version_number
82 ,name = p_rec.name
83 ,last_updated_by = fnd_global.user_id
84 ,last_update_date = sysdate
85 ,last_update_login = fnd_global.login_id
86
87 where retrieval_rule_id = p_rec.retrieval_rule_id;
88 --
89 hxc_rtr_shd.g_api_dml := false; -- Unset the api dml status
90 --
91 if g_debug then
92 hr_utility.set_location(' Leaving:'||l_proc, 10);
93 end if;
94 --
95 Exception
96 When hr_api.check_integrity_violated Then
97 -- A check constraint has been violated
98 hxc_rtr_shd.g_api_dml := false; -- Unset the api dml status
99 hxc_rtr_shd.constraint_error
100 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101 When hr_api.parent_integrity_violated Then
102 -- Parent integrity has been violated
103 hxc_rtr_shd.g_api_dml := false; -- Unset the api dml status
104 hxc_rtr_shd.constraint_error
105 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106 When hr_api.unique_integrity_violated Then
107 -- Unique integrity has been violated
108 hxc_rtr_shd.g_api_dml := false; -- Unset the api dml status
109 hxc_rtr_shd.constraint_error
110 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111 When Others Then
112 hxc_rtr_shd.g_api_dml := false; -- Unset the api dml status
113 Raise;
114 End update_dml;
115 --
116 -- ----------------------------------------------------------------------------
117 -- |------------------------------< pre_update >------------------------------|
118 -- ----------------------------------------------------------------------------
119 -- {Start Of Comments}
120 --
121 -- Description:
122 -- This private procedure contains any processing which is required before
123 -- the update dml.
124 --
125 -- Prerequisites:
126 -- This is an internal procedure which is called from the upd procedure.
127 --
128 -- In Parameters:
129 -- A Pl/Sql record structure.
130 --
131 -- Post Success:
132 -- Processing continues.
133 --
134 -- Post Failure:
135 -- If an error has occurred, an error message and exception wil be raised
136 -- but not handled.
137 --
138 -- Developer Implementation Notes:
139 -- Any pre-processing required before the update dml is issued should be
140 -- coded within this procedure. It is important to note that any 3rd party
141 -- maintenance should be reviewed before placing in this procedure.
142 --
143 -- Access Status:
144 -- Internal Row Handler Use Only.
145 --
146 -- {End Of Comments}
147 -- ----------------------------------------------------------------------------
148 Procedure pre_update
149 (p_rec in hxc_rtr_shd.g_rec_type
150 ) is
151 --
152 l_proc varchar2(72);
153 --
154 Begin
155
156
157 if g_debug then
158 l_proc := g_package||'pre_update';
159 hr_utility.set_location('Entering:'||l_proc, 5);
160 --
161 hr_utility.set_location(' Leaving:'||l_proc, 10);
162 end if;
163 End pre_update;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |-----------------------------< post_update >------------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 -- This private procedure contains any processing which is required after the
172 -- update dml.
173 --
174 -- Prerequisites:
175 -- This is an internal procedure which is called from the upd procedure.
176 --
177 -- In Parameters:
178 -- A Pl/Sql record structure.
179 --
180 -- Post Success:
181 -- Processing continues.
182 --
183 -- Post Failure:
184 -- If an error has occurred, an error message and exception will be raised
185 -- but not handled.
186 --
187 -- Developer Implementation Notes:
188 -- Any post-processing required after the update dml is issued should be
189 -- coded within this procedure. It is important to note that any 3rd party
190 -- maintenance should be reviewed before placing in this procedure.
191 --
192 -- Access Status:
193 -- Internal Row Handler Use Only.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure post_update
198 (p_effective_date in date
199 ,p_rec in hxc_rtr_shd.g_rec_type
200 ) is
201 --
202 l_proc varchar2(72);
203 --
204 Begin
205
206
207 if g_debug then
208 l_proc := g_package||'post_update';
209 hr_utility.set_location('Entering:'||l_proc, 5);
210 end if;
211 begin
212 --
213 hxc_rtr_rku.after_update
214 (p_effective_date => p_effective_date
215 ,p_retrieval_rule_id
216 => p_rec.retrieval_rule_id
217 ,p_retrieval_process_id
218 => p_rec.retrieval_process_id
219 ,p_object_version_number
220 => p_rec.object_version_number
221 ,p_name
222 => p_rec.name
223 ,p_retrieval_process_id_o
224 => hxc_rtr_shd.g_old_rec.retrieval_process_id
225 ,p_object_version_number_o
226 => hxc_rtr_shd.g_old_rec.object_version_number
227 ,p_name_o
228 => hxc_rtr_shd.g_old_rec.name
229 );
230 --
231 exception
232 --
233 when hr_api.cannot_find_prog_unit then
234 --
235 hr_api.cannot_find_prog_unit_error
236 (p_module_name => 'HXC_RETRIEVAL_RULES'
237 ,p_hook_type => 'AU');
238 --
239 end;
240 --
241 if g_debug then
242 hr_utility.set_location(' Leaving:'||l_proc, 10);
243 end if;
244 End post_update;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |-----------------------------< convert_defs >-----------------------------|
248 -- ----------------------------------------------------------------------------
249 -- {Start Of Comments}
250 --
251 -- Description:
252 -- The Convert_Defs procedure has one very important function:
253 -- It must return the record structure for the row with all system defaulted
254 -- values converted into its corresponding parameter value for update. When
255 -- we attempt to update a row through the Upd process , certain
256 -- parameters can be defaulted which enables flexibility in the calling of
257 -- the upd process (e.g. only attributes which need to be updated need to be
258 -- specified). For the upd process to determine which attributes
259 -- have NOT been specified we need to check if the parameter has a reserved
260 -- system default value. Therefore, for all parameters which have a
261 -- corresponding reserved system default mechanism specified we need to
262 -- check if a system default is being used. If a system default is being
263 -- used then we convert the defaulted value into its corresponding attribute
264 -- value held in the g_old_rec data structure.
265 --
266 -- Prerequisites:
267 -- This private function can only be called from the upd process.
268 --
269 -- In Parameters:
270 -- A Pl/Sql record structure.
271 --
272 -- Post Success:
273 -- The record structure will be returned with all system defaulted parameter
274 -- values converted into its current row attribute value.
275 --
276 -- Post Failure:
277 -- No direct error handling is required within this function. Any possible
278 -- errors within this procedure will be a PL/SQL value error due to
279 -- conversion of datatypes or data lengths.
280 --
281 -- Developer Implementation Notes:
282 -- None.
283 --
284 -- Access Status:
285 -- Internal Row Handler Use Only.
286 --
287 -- {End Of Comments}
288 -- ----------------------------------------------------------------------------
289 Procedure convert_defs
290 (p_rec in out nocopy hxc_rtr_shd.g_rec_type
291 ) is
292 --
293 Begin
294 --
295 -- We must now examine each argument value in the
296 -- p_rec plsql record structure
297 -- to see if a system default is being used. If a system default
298 -- is being used then we must set to the 'current' argument value.
299 --
300 If (p_rec.retrieval_process_id = hr_api.g_number) then
301 p_rec.retrieval_process_id :=
302 hxc_rtr_shd.g_old_rec.retrieval_process_id;
303 End If;
304 If (p_rec.name = hr_api.g_varchar2) then
305 p_rec.name :=
306 hxc_rtr_shd.g_old_rec.name;
307 End If;
308 --
309 End convert_defs;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |---------------------------------< upd >----------------------------------|
313 -- ----------------------------------------------------------------------------
314 Procedure upd
315 (p_effective_date in date
316 ,p_rec in out nocopy hxc_rtr_shd.g_rec_type
317 ) is
318 --
319 l_proc varchar2(72);
320 --
321 Begin
322 g_debug := hr_utility.debug_enabled;
323
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_rtr_shd.lck
332 (p_rec.retrieval_rule_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_rtr_bus.update_validate
344 (p_effective_date
345 ,p_rec
346 );
347 --
348 -- Call the supporting pre-update operation
349 --
350 hxc_rtr_upd.pre_update(p_rec);
351 --
352 -- Update the row.
353 --
354 hxc_rtr_upd.update_dml(p_rec);
355 --
356 -- Call the supporting post-update operation
357 --
358 hxc_rtr_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_retrieval_rule_id in number
370 ,p_object_version_number in out nocopy number
371 ,p_retrieval_process_id in number default hr_api.g_number
372 ,p_name in varchar2 default hr_api.g_varchar2
373 ) is
374 --
375 l_rec hxc_rtr_shd.g_rec_type;
376 l_proc varchar2(72);
377 --
378 Begin
379 g_debug := hr_utility.debug_enabled;
380
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_rtr_shd.convert_args
391 (p_retrieval_rule_id
392 ,p_retrieval_process_id
393 ,p_object_version_number
394 ,p_name
395 );
396 --
397 -- Having converted the arguments into the
398 -- plsql record structure we call the corresponding record
399 -- business process.
400 --
401 hxc_rtr_upd.upd
402 (p_effective_date
403 ,l_rec
404 );
405 p_object_version_number := l_rec.object_version_number;
406 --
407 if g_debug then
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 end if;
410 End upd;
411 --
412 end hxc_rtr_upd;