DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BBP_UPD

Source


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