DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_MCU_UPD

Source


1 Package Body hxc_mcu_upd as
2 /* $Header: hxcmcurhi.pkb 120.2 2005/09/23 08:44:11 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_mcu_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_mcu_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_mcu_shd.g_api_dml := true;  -- Set the api dml status
74   --
75   -- Update the hxc_mapping_comp_usages Row
76   --
77   update hxc_mapping_comp_usages
78     set
79      mapping_comp_usage_id           = p_rec.mapping_comp_usage_id
80     ,object_version_number           = p_rec.object_version_number
81     ,mapping_component_id            = p_rec.mapping_component_id
82     ,mapping_id                      = p_rec.mapping_id
83       ,last_updated_by		     = fnd_global.user_id
84     ,last_update_date		     = sysdate
85     ,last_update_login	             = fnd_global.login_id
86     where mapping_comp_usage_id = p_rec.mapping_comp_usage_id;
87   --
88   hxc_mcu_shd.g_api_dml := false;   -- Unset the api dml status
89   --
90   if g_debug then
91   	hr_utility.set_location(' Leaving:'||l_proc, 10);
92   end if;
93 --
94 Exception
95   When hr_api.check_integrity_violated Then
96     -- A check constraint has been violated
97     hxc_mcu_shd.g_api_dml := false;   -- Unset the api dml status
98     hxc_mcu_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.parent_integrity_violated Then
101     -- Parent integrity has been violated
102     hxc_mcu_shd.g_api_dml := false;   -- Unset the api dml status
103     hxc_mcu_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When hr_api.unique_integrity_violated Then
106     -- Unique integrity has been violated
107     hxc_mcu_shd.g_api_dml := false;   -- Unset the api dml status
108     hxc_mcu_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When Others Then
111     hxc_mcu_shd.g_api_dml := false;   -- Unset the api dml status
112     Raise;
113 End update_dml;
114 --
115 -- ----------------------------------------------------------------------------
116 -- |------------------------------< pre_update >------------------------------|
117 -- ----------------------------------------------------------------------------
118 -- {Start Of Comments}
119 --
120 -- Description:
121 --   This private procedure contains any processing which is required before
122 --   the update dml.
123 --
124 -- Prerequisites:
125 --   This is an internal procedure which is called from the upd procedure.
126 --
127 -- In Parameters:
128 --   A Pl/Sql record structure.
129 --
130 -- Post Success:
131 --   Processing continues.
132 --
133 -- Post Failure:
134 --   If an error has occurred, an error message and exception wil be raised
135 --   but not handled.
136 --
137 -- Developer Implementation Notes:
138 --   Any pre-processing required before the update dml is issued should be
139 --   coded within this procedure. It is important to note that any 3rd party
140 --   maintenance should be reviewed before placing in this procedure.
141 --
142 -- Access Status:
143 --   Internal Row Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_update
148   (p_rec in hxc_mcu_shd.g_rec_type
149   ) is
150 --
151   l_proc  varchar2(72);
152 --
153 Begin
154 
155 
156   if g_debug then
157   	l_proc := g_package||'pre_update';
158   	hr_utility.set_location('Entering:'||l_proc, 5);
159   	--
160   	hr_utility.set_location(' Leaving:'||l_proc, 10);
161   end if;
162 End pre_update;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |-----------------------------< post_update >------------------------------|
166 -- ----------------------------------------------------------------------------
167 -- {Start Of Comments}
168 --
169 -- Description:
170 --   This private procedure contains any processing which is required after the
171 --   update dml.
172 --
173 -- Prerequisites:
174 --   This is an internal procedure which is called from the upd procedure.
175 --
176 -- In Parameters:
177 --   A Pl/Sql record structure.
178 --
179 -- Post Success:
180 --   Processing continues.
181 --
182 -- Post Failure:
183 --   If an error has occurred, an error message and exception will be raised
184 --   but not handled.
185 --
186 -- Developer Implementation Notes:
187 --   Any post-processing required after the update dml is issued should be
188 --   coded within this procedure. It is important to note that any 3rd party
189 --   maintenance should be reviewed before placing in this procedure.
190 --
191 -- Access Status:
192 --   Internal Row Handler Use Only.
193 --
194 -- {End Of Comments}
195 -- ----------------------------------------------------------------------------
196 Procedure post_update
197   (p_rec                          in hxc_mcu_shd.g_rec_type
198   ) is
199 --
200   l_proc  varchar2(72);
201 --
202 Begin
203 
204 
205   if g_debug then
206   	l_proc := g_package||'post_update';
207   	hr_utility.set_location('Entering:'||l_proc, 5);
208   end if;
209   begin
210     --
211     hxc_mcu_rku.after_update
212       (p_mapping_comp_usage_id
213       => p_rec.mapping_comp_usage_id
214       ,p_object_version_number
215       => p_rec.object_version_number
216       ,p_mapping_component_id
217       => p_rec.mapping_component_id
218       ,p_mapping_id
219       => p_rec.mapping_id
220       ,p_object_version_number_o
221       => hxc_mcu_shd.g_old_rec.object_version_number
222       ,p_mapping_component_id_o
223       => hxc_mcu_shd.g_old_rec.mapping_component_id
224       ,p_mapping_id_o
225       => hxc_mcu_shd.g_old_rec.mapping_id
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_MAPPING_COMP_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_mcu_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.mapping_component_id = hr_api.g_number) then
298     p_rec.mapping_component_id :=
299     hxc_mcu_shd.g_old_rec.mapping_component_id;
300   End If;
301   If (p_rec.mapping_id = hr_api.g_number) then
302     p_rec.mapping_id :=
303     hxc_mcu_shd.g_old_rec.mapping_id;
304   End If;
305   --
306 End convert_defs;
307 --
308 -- ----------------------------------------------------------------------------
309 -- |---------------------------------< upd >----------------------------------|
310 -- ----------------------------------------------------------------------------
311 Procedure upd
312   (p_rec                          in out nocopy hxc_mcu_shd.g_rec_type
313   ) is
314 --
315   l_proc  varchar2(72);
316 --
317 Begin
318   g_debug := hr_utility.debug_enabled;
319 
320   if g_debug then
321   	l_proc := g_package||'upd';
322   	hr_utility.set_location('Entering:'||l_proc, 5);
323   end if;
324   --
325   -- We must lock the row which we need to update.
326   --
327   hxc_mcu_shd.lck
328     (p_rec.mapping_comp_usage_id
329     ,p_rec.object_version_number
330     );
331   --
332   -- 1. During an update system defaults are used to determine if
333   --    arguments have been defaulted or not. We must therefore
334   --    derive the full record structure values to be updated.
335   --
336   -- 2. Call the supporting update validate operations.
337   --
338   convert_defs(p_rec);
339   hxc_mcu_bus.update_validate
340      (p_rec
341      );
342   --
343   -- Call the supporting pre-update operation
344   --
345   hxc_mcu_upd.pre_update(p_rec);
346   --
347   -- Update the row.
348   --
349   hxc_mcu_upd.update_dml(p_rec);
350   --
351   -- Call the supporting post-update operation
352   --
353   hxc_mcu_upd.post_update
354      (p_rec
355      );
356 End upd;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------------< upd >----------------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure upd
362   (p_mapping_comp_usage_id        in     number
363   ,p_object_version_number        in out nocopy number
364   ,p_mapping_component_id         in     number    default hr_api.g_number
365   ,p_mapping_id                   in     number    default hr_api.g_number
366   ) is
367 --
368   l_rec	  hxc_mcu_shd.g_rec_type;
369   l_proc  varchar2(72);
370 --
371 Begin
372   g_debug := hr_utility.debug_enabled;
373 
374   if g_debug then
375   	l_proc := g_package||'upd';
376   	hr_utility.set_location('Entering:'||l_proc, 5);
377   end if;
378   --
379   -- Call conversion function to turn arguments into the
380   -- l_rec structure.
381   --
382   l_rec :=
383   hxc_mcu_shd.convert_args
384   (p_mapping_comp_usage_id
385   ,p_object_version_number
386   ,p_mapping_component_id
387   ,p_mapping_id
388   );
389   --
390   -- Having converted the arguments into the
391   -- plsql record structure we call the corresponding record
392   -- business process.
393   --
394   hxc_mcu_upd.upd
395      (l_rec
396      );
397   p_object_version_number := l_rec.object_version_number;
398   --
399   if g_debug then
400   	hr_utility.set_location(' Leaving:'||l_proc, 10);
401   end if;
402 End upd;
403 --
404 end hxc_mcu_upd;