DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HEG_UPD

Source


1 Package Body hxc_heg_upd as
2 /* $Header: hxchegrhi.pkb 120.2 2005/09/23 10:42:21 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_heg_upd.';  -- Global package name
9 g_debug	boolean		:=hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 -- Description:
16 --   This procedure controls the actual dml update logic. The processing of
17 --   this procedure is:
18 --   1) Increment the object_version_number by 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To update the specified row in the schema using the primary key in
23 --      the predicates.
24 --   4) To trap any constraint violations that may have occurred.
25 --   5) To raise any other errors.
26 --
27 -- Prerequisites:
28 --   This is an internal private procedure which must be called from the upd
29 --   procedure.
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be updated in the schema.
36 --
37 -- Post Failure:
38 --   On the update dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   The update 'set' attribute list should be modified if any of your
47 --   attributes are not updateable.
48 --
49 -- Access Status:
50 --   Internal Row Handler Use Only.
51 --
52 -- ----------------------------------------------------------------------------
53 Procedure update_dml
54   (p_rec in out nocopy hxc_heg_shd.g_rec_type
55   ) is
56 --
57   l_proc  varchar2(72);
58 --
59 Begin
60   if g_debug then
61 	l_proc := g_package||'update_dml';
62 	hr_utility.set_location('Entering:'||l_proc, 5);
63   end if;
64   --
65   -- Increment the object version
66   p_rec.object_version_number := p_rec.object_version_number + 1;
67   --
68   hxc_heg_shd.g_api_dml := true;  -- Set the api dml status
69   --
70   -- Update the hxc_entity_groups Row
71   --
72   update hxc_entity_groups
73     set
74      entity_group_id                 = p_rec.entity_group_id
75     ,name                            = p_rec.name
76     ,entity_type                     = p_rec.entity_type
77     ,object_version_number           = p_rec.object_version_number
78         ,last_updated_by		     = fnd_global.user_id
79     ,last_update_date		     = sysdate
80     ,last_update_login	             = fnd_global.login_id
81     ,description                     = p_rec.description
82     ,business_group_id               = p_rec.business_group_id
83     ,legislation_code                = p_rec.legislation_code
84 
85     where entity_group_id = p_rec.entity_group_id;
86   --
87   hxc_heg_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_heg_shd.g_api_dml := false;   -- Unset the api dml status
97     hxc_heg_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_heg_shd.g_api_dml := false;   -- Unset the api dml status
102     hxc_heg_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_heg_shd.g_api_dml := false;   -- Unset the api dml status
107     hxc_heg_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     hxc_heg_shd.g_api_dml := false;   -- Unset the api dml status
111     Raise;
112 End update_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_update >------------------------------|
116 -- ----------------------------------------------------------------------------
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 -- ----------------------------------------------------------------------------
144 Procedure pre_update
145   (p_rec in hxc_heg_shd.g_rec_type
146   ) is
147 --
148   l_proc  varchar2(72);
149 --
150 Begin
151   if g_debug then
152 	l_proc := g_package||'pre_update';
153 	hr_utility.set_location('Entering:'||l_proc, 5);
154 	--
155 	hr_utility.set_location(' Leaving:'||l_proc, 10);
156   end if;
157 End pre_update;
158 --
159 -- ----------------------------------------------------------------------------
160 -- |-----------------------------< post_update >------------------------------|
161 -- ----------------------------------------------------------------------------
162 --
163 -- Description:
164 --   This private procedure contains any processing which is required after the
165 --   update dml.
166 --
167 -- Prerequisites:
168 --   This is an internal procedure which is called from the upd procedure.
169 --
170 -- In Parameters:
171 --   A Pl/Sql record structure.
172 --
173 -- Post Success:
174 --   Processing continues.
175 --
176 -- Post Failure:
177 --   If an error has occurred, an error message and exception will be raised
178 --   but not handled.
179 --
180 -- Developer Implementation Notes:
181 --   Any post-processing required after the update dml is issued should be
182 --   coded within this procedure. It is important to note that any 3rd party
183 --   maintenance should be reviewed before placing in this procedure.
184 --
185 -- Access Status:
186 --   Internal Row Handler Use Only.
187 --
188 -- ----------------------------------------------------------------------------
189 Procedure post_update
190   (p_rec                          in hxc_heg_shd.g_rec_type
191   ) is
192 --
193   l_proc  varchar2(72);
194 --
195 Begin
196   if g_debug then
197 	l_proc := g_package||'post_update';
198 	hr_utility.set_location('Entering:'||l_proc, 5);
199   end if;
200   begin
201     --
202     hxc_heg_rku.after_update
203       (p_entity_group_id
204       => p_rec.entity_group_id
205       ,p_name
206       => p_rec.name
207       ,p_entity_type
208       => p_rec.entity_type
209       ,p_object_version_number
210       => p_rec.object_version_number
211       ,p_name_o
212       => hxc_heg_shd.g_old_rec.name
213       ,p_entity_type_o
214       => hxc_heg_shd.g_old_rec.entity_type
215       ,p_object_version_number_o
216       => hxc_heg_shd.g_old_rec.object_version_number
217       ,p_description
218       => p_rec.description
219       ,p_business_group_id
220       => p_rec.business_group_id
221       ,p_legislation_code
222       => p_rec.legislation_code
223       ,p_description_o
224       => hxc_heg_shd.g_old_rec.description
225       ,p_business_group_id_o
226       => hxc_heg_shd.g_old_rec.business_group_id
227       ,p_legislation_code_o
228       => hxc_heg_shd.g_old_rec.legislation_code
229       );
230     --
231   exception
232     --
233     when hr_api.cannot_find_prog_unit then
234       --
235       hr_api.cannot_find_prog_unit_error
236         (p_module_name => 'HXC_ENTITY_GROUPS'
237         ,p_hook_type   => 'AU');
238       --
239   end;
240   --
241   if g_debug then
242 	hr_utility.set_location(' Leaving:'||l_proc, 10);
243   end if;
244 End post_update;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |-----------------------------< convert_defs >-----------------------------|
248 -- ----------------------------------------------------------------------------
249 --
250 -- Description:
251 --   The Convert_Defs procedure has one very important function:
252 --   It must return the record structure for the row with all system defaulted
253 --   values converted into its corresponding parameter value for update. When
254 --   we attempt to update a row through the Upd process , certain
255 --   parameters can be defaulted which enables flexibility in the calling of
256 --   the upd process (e.g. only attributes which need to be updated need to be
257 --   specified). For the upd process to determine which attributes
258 --   have NOT been specified we need to check if the parameter has a reserved
259 --   system default value. Therefore, for all parameters which have a
260 --   corresponding reserved system default mechanism specified we need to
261 --   check if a system default is being used. If a system default is being
262 --   used then we convert the defaulted value into its corresponding attribute
263 --   value held in the g_old_rec data structure.
264 --
265 -- Prerequisites:
266 --   This private function can only be called from the upd process.
267 --
268 -- In Parameters:
269 --   A Pl/Sql record structure.
270 --
271 -- Post Success:
272 --   The record structure will be returned with all system defaulted parameter
273 --   values converted into its current row attribute value.
274 --
275 -- Post Failure:
276 --   No direct error handling is required within this function. Any possible
277 --   errors within this procedure will be a PL/SQL value error due to
278 --   conversion of datatypes or data lengths.
279 --
280 -- Developer Implementation Notes:
281 --   None.
282 --
283 -- Access Status:
284 --   Internal Row Handler Use Only.
285 --
286 -- ----------------------------------------------------------------------------
287 Procedure convert_defs
288   (p_rec in out nocopy hxc_heg_shd.g_rec_type
289   ) is
290 --
291 Begin
292   --
293   -- We must now examine each argument value in the
294   -- p_rec plsql record structure
295   -- to see if a system default is being used. If a system default
296   -- is being used then we must set to the 'current' argument value.
297   --
298   If (p_rec.name = hr_api.g_varchar2) then
299     p_rec.name :=
300     hxc_heg_shd.g_old_rec.name;
301   End If;
302   --
303 End convert_defs;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< upd >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure upd
309   (p_rec                          in out nocopy hxc_heg_shd.g_rec_type
310   ) is
311 --
312   l_proc  varchar2(72);
313 --
314 Begin
315   g_debug:=hr_utility.debug_enabled;
316   if g_debug then
317 	l_proc := g_package||'upd';
318 	hr_utility.set_location('Entering:'||l_proc, 5);
319   end if;
320   --
321   -- We must lock the row which we need to update.
322   --
323   hxc_heg_shd.lck
324     (p_rec.entity_group_id
325     ,p_rec.object_version_number
326     );
327   --
328   -- 1. During an update system defaults are used to determine if
329   --    arguments have been defaulted or not. We must therefore
330   --    derive the full record structure values to be updated.
331   --
332   -- 2. Call the supporting update validate operations.
333   --
334   convert_defs(p_rec);
335   hxc_heg_bus.update_validate
336      (p_rec
337      );
338   --
339   -- Call the supporting pre-update operation
340   --
341   hxc_heg_upd.pre_update(p_rec);
342   --
343   -- Update the row.
344   --
345   hxc_heg_upd.update_dml(p_rec);
346   --
347   -- Call the supporting post-update operation
348   --
349   hxc_heg_upd.post_update
350      (p_rec
351      );
352 End upd;
353 --
354 -- ----------------------------------------------------------------------------
355 -- |---------------------------------< upd >----------------------------------|
356 -- ----------------------------------------------------------------------------
357 Procedure upd
358   (p_entity_group_id              in     number
359   ,p_object_version_number        in out nocopy number
360   ,p_name                         in     varchar2
361   ,p_entity_type                  in     varchar2
362   ,p_description                  in     varchar2 default null
363   ,p_business_group_id            in     number default null
364   ,p_legislation_code             in     varchar2 default null
365   ) is
366 --
367   l_rec	  hxc_heg_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_heg_shd.convert_args
382   (p_entity_group_id
383   ,p_name
384   ,p_entity_type
385   ,p_object_version_number
386   ,p_description
387   ,p_business_group_id
388   ,p_legislation_code
389   );
390   --
391   -- Having converted the arguments into the
392   -- plsql record structure we call the corresponding record
393   -- business process.
394   --
395   hxc_heg_upd.upd
396      (l_rec
397      );
398   p_object_version_number := l_rec.object_version_number;
399   --
400   if g_debug then
401 	hr_utility.set_location(' Leaving:'||l_proc, 10);
402   end if;
403 End upd;
404 --
405 end hxc_heg_upd;