1 Package Body hxc_hat_upd as
2 /* $Header: hxchatrhi.pkb 120.2 2005/09/23 10:41:13 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_hat_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_hat_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 --
71 --
72 -- Update the hxc_alias_types Row
73 --
74 update hxc_alias_types
75 set
76 alias_type_id = p_rec.alias_type_id
77 ,alias_type = p_rec.alias_type
78 ,reference_object = p_rec.reference_object
79 ,object_version_number = p_rec.object_version_number
80 ,last_updated_by = fnd_global.user_id
81 ,last_update_date = sysdate
82 ,last_update_login = fnd_global.login_id
83
84 where alias_type_id = p_rec.alias_type_id;
85 --
86 --
87 --
88 if g_debug then
89 hr_utility.set_location(' Leaving:'||l_proc, 10);
90 end if;
91 --
92 Exception
93 When hr_api.check_integrity_violated Then
94 -- A check constraint has been violated
95 --
96 hxc_hat_shd.constraint_error
97 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98 When hr_api.parent_integrity_violated Then
99 -- Parent integrity has been violated
100 --
101 hxc_hat_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When hr_api.unique_integrity_violated Then
104 -- Unique integrity has been violated
105 --
106 hxc_hat_shd.constraint_error
107 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108 When Others Then
109 --
110 Raise;
111 End update_dml;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |------------------------------< pre_update >------------------------------|
115 -- ----------------------------------------------------------------------------
116 -- {Start Of Comments}
117 --
118 -- Description:
119 -- This private procedure contains any processing which is required before
120 -- the update dml.
121 --
122 -- Prerequisites:
123 -- This is an internal procedure which is called from the upd procedure.
124 --
125 -- In Parameters:
126 -- A Pl/Sql record structure.
127 --
128 -- Post Success:
129 -- Processing continues.
130 --
131 -- Post Failure:
132 -- If an error has occurred, an error message and exception wil be raised
133 -- but not handled.
134 --
135 -- Developer Implementation Notes:
136 -- Any pre-processing required before the update dml is issued should be
137 -- coded within this procedure. It is important to note that any 3rd party
138 -- maintenance should be reviewed before placing in this procedure.
139 --
140 -- Access Status:
141 -- Internal Row Handler Use Only.
142 --
143 -- {End Of Comments}
144 -- ----------------------------------------------------------------------------
145 Procedure pre_update
146 (p_rec in hxc_hat_shd.g_rec_type
147 ) is
148 --
149 l_proc varchar2(72);
150 --
151 Begin
152 if g_debug then
153 l_proc := g_package||'pre_update';
154 hr_utility.set_location('Entering:'||l_proc, 5);
155 --
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
167 -- the 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_rec in hxc_hat_shd.g_rec_type
194 ) is
195 --
196 l_proc varchar2(72);
197 --
198 Begin
199 if g_debug then
200 l_proc := g_package||'post_update';
201 hr_utility.set_location('Entering:'||l_proc, 5);
202 end if;
203 begin
204 --
205 hxc_hat_rku.after_update
206 (p_alias_type_id
207 => p_rec.alias_type_id
208 ,p_alias_type
209 => p_rec.alias_type
210 ,p_reference_object
211 => p_rec.reference_object
212 ,p_object_version_number
213 => p_rec.object_version_number
214 ,p_alias_type_o
215 => hxc_hat_shd.g_old_rec.alias_type
216 ,p_reference_object_o
217 => hxc_hat_shd.g_old_rec.reference_object
218 ,p_object_version_number_o
219 => hxc_hat_shd.g_old_rec.object_version_number
220 );
221 --
222 exception
223 --
224 when hr_api.cannot_find_prog_unit then
225 --
226 hr_api.cannot_find_prog_unit_error
227 (p_module_name => 'HXC_ALIAS_TYPES'
228 ,p_hook_type => 'AU');
229 --
230 end;
231 --
232 if g_debug then
233 hr_utility.set_location(' Leaving:'||l_proc, 10);
234 end if;
235 End post_update;
236 --
237 -- ----------------------------------------------------------------------------
238 -- |-----------------------------< convert_defs >-----------------------------|
239 -- ----------------------------------------------------------------------------
240 -- {Start Of Comments}
241 --
242 -- Description:
243 -- The Convert_Defs procedure has one very important function:
244 -- It must return the record structure for the row with all system defaulted
245 -- values converted into its corresponding parameter value for update. When
246 -- we attempt to update a row through the Upd process , certain
247 -- parameters can be defaulted which enables flexibility in the calling of
248 -- the upd process (e.g. only attributes which need to be updated need to be
249 -- specified). For the upd process to determine which attributes
250 -- have NOT been specified we need to check if the parameter has a reserved
251 -- system default value. Therefore, for all parameters which have a
252 -- corresponding reserved system default mechanism specified we need to
253 -- check if a system default is being used. If a system default is being
254 -- used then we convert the defaulted value into its corresponding attribute
255 -- value held in the g_old_rec data structure.
256 --
257 -- Prerequisites:
258 -- This private function can only be called from the upd process.
259 --
260 -- In Parameters:
261 -- A Pl/Sql record structure.
262 --
263 -- Post Success:
264 -- The record structure will be returned with all system defaulted parameter
265 -- values converted into its current row attribute value.
266 --
267 -- Post Failure:
268 -- No direct error handling is required within this function. Any possible
269 -- errors within this procedure will be a PL/SQL value error due to
270 -- conversion of datatypes or data lengths.
271 --
272 -- Developer Implementation Notes:
273 -- None.
274 --
275 -- Access Status:
276 -- Internal Row Handler Use Only.
277 --
278 -- {End Of Comments}
279 -- ----------------------------------------------------------------------------
280 Procedure convert_defs
281 (p_rec in out nocopy hxc_hat_shd.g_rec_type
282 ) is
283 --
284 Begin
285 --
286 -- We must now examine each argument value in the
287 -- p_rec plsql record structure
288 -- to see if a system default is being used. If a system default
289 -- is being used then we must set to the 'current' argument value.
290 --
291 If (p_rec.alias_type = hr_api.g_varchar2) then
292 p_rec.alias_type :=
293 hxc_hat_shd.g_old_rec.alias_type;
294 End If;
295 If (p_rec.reference_object = hr_api.g_varchar2) then
296 p_rec.reference_object :=
297 hxc_hat_shd.g_old_rec.reference_object;
298 End If;
299 --
300 End convert_defs;
301 --
302 -- ----------------------------------------------------------------------------
303 -- |---------------------------------< upd >----------------------------------|
304 -- ----------------------------------------------------------------------------
305 Procedure upd
306 (p_rec in out nocopy hxc_hat_shd.g_rec_type
307 ) is
308 --
309 l_proc varchar2(72);
310 --
311 Begin
312 g_debug:=hr_utility.debug_enabled;
313 if g_debug then
314 l_proc := g_package||'upd';
315 hr_utility.set_location('Entering:'||l_proc, 5);
316 end if;
317 --
318 -- We must lock the row which we need to update.
319 --
320 hxc_hat_shd.lck
321 (p_rec.alias_type_id
322 ,p_rec.object_version_number
323 );
324 --
325 -- 1. During an update system defaults are used to determine if
326 -- arguments have been defaulted or not. We must therefore
327 -- derive the full record structure values to be updated.
328 --
329 -- 2. Call the supporting update validate operations.
330 --
331 convert_defs(p_rec);
332 hxc_hat_bus.update_validate
333 (p_rec
334 );
335 --
336 -- Call to raise any errors on multi-message list
337 hr_multi_message.end_validation_set;
338 --
339 -- Call the supporting pre-update operation
340 --
341 hxc_hat_upd.pre_update(p_rec);
342 --
343 -- Update the row.
344 --
345 hxc_hat_upd.update_dml(p_rec);
346 --
347 -- Call the supporting post-update operation
348 --
349 hxc_hat_upd.post_update
350 (p_rec
351 );
352 --
353 -- Call to raise any errors on multi-message list
354 hr_multi_message.end_validation_set;
355 End upd;
356 --
357 -- ----------------------------------------------------------------------------
358 -- |---------------------------------< upd >----------------------------------|
359 -- ----------------------------------------------------------------------------
360 Procedure upd
361 (p_alias_type_id in number
362 ,p_object_version_number in out nocopy number
363 ,p_alias_type in varchar2 default hr_api.g_varchar2
364 ,p_reference_object in varchar2 default hr_api.g_varchar2
365 ) is
366 --
367 l_rec hxc_hat_shd.g_rec_type;
368 l_proc varchar2(72);
369 --
370 Begin
371 g_debug:=hr_utility.debug_enabled;
372 if g_debug then
373 l_proc := g_package||'upd';
374 hr_utility.set_location('Entering:'||l_proc, 5);
375 end if;
376 --
377 -- Call conversion function to turn arguments into the
378 -- l_rec structure.
379 --
380 l_rec :=
381 hxc_hat_shd.convert_args
382 (p_alias_type_id
383 ,p_alias_type
384 ,p_reference_object
385 ,p_object_version_number
386 );
387 --
388 -- Having converted the arguments into the
389 -- plsql record structure we call the corresponding record
390 -- business process.
391 --
392 hxc_hat_upd.upd
393 (l_rec
394 );
395 p_object_version_number := l_rec.object_version_number;
396 --
397 if g_debug then
398 hr_utility.set_location(' Leaving:'||l_proc, 10);
399 end if;
400 End upd;
401 --
402 end hxc_hat_upd;