DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HAS_UPD

Source


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