DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XWC_UPD

Source


1 Package Body ben_xwc_upd as
2 /* $Header: bexwcrhi.pkb 120.3 2006/04/27 11:31:07 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xwc_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_xwc_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_xwc_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ben_ext_where_clause Row
68   --
69   update ben_ext_where_clause
70   set
71   ext_where_clause_id               = p_rec.ext_where_clause_id,
72   seq_num                           = p_rec.seq_num,
73   oper_cd                           = p_rec.oper_cd,
74   val                               = p_rec.val,
75   and_or_cd                         = p_rec.and_or_cd,
76   ext_data_elmt_id                  = p_rec.ext_data_elmt_id,
77   cond_ext_data_elmt_id             = p_rec.cond_ext_data_elmt_id,
78   ext_rcd_in_file_id                = p_rec.ext_rcd_in_file_id,
79   ext_data_elmt_in_rcd_id           = p_rec.ext_data_elmt_in_rcd_id,
80   business_group_id                 = p_rec.business_group_id,
81   legislation_code                  = p_rec.legislation_code,
82   last_update_date                  = p_rec.last_update_date,
83   last_updated_by                   = p_rec.last_updated_by,
84   last_update_login                 = p_rec.last_update_login,
85   object_version_number             = p_rec.object_version_number,
86   cond_ext_data_elmt_in_rcd_id      = p_rec.cond_ext_data_elmt_in_rcd_id
87   where ext_where_clause_id = p_rec.ext_where_clause_id;
88   --
89   ben_xwc_shd.g_api_dml := false;   -- Unset the api dml status
90   --
91   hr_utility.set_location(' Leaving:'||l_proc, 10);
92 --
93 Exception
94   When hr_api.check_integrity_violated Then
95     -- A check constraint has been violated
96     ben_xwc_shd.g_api_dml := false;   -- Unset the api dml status
97     ben_xwc_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     ben_xwc_shd.g_api_dml := false;   -- Unset the api dml status
102     ben_xwc_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     ben_xwc_shd.g_api_dml := false;   -- Unset the api dml status
107     ben_xwc_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     ben_xwc_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 structre.
128 --
129 -- Post Success:
130 --   Processing continues.
131 --
132 -- Post Failure:
133 --   If an error has occurred, an error message and exception will 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(p_rec in ben_xwc_shd.g_rec_type) is
147 --
148   l_proc  varchar2(72) := g_package||'pre_update';
149 --
150 Begin
151   hr_utility.set_location('Entering:'||l_proc, 5);
152   --
153   hr_utility.set_location(' Leaving:'||l_proc, 10);
154 End pre_update;
155 --
156 -- ----------------------------------------------------------------------------
157 -- |-----------------------------< post_update >------------------------------|
158 -- ----------------------------------------------------------------------------
159 -- {Start Of Comments}
160 --
161 -- Description:
162 --   This private procedure contains any processing which is required after the
163 --   update dml.
164 --
165 -- Prerequisites:
166 --   This is an internal procedure which is called from the upd procedure.
167 --
168 -- In Parameters:
169 --   A Pl/Sql record structre.
170 --
171 -- Post Success:
172 --   Processing continues.
173 --
174 -- Post Failure:
175 --   If an error has occurred, an error message and exception will be raised
176 --   but not handled.
177 --
178 -- Developer Implementation Notes:
179 --   Any post-processing required after the update dml is issued should be
180 --   coded within this procedure. It is important to note that any 3rd party
181 --   maintenance should be reviewed before placing in this procedure.
182 --
183 -- Access Status:
184 --   Internal Row Handler Use Only.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure post_update(
189 p_effective_date in date,p_rec in ben_xwc_shd.g_rec_type) is
190 --
191   l_proc  varchar2(72) := g_package||'post_update';
192 --
193 Begin
194   hr_utility.set_location('Entering:'||l_proc, 5);
195 --
196   --
197   -- Start of API User Hook for post_update.
198   --
199   begin
200     --
201     ben_xwc_rku.after_update
202       (
203   p_ext_where_clause_id           =>p_rec.ext_where_clause_id
204  ,p_seq_num                       =>p_rec.seq_num
205  ,p_oper_cd                       =>p_rec.oper_cd
206  ,p_val                           =>p_rec.val
207  ,p_and_or_cd                     =>p_rec.and_or_cd
208  ,p_ext_data_elmt_id              =>p_rec.ext_data_elmt_id
209  ,p_cond_ext_data_elmt_id         =>p_rec.cond_ext_data_elmt_id
210  ,p_ext_rcd_in_file_id            =>p_rec.ext_rcd_in_file_id
211  ,p_ext_data_elmt_in_rcd_id       =>p_rec.ext_data_elmt_in_rcd_id
212  ,p_business_group_id             =>p_rec.business_group_id
213  ,p_legislation_code              =>p_rec.legislation_code
214  ,p_object_version_number         =>p_rec.object_version_number
215  ,p_cond_ext_data_elmt_in_rcd_id  =>p_rec.cond_ext_data_elmt_in_rcd_id
216  ,p_effective_date                =>p_effective_date
217  ,p_seq_num_o                     =>ben_xwc_shd.g_old_rec.seq_num
218  ,p_oper_cd_o                     =>ben_xwc_shd.g_old_rec.oper_cd
219  ,p_val_o                         =>ben_xwc_shd.g_old_rec.val
220  ,p_and_or_cd_o                   =>ben_xwc_shd.g_old_rec.and_or_cd
221  ,p_ext_data_elmt_id_o            =>ben_xwc_shd.g_old_rec.ext_data_elmt_id
222  ,p_cond_ext_data_elmt_id_o       =>ben_xwc_shd.g_old_rec.cond_ext_data_elmt_id
223  ,p_ext_rcd_in_file_id_o          =>ben_xwc_shd.g_old_rec.ext_rcd_in_file_id
224  ,p_ext_data_elmt_in_rcd_id_o     =>ben_xwc_shd.g_old_rec.ext_data_elmt_in_rcd_id
225  ,p_business_group_id_o           =>ben_xwc_shd.g_old_rec.business_group_id
226  ,p_legislation_code_o            =>ben_xwc_shd.g_old_rec.legislation_code
227  ,p_object_version_number_o       =>ben_xwc_shd.g_old_rec.object_version_number
228  ,p_cond_ext_data_elmt_in_rcd__o=>ben_xwc_shd.g_old_rec.cond_ext_data_elmt_in_rcd_id
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 => 'ben_ext_where_clause'
237         ,p_hook_type   => 'AU');
238       --
239   end;
240   --
241   -- End of API User Hook for post_update.
242   --
243   --
244   hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End post_update;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |-----------------------------< convert_defs >-----------------------------|
249 -- ----------------------------------------------------------------------------
250 -- {Start Of Comments}
251 --
252 -- Description:
253 --   The Convert_Defs procedure has one very important function:
254 --   It must return the record structure for the row with all system defaulted
255 --   values converted into its corresponding parameter value for update. When
256 --   we attempt to update a row through the Upd process , certain
257 --   parameters can be defaulted which enables flexibility in the calling of
258 --   the upd process (e.g. only attributes which need to be updated need to be
259 --   specified). For the upd process to determine which attributes
260 --   have NOT been specified we need to check if the parameter has a reserved
261 --   system default value. Therefore, for all parameters which have a
262 --   corresponding reserved system default mechanism specified we need to
263 --   check if a system default is being used. If a system default is being
264 --   used then we convert the defaulted value into its corresponding attribute
265 --   value held in the g_old_rec data structure.
266 --
267 -- Prerequisites:
268 --   This private function can only be called from the upd process.
269 --
270 -- In Parameters:
271 --   A Pl/Sql record structre.
272 --
273 -- Post Success:
274 --   The record structure will be returned with all system defaulted parameter
275 --   values converted into its current row attribute value.
276 --
277 -- Post Failure:
278 --   No direct error handling is required within this function. Any possible
279 --   errors within this procedure will be a PL/SQL value error due to conversion
280 --   of datatypes or data lengths.
281 --
282 -- Developer Implementation Notes:
283 --   None.
284 --
285 -- Access Status:
286 --   Internal Row Handler Use Only.
287 --
288 -- {End Of Comments}
289 -- ----------------------------------------------------------------------------
290 Procedure convert_defs(p_rec in out nocopy ben_xwc_shd.g_rec_type) is
291 --
292   l_proc  varchar2(72) := g_package||'convert_defs';
293 --
294 Begin
295   --
296   hr_utility.set_location('Entering:'||l_proc, 5);
297   --
298   -- We must now examine each argument value in the
299   -- p_rec plsql record structure
300   -- to see if a system default is being used. If a system default
301   -- is being used then we must set to the 'current' argument value.
302   --
303   If (p_rec.seq_num = hr_api.g_number) then
304     p_rec.seq_num :=
305     ben_xwc_shd.g_old_rec.seq_num;
306   End If;
307   If (p_rec.oper_cd = hr_api.g_varchar2) then
308     p_rec.oper_cd :=
309     ben_xwc_shd.g_old_rec.oper_cd;
310   End If;
311   If (p_rec.val = hr_api.g_varchar2) then
312     p_rec.val :=
313     ben_xwc_shd.g_old_rec.val;
314   End If;
315   If (p_rec.and_or_cd = hr_api.g_varchar2) then
316     p_rec.and_or_cd :=
317     ben_xwc_shd.g_old_rec.and_or_cd;
318   End If;
319   If (p_rec.ext_data_elmt_id = hr_api.g_number) then
320     p_rec.ext_data_elmt_id :=
321     ben_xwc_shd.g_old_rec.ext_data_elmt_id;
322   End If;
323   If (p_rec.cond_ext_data_elmt_id = hr_api.g_number) then
324     p_rec.cond_ext_data_elmt_id :=
325     ben_xwc_shd.g_old_rec.cond_ext_data_elmt_id;
326   End If;
327   If (p_rec.ext_rcd_in_file_id = hr_api.g_number) then
328     p_rec.ext_rcd_in_file_id :=
329     ben_xwc_shd.g_old_rec.ext_rcd_in_file_id;
330   End If;
331   If (p_rec.ext_data_elmt_in_rcd_id = hr_api.g_number) then
332     p_rec.ext_data_elmt_in_rcd_id :=
333     ben_xwc_shd.g_old_rec.ext_data_elmt_in_rcd_id;
334   End If;
335   If (p_rec.business_group_id = hr_api.g_number) then
336     p_rec.business_group_id :=
337     ben_xwc_shd.g_old_rec.business_group_id;
338   End If;
339   If (p_rec.legislation_code = hr_api.g_varchar2) then
340       p_rec.legislation_code :=
341       ben_xwc_shd.g_old_rec.legislation_code;
342   End If;
343   If (p_rec.cond_ext_data_elmt_in_rcd_id = hr_api.g_number) then
344     p_rec.cond_ext_data_elmt_in_rcd_id :=
345     ben_xwc_shd.g_old_rec.cond_ext_data_elmt_in_rcd_id;
346   End If;
347   --
348   hr_utility.set_location(' Leaving:'||l_proc, 10);
349 --
350 End convert_defs;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |---------------------------------< upd >----------------------------------|
354 -- ----------------------------------------------------------------------------
355 Procedure upd
356   (
357   p_effective_date in date,
358   p_rec        in out nocopy ben_xwc_shd.g_rec_type
359   ) is
360 --
361   l_proc  varchar2(72) := g_package||'upd';
362 --
363 Begin
364   hr_utility.set_location('Entering:'||l_proc, 5);
365   --
366   -- We must lock the row which we need to update.
367   --
368   ben_xwc_shd.lck
369 	(
370 	p_rec.ext_where_clause_id,
371 	p_rec.object_version_number
372 	);
373   --
374   -- 1. During an update system defaults are used to determine if
375   --    arguments have been defaulted or not. We must therefore
376   --    derive the full record structure values to be updated.
377   --
378   -- 2. Call the supporting update validate operations.
379   --
380   convert_defs(p_rec);
381   ben_xwc_bus.update_validate(p_rec
382   ,p_effective_date);
383   --
384   -- Call the supporting pre-update operation
385   --
386   pre_update(p_rec);
387   --
388   -- Update the row.
389   --
390   update_dml(p_rec);
391   --
392   -- Call the supporting post-update operation
393   --
394   post_update(
395 p_effective_date,p_rec);
396 End upd;
397 --
398 -- ----------------------------------------------------------------------------
399 -- |---------------------------------< upd >----------------------------------|
400 -- ----------------------------------------------------------------------------
401 Procedure upd
402   (
403   p_effective_date in date,
404   p_ext_where_clause_id          in number,
405   p_seq_num                      in number           default hr_api.g_number,
406   p_oper_cd                      in varchar2         default hr_api.g_varchar2,
407   p_val                          in varchar2         default hr_api.g_varchar2,
408   p_and_or_cd                    in varchar2         default hr_api.g_varchar2,
409   p_ext_data_elmt_id             in number           default hr_api.g_number,
410   p_cond_ext_data_elmt_id        in number           default hr_api.g_number,
411   p_ext_rcd_in_file_id           in number           default hr_api.g_number,
412   p_ext_data_elmt_in_rcd_id      in number           default hr_api.g_number,
413   p_business_group_id            in number           default hr_api.g_number,
414   p_legislation_code             in varchar2         default hr_api.g_varchar2,
415   p_last_update_date             in date             default hr_api.g_date,
416   p_creation_date                in date             default hr_api.g_date,
417   p_last_updated_by              in number           default hr_api.g_number,
418   p_last_update_login            in number           default hr_api.g_number,
419   p_created_by                   in number           default hr_api.g_number,
420   p_object_version_number        in out nocopy number,
421   p_cond_ext_data_elmt_in_rcd_id in number           default hr_api.g_number
422   ) is
423 --
424   l_rec	  ben_xwc_shd.g_rec_type;
425   l_proc  varchar2(72) := g_package||'upd';
426 --
427 Begin
428   hr_utility.set_location('Entering:'||l_proc, 5);
429   --
430   -- Call conversion function to turn arguments into the
431   -- l_rec structure.
432   --
433   l_rec :=
434   ben_xwc_shd.convert_args
435   (
436   p_ext_where_clause_id,
437   p_seq_num,
438   p_oper_cd,
439   p_val,
440   p_and_or_cd,
441   p_ext_data_elmt_id,
442   p_cond_ext_data_elmt_id,
443   p_ext_rcd_in_file_id,
444   p_ext_data_elmt_in_rcd_id,
445   p_business_group_id,
446   p_legislation_code,
447   p_last_update_date ,
448   p_creation_date    ,
449   p_last_updated_by  ,
450   p_last_update_login,
451   p_created_by       ,
452   p_object_version_number,
453   p_cond_ext_data_elmt_in_rcd_id
454   );
455   --
456   -- Having converted the arguments into the
457   -- plsql record structure we call the corresponding record
458   -- business process.
459   --
460   upd(
461     p_effective_date,l_rec);
462   p_object_version_number := l_rec.object_version_number;
463   --
464   hr_utility.set_location(' Leaving:'||l_proc, 10);
465 End upd;
466 --
467 end ben_xwc_upd;