DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_ATC_UPD

Source


1 Package Body hxc_atc_upd as
2 /* $Header: hxcatcrhi.pkb 120.2 2005/09/23 08:06:56 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hxc_atc_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_atc_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_type_components Row
73   --
74   update hxc_alias_type_components
75     set
76      alias_type_component_id         = p_rec.alias_type_component_id
77     ,component_name                  = p_rec.component_name
78     ,component_type                  = p_rec.component_type
79     ,mapping_component_id            = p_rec.mapping_component_id
80     ,alias_type_id                   = p_rec.alias_type_id
81     ,object_version_number           = p_rec.object_version_number
82         ,last_updated_by		     = fnd_global.user_id
83     ,last_update_date		     = sysdate
84     ,last_update_login	             = fnd_global.login_id
85 
86     where alias_type_component_id = p_rec.alias_type_component_id;
87   --
88   --
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     --
98     hxc_atc_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     --
103     hxc_atc_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     --
108     hxc_atc_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When Others Then
111     --
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_atc_shd.g_rec_type
149   ) is
150 --
151   l_proc  varchar2(72);
152 --
153 Begin
154   if g_debug then
155 	   l_proc:= g_package||'pre_update';
156 	   hr_utility.set_location('Entering:'||l_proc, 5);
157 	  --
158 	  hr_utility.set_location(' Leaving:'||l_proc, 10);
159   end if;
160 End pre_update;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |-----------------------------< post_update >------------------------------|
164 -- ----------------------------------------------------------------------------
165 -- {Start Of Comments}
166 --
167 -- Description:
168 --   This private procedure contains any processing which is required after
169 --   the update dml.
170 --
171 -- Prerequisites:
172 --   This is an internal procedure which is called from the upd procedure.
173 --
174 -- In Parameters:
175 --   A Pl/Sql record structure.
176 --
177 -- Post Success:
178 --   Processing continues.
179 --
180 -- Post Failure:
181 --   If an error has occurred, an error message and exception will be raised
182 --   but not handled.
183 --
184 -- Developer Implementation Notes:
185 --   Any post-processing required after the update dml is issued should be
186 --   coded within this procedure. It is important to note that any 3rd party
187 --   maintenance should be reviewed before placing in this procedure.
188 --
189 -- Access Status:
190 --   Internal Row Handler Use Only.
191 --
192 -- {End Of Comments}
193 -- ----------------------------------------------------------------------------
194 Procedure post_update
195   (p_rec                          in hxc_atc_shd.g_rec_type
196   ) is
197 --
198   l_proc  varchar2(72);
199 --
200 Begin
201   if g_debug then
202 	l_proc := g_package||'post_update';
203 	hr_utility.set_location('Entering:'||l_proc, 5);
204   end if;
205   begin
206     --
207     hxc_atc_rku.after_update
208       (p_alias_type_component_id
209       => p_rec.alias_type_component_id
210       ,p_component_name
211       => p_rec.component_name
212       ,p_component_type
213       => p_rec.component_type
214       ,p_mapping_component_id
215       => p_rec.mapping_component_id
216       ,p_alias_type_id
217       => p_rec.alias_type_id
218       ,p_object_version_number
219       => p_rec.object_version_number
220       ,p_component_name_o
221       => hxc_atc_shd.g_old_rec.component_name
222       ,p_component_type_o
223       => hxc_atc_shd.g_old_rec.component_type
224       ,p_mapping_component_id_o
225       => hxc_atc_shd.g_old_rec.mapping_component_id
226       ,p_alias_type_id_o
227       => hxc_atc_shd.g_old_rec.alias_type_id
228       ,p_object_version_number_o
229       => hxc_atc_shd.g_old_rec.object_version_number
230       );
231 
232 	hxc_time_category_utils_pkg.alias_type_comp_ref_int_chk ( p_rec.alias_type_id );
233 
234   exception
235     --
236     when hr_api.cannot_find_prog_unit then
237       --
238       hr_api.cannot_find_prog_unit_error
239         (p_module_name => 'HXC_ALIAS_TYPE_COMPONENTS'
240         ,p_hook_type   => 'AU');
241       --
242   end;
243   --
244   if g_debug then
245 	hr_utility.set_location(' Leaving:'||l_proc, 10);
246   end if;
247 End post_update;
248 --
249 -- ----------------------------------------------------------------------------
250 -- |-----------------------------< convert_defs >-----------------------------|
251 -- ----------------------------------------------------------------------------
252 -- {Start Of Comments}
253 --
254 -- Description:
255 --   The Convert_Defs procedure has one very important function:
256 --   It must return the record structure for the row with all system defaulted
257 --   values converted into its corresponding parameter value for update. When
258 --   we attempt to update a row through the Upd process , certain
259 --   parameters can be defaulted which enables flexibility in the calling of
260 --   the upd process (e.g. only attributes which need to be updated need to be
261 --   specified). For the upd process to determine which attributes
262 --   have NOT been specified we need to check if the parameter has a reserved
263 --   system default value. Therefore, for all parameters which have a
264 --   corresponding reserved system default mechanism specified we need to
265 --   check if a system default is being used. If a system default is being
266 --   used then we convert the defaulted value into its corresponding attribute
267 --   value held in the g_old_rec data structure.
268 --
269 -- Prerequisites:
270 --   This private function can only be called from the upd process.
271 --
272 -- In Parameters:
273 --   A Pl/Sql record structure.
274 --
275 -- Post Success:
276 --   The record structure will be returned with all system defaulted parameter
277 --   values converted into its current row attribute value.
278 --
279 -- Post Failure:
280 --   No direct error handling is required within this function. Any possible
281 --   errors within this procedure will be a PL/SQL value error due to
282 --   conversion of datatypes or data lengths.
283 --
284 -- Developer Implementation Notes:
285 --   None.
286 --
287 -- Access Status:
288 --   Internal Row Handler Use Only.
289 --
290 -- {End Of Comments}
291 -- ----------------------------------------------------------------------------
292 Procedure convert_defs
293   (p_rec in out nocopy hxc_atc_shd.g_rec_type
294   ) is
295 --
296 Begin
297   --
298   -- We must now examine each argument value in the
299   -- p_rec plsql record structure
300   -- to see if a system default is being used. If a system default
301   -- is being used then we must set to the 'current' argument value.
302   --
303   If (p_rec.component_name = hr_api.g_varchar2) then
304     p_rec.component_name :=
305     hxc_atc_shd.g_old_rec.component_name;
306   End If;
307   If (p_rec.component_type = hr_api.g_varchar2) then
308     p_rec.component_type :=
309     hxc_atc_shd.g_old_rec.component_type;
310   End If;
311   If (p_rec.mapping_component_id = hr_api.g_number) then
312     p_rec.mapping_component_id :=
313     hxc_atc_shd.g_old_rec.mapping_component_id;
314   End If;
315   If (p_rec.alias_type_id = hr_api.g_number) then
316     p_rec.alias_type_id :=
317     hxc_atc_shd.g_old_rec.alias_type_id;
318   End If;
319   --
320 End convert_defs;
321 --
322 -- ----------------------------------------------------------------------------
323 -- |---------------------------------< upd >----------------------------------|
324 -- ----------------------------------------------------------------------------
325 Procedure upd
326   (p_rec                          in out nocopy hxc_atc_shd.g_rec_type
327   ) is
328 --
329   l_proc  varchar2(72);
330 --
331 Begin
332   g_debug:=hr_utility.debug_enabled;
333   if g_debug then
334 	l_proc := g_package||'upd';
335 	hr_utility.set_location('Entering:'||l_proc, 5);
336   end if;
337   --
338   -- We must lock the row which we need to update.
339   --
340   hxc_atc_shd.lck
341     (p_rec.alias_type_component_id
342     ,p_rec.object_version_number
343     );
344   --
345   -- 1. During an update system defaults are used to determine if
346   --    arguments have been defaulted or not. We must therefore
347   --    derive the full record structure values to be updated.
348   --
349   -- 2. Call the supporting update validate operations.
350   --
351   convert_defs(p_rec);
352   hxc_atc_bus.update_validate
353      (p_rec
354      );
355   --
356   -- Call to raise any errors on multi-message list
357   hr_multi_message.end_validation_set;
358   --
359   -- Call the supporting pre-update operation
360   --
361   hxc_atc_upd.pre_update(p_rec);
362   --
363   -- Update the row.
364   --
365   hxc_atc_upd.update_dml(p_rec);
366   --
367   -- Call the supporting post-update operation
368   --
369   hxc_atc_upd.post_update
370      (p_rec
371      );
372   --
373   -- Call to raise any errors on multi-message list
374   hr_multi_message.end_validation_set;
375 End upd;
376 --
377 -- ----------------------------------------------------------------------------
378 -- |---------------------------------< upd >----------------------------------|
379 -- ----------------------------------------------------------------------------
380 Procedure upd
381   (p_alias_type_component_id      in     number
382   ,p_object_version_number        in out nocopy number
383   ,p_component_name               in     varchar2  default hr_api.g_varchar2
384   ,p_component_type               in     varchar2  default hr_api.g_varchar2
385   ,p_mapping_component_id         in     number    default hr_api.g_number
386   ,p_alias_type_id                in     number    default hr_api.g_number
387   ) is
388 --
389   l_rec   hxc_atc_shd.g_rec_type;
390   l_proc  varchar2(72);
391 --
392 Begin
393   g_debug:=hr_utility.debug_enabled;
394   if g_debug then
395 	 l_proc:= g_package||'upd';
396 	 hr_utility.set_location('Entering:'||l_proc, 5);
397   end if;
398   --
399   -- Call conversion function to turn arguments into the
400   -- l_rec structure.
401   --
402   l_rec :=
403   hxc_atc_shd.convert_args
404   (p_alias_type_component_id
405   ,p_component_name
406   ,p_component_type
407   ,p_mapping_component_id
408   ,p_alias_type_id
409   ,p_object_version_number
410   );
411   --
412   -- Having converted the arguments into the
413   -- plsql record structure we call the corresponding record
414   -- business process.
415   --
416   hxc_atc_upd.upd
417      (l_rec
418      );
419   p_object_version_number := l_rec.object_version_number;
420   --
421   if g_debug then
422 	hr_utility.set_location(' Leaving:'||l_proc, 10);
423   end if;
424 End upd;
425 --
426 end hxc_atc_upd;