DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HSD_UPD

Source


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