DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XDD_UPD

Source


1 Package Body ben_xdd_upd as
2 /* $Header: bexddrhi.pkb 120.1 2005/06/08 13:09:46 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xdd_upd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< update_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
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 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out nocopy ben_xdd_shd.g_rec_type) is
55 --
56   l_proc  varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59   hr_utility.set_location('Entering:'||l_proc, 5);
60   --
61   -- Increment the object version
62   --
63   p_rec.object_version_number := p_rec.object_version_number + 1;
64   --
65   ben_xdd_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ben_ext_data_elmt_decd Row
68   --
69   update ben_ext_data_elmt_decd
70   set
71   ext_data_elmt_decd_id             = p_rec.ext_data_elmt_decd_id,
72   val                               = p_rec.val,
73   dcd_val                           = p_rec.dcd_val,
74   chg_evt_source                    = p_rec.chg_evt_source,
75   ext_data_elmt_id                  = p_rec.ext_data_elmt_id,
76   business_group_id                 = p_rec.business_group_id,
77   legislation_code                  = p_rec.legislation_code,
78   last_update_date                  = p_rec.last_update_date,
79   last_updated_by                   = p_rec.last_updated_by,
80   last_update_login                 = p_rec.last_update_login,
81   object_version_number             = p_rec.object_version_number
82   where ext_data_elmt_decd_id = p_rec.ext_data_elmt_decd_id;
83   --
84   ben_xdd_shd.g_api_dml := false;   -- Unset the api dml status
85   --
86   hr_utility.set_location(' Leaving:'||l_proc, 10);
87 --
88 Exception
89   When hr_api.check_integrity_violated Then
90     -- A check constraint has been violated
91     ben_xdd_shd.g_api_dml := false;   -- Unset the api dml status
92     ben_xdd_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.parent_integrity_violated Then
95     -- Parent integrity has been violated
96     ben_xdd_shd.g_api_dml := false;   -- Unset the api dml status
97     ben_xdd_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When hr_api.unique_integrity_violated Then
100     -- Unique integrity has been violated
101     ben_xdd_shd.g_api_dml := false;   -- Unset the api dml status
102     ben_xdd_shd.constraint_error
103       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104   When Others Then
105     ben_xdd_shd.g_api_dml := false;   -- Unset the api dml status
106     Raise;
107 End update_dml;
108 --
109 -- ----------------------------------------------------------------------------
110 -- |------------------------------< pre_update >------------------------------|
111 -- ----------------------------------------------------------------------------
112 -- {Start Of Comments}
113 --
114 -- Description:
115 --   This private procedure contains any processing which is required before
116 --   the update dml.
117 --
118 -- Prerequisites:
119 --   This is an internal procedure which is called from the upd procedure.
120 --
121 -- In Parameters:
122 --   A Pl/Sql record structre.
123 --
124 -- Post Success:
125 --   Processing continues.
126 --
127 -- Post Failure:
128 --   If an error has occurred, an error message and exception will be raised
129 --   but not handled.
130 --
131 -- Developer Implementation Notes:
132 --   Any pre-processing required before the update dml is issued should be
133 --   coded within this procedure. It is important to note that any 3rd party
134 --   maintenance should be reviewed before placing in this procedure.
135 --
136 -- Access Status:
137 --   Internal Row Handler Use Only.
138 --
139 -- {End Of Comments}
140 -- ----------------------------------------------------------------------------
141 Procedure pre_update(p_rec in ben_xdd_shd.g_rec_type) is
142 --
143   l_proc  varchar2(72) := g_package||'pre_update';
144 --
145 Begin
146   hr_utility.set_location('Entering:'||l_proc, 5);
147   --
148   hr_utility.set_location(' Leaving:'||l_proc, 10);
149 End pre_update;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |-----------------------------< post_update >------------------------------|
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 --   This private procedure contains any processing which is required after the
158 --   update dml.
159 --
160 -- Prerequisites:
161 --   This is an internal procedure which is called from the upd procedure.
162 --
163 -- In Parameters:
164 --   A Pl/Sql record structre.
165 --
166 -- Post Success:
167 --   Processing continues.
168 --
169 -- Post Failure:
170 --   If an error has occurred, an error message and exception will be raised
171 --   but not handled.
172 --
173 -- Developer Implementation Notes:
174 --   Any post-processing required after the update dml is issued should be
175 --   coded within this procedure. It is important to note that any 3rd party
176 --   maintenance should be reviewed before placing in this procedure.
177 --
178 -- Access Status:
179 --   Internal Row Handler Use Only.
180 --
181 -- {End Of Comments}
182 -- ----------------------------------------------------------------------------
183 Procedure post_update(p_rec in ben_xdd_shd.g_rec_type) is
184 --
185   l_proc  varchar2(72) := g_package||'post_update';
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189 --
190   --
191   -- Start of API User Hook for post_update.
192   --
193   begin
194     --
195     ben_xdd_rku.after_update
196       (
197   p_ext_data_elmt_decd_id         =>p_rec.ext_data_elmt_decd_id
198  ,p_val                           =>p_rec.val
199  ,p_dcd_val                       =>p_rec.dcd_val
200  ,p_chg_evt_source                =>p_rec.chg_evt_source
201  ,p_ext_data_elmt_id              =>p_rec.ext_data_elmt_id
202  ,p_business_group_id             =>p_rec.business_group_id
203  ,p_legislation_code              =>p_rec.legislation_code
204  ,p_object_version_number         =>p_rec.object_version_number
205  ,p_val_o                         =>ben_xdd_shd.g_old_rec.val
206  ,p_dcd_val_o                     =>ben_xdd_shd.g_old_rec.dcd_val
207  ,p_chg_evt_source_o              =>ben_xdd_shd.g_old_rec.chg_evt_source
208  ,p_ext_data_elmt_id_o            =>ben_xdd_shd.g_old_rec.ext_data_elmt_id
209  ,p_business_group_id_o           =>ben_xdd_shd.g_old_rec.business_group_id
210  ,p_legislation_code_o            =>ben_xdd_shd.g_old_rec.legislation_code
211  ,p_object_version_number_o       =>ben_xdd_shd.g_old_rec.object_version_number
212       );
213     --
214   exception
215     --
216     when hr_api.cannot_find_prog_unit then
217       --
218       hr_api.cannot_find_prog_unit_error
219         (p_module_name => 'ben_ext_data_elmt_decd'
220         ,p_hook_type   => 'AU');
221       --
222   end;
223   --
224   -- End of API User Hook for post_update.
225   --
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
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 structre.
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 conversion
263 --   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(p_rec in out nocopy ben_xdd_shd.g_rec_type) is
274 --
275   l_proc  varchar2(72) := g_package||'convert_defs';
276 --
277 Begin
278   --
279   hr_utility.set_location('Entering:'||l_proc, 5);
280   --
281   -- We must now examine each argument value in the
282   -- p_rec plsql record structure
283   -- to see if a system default is being used. If a system default
284   -- is being used then we must set to the 'current' argument value.
285   --
286   If (p_rec.val = hr_api.g_varchar2) then
287     p_rec.val :=
288     ben_xdd_shd.g_old_rec.val;
289   End If;
290   If (p_rec.dcd_val = hr_api.g_varchar2) then
291     p_rec.dcd_val :=
292     ben_xdd_shd.g_old_rec.dcd_val;
293   End If;
294   If (p_rec.chg_evt_source = hr_api.g_varchar2) then
295     p_rec.chg_evt_source :=
296     ben_xdd_shd.g_old_rec.chg_evt_source;
297   End If;
298   If (p_rec.ext_data_elmt_id = hr_api.g_number) then
299     p_rec.ext_data_elmt_id :=
300     ben_xdd_shd.g_old_rec.ext_data_elmt_id;
301   End If;
302   If (p_rec.business_group_id = hr_api.g_number) then
303     p_rec.business_group_id :=
304     ben_xdd_shd.g_old_rec.business_group_id;
305   End If;
306   If (p_rec.legislation_code = hr_api.g_varchar2) then
307     p_rec.legislation_code :=
308     ben_xdd_shd.g_old_rec.legislation_code;
309   End If;
310 
311   --
312   hr_utility.set_location(' Leaving:'||l_proc, 10);
313 --
314 End convert_defs;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------------< upd >----------------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure upd
320   (
321   p_rec        in out nocopy ben_xdd_shd.g_rec_type
322   ) is
323 --
324   l_proc  varchar2(72) := g_package||'upd';
325 --
326 Begin
327   hr_utility.set_location('Entering:'||l_proc, 5);
328   --
329   -- We must lock the row which we need to update.
330   --
331   ben_xdd_shd.lck
332 	(
333 	p_rec.ext_data_elmt_decd_id,
334 	p_rec.object_version_number
335 	);
336   --
337   -- 1. During an update system defaults are used to determine if
338   --    arguments have been defaulted or not. We must therefore
339   --    derive the full record structure values to be updated.
340   --
341   -- 2. Call the supporting update validate operations.
342   --
343   convert_defs(p_rec);
344   ben_xdd_bus.update_validate(p_rec);
345   --
346   -- Call the supporting pre-update operation
347   --
348   pre_update(p_rec);
349   --
350   -- Update the row.
351   --
352   update_dml(p_rec);
353   --
354   -- Call the supporting post-update operation
355   --
356   post_update(p_rec);
357 End upd;
358 --
359 -- ----------------------------------------------------------------------------
360 -- |---------------------------------< upd >----------------------------------|
361 -- ----------------------------------------------------------------------------
362 Procedure upd
363   (
364   p_ext_data_elmt_decd_id        in number,
365   p_val                          in varchar2         default hr_api.g_varchar2,
366   p_dcd_val                      in varchar2         default hr_api.g_varchar2,
367   p_chg_evt_source               in varchar2         default hr_api.g_varchar2,
368   p_ext_data_elmt_id             in number           default hr_api.g_number,
369   p_business_group_id            in number           default hr_api.g_number,
370   p_legislation_code             in varchar2         default hr_api.g_varchar2,
371   p_last_update_date             in date             default hr_api.g_date,
372   p_creation_date                in date             default hr_api.g_date,
373   p_last_updated_by              in number           default hr_api.g_number,
374   p_last_update_login            in number           default hr_api.g_number,
375   p_created_by                   in number           default hr_api.g_number,
376   p_object_version_number        in out nocopy number
377   ) is
378 --
379   l_rec	  ben_xdd_shd.g_rec_type;
380   l_proc  varchar2(72) := g_package||'upd';
381 --
382 Begin
383   hr_utility.set_location('Entering:'||l_proc, 5);
384   --
385   -- Call conversion function to turn arguments into the
386   -- l_rec structure.
387   --
388   l_rec :=
389   ben_xdd_shd.convert_args
390   (
391   p_ext_data_elmt_decd_id,
392   p_val,
393   p_dcd_val,
394   p_chg_evt_source,
395   p_ext_data_elmt_id,
396   p_business_group_id,
397   p_legislation_code,
398   p_last_update_date,
399   p_creation_date   ,
400   p_last_updated_by ,
401   p_last_update_login,
402   p_created_by ,
403   p_object_version_number
404   );
405   --
406   -- Having converted the arguments into the
407   -- plsql record structure we call the corresponding record
408   -- business process.
409   --
410   upd(l_rec);
411   p_object_version_number := l_rec.object_version_number;
412   --
413   hr_utility.set_location(' Leaving:'||l_proc, 10);
414 End upd;
415 --
416 end ben_xdd_upd;