DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_MAP_UPD

Source


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