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