DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_BBT_UPD

Source


1 Package Body per_bbt_upd as
2 /* $Header: pebbtrhi.pkb 115.7 2002/12/02 13:20:16 apholt noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_bbt_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
55   (p_rec in out nocopy per_bbt_shd.g_rec_type
56   ) is
57 --
58   l_proc  varchar2(72) := g_package||'update_dml';
59 --
60 Begin
61   hr_utility.set_location('Entering:'||l_proc, 5);
62   --
63   -- Increment the object version
64   p_rec.object_version_number := p_rec.object_version_number + 1;
65   --
66   --
67   --
68   -- Update the per_bf_balance_types Row
69   --
70   update per_bf_balance_types
71     set
72      balance_type_id                 = p_rec.balance_type_id
73     ,input_value_id                  = p_rec.input_value_id
74     ,displayed_name                  = p_rec.displayed_name
75     ,internal_name                   = p_rec.internal_name
76     ,uom                             = p_rec.uom
77     ,currency                        = p_rec.currency
78     ,category                        = p_rec.category
79     ,date_from                       = p_rec.date_from
80     ,date_to                         = p_rec.date_to
81     ,object_version_number           = p_rec.object_version_number
82     where balance_type_id = p_rec.balance_type_id;
83   --
84   --
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     --
92     per_bbt_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     --
97     per_bbt_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     --
102     per_bbt_shd.constraint_error
103       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104   When Others Then
105     --
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 structure.
123 --
124 -- Post Success:
125 --   Processing continues.
126 --
127 -- Post Failure:
128 --   If an error has occurred, an error message and exception wil 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
142   (p_rec in per_bbt_shd.g_rec_type
143   ) is
144 --
145   l_proc  varchar2(72) := g_package||'pre_update';
146 --
147 Begin
148   hr_utility.set_location('Entering:'||l_proc, 5);
149   --
150   hr_utility.set_location(' Leaving:'||l_proc, 10);
151 End pre_update;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------------< post_update >------------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 --   This private procedure contains any processing which is required after the
160 --   update dml.
161 --
162 -- Prerequisites:
163 --   This is an internal procedure which is called from the upd procedure.
164 --
165 -- In Parameters:
166 --   A Pl/Sql record structre.
167 --
168 -- Post Success:
169 --   Processing continues.
170 --
171 -- Post Failure:
172 --   If an error has occurred, an error message and exception will be raised
173 --   but not handled.
174 --
175 -- Developer Implementation Notes:
176 --   Any post-processing required after the update dml is issued should be
177 --   coded within this procedure. It is important to note that any 3rd party
178 --   maintenance should be reviewed before placing in this procedure.
179 --
180 -- Access Status:
181 --   Internal Row Handler Use Only.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure post_update
186   (p_effective_date               in date
187   ,p_rec                         in per_bbt_shd.g_rec_type
188   ) is
189 --
190   l_proc  varchar2(72) := g_package||'post_update';
191 --
192 Begin
193   hr_utility.set_location('Entering:'||l_proc, 5);
194   begin
195     --
196     per_bbt_rku.after_update
197       (p_effective_date              => p_effective_date
198       ,p_balance_type_id               => p_rec.balance_type_id
199       ,p_input_value_id               => p_rec.input_value_id
200       ,p_business_group_id            => p_rec.business_group_id
201       ,p_displayed_name               => p_rec.displayed_name
202       ,p_internal_name                => p_rec.internal_name
203       ,p_uom                          => p_rec.uom
204       ,p_currency                     => p_rec.currency
205       ,p_category                     => p_rec.category
206       ,p_date_from                    => p_rec.date_from
207       ,p_date_to                      => p_rec.date_to
208       ,p_object_version_number        => p_rec.object_version_number
209       ,p_input_value_id_o
210       => per_bbt_shd.g_old_rec.input_value_id
211       ,p_business_group_id_o
212       => per_bbt_shd.g_old_rec.business_group_id
213       ,p_displayed_name_o
214       => per_bbt_shd.g_old_rec.displayed_name
215       ,p_internal_name_o
216       => per_bbt_shd.g_old_rec.internal_name
217       ,p_uom_o
218       => per_bbt_shd.g_old_rec.uom
219       ,p_currency_o
220       => per_bbt_shd.g_old_rec.currency
221       ,p_category_o
222       => per_bbt_shd.g_old_rec.category
223       ,p_date_from_o
224       => per_bbt_shd.g_old_rec.date_from
225       ,p_date_to_o
226       => per_bbt_shd.g_old_rec.date_to
227       ,p_object_version_number_o
228       => per_bbt_shd.g_old_rec.object_version_number
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 => 'PER_BF_BALANCE_TYPES'
237         ,p_hook_type   => 'AU');
238       --
239   end;
240   --
241   hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End post_update;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |-----------------------------< convert_defs >-----------------------------|
246 -- ----------------------------------------------------------------------------
247 -- {Start Of Comments}
248 --
249 -- Description:
250 --   The Convert_Defs procedure has one very important function:
251 --   It must return the record structure for the row with all system defaulted
252 --   values converted into its corresponding parameter value for update. When
253 --   we attempt to update a row through the Upd process , certain
254 --   parameters can be defaulted which enables flexibility in the calling of
255 --   the upd process (e.g. only attributes which need to be updated need to be
256 --   specified). For the upd process to determine which attributes
257 --   have NOT been specified we need to check if the parameter has a reserved
258 --   system default value. Therefore, for all parameters which have a
259 --   corresponding reserved system default mechanism specified we need to
260 --   check if a system default is being used. If a system default is being
261 --   used then we convert the defaulted value into its corresponding attribute
262 --   value held in the g_old_rec data structure.
263 --
264 -- Prerequisites:
265 --   This private function can only be called from the upd process.
266 --
267 -- In Parameters:
268 --   A Pl/Sql record structre.
269 --
270 -- Post Success:
271 --   The record structure will be returned with all system defaulted parameter
272 --   values converted into its current row attribute value.
273 --
274 -- Post Failure:
275 --   No direct error handling is required within this function. Any possible
276 --   errors within this procedure will be a PL/SQL value error due to
277 --   conversion of datatypes or data lengths.
278 --
279 -- Developer Implementation Notes:
280 --   None.
281 --
282 -- Access Status:
283 --   Internal Row Handler Use Only.
284 --
285 -- {End Of Comments}
286 -- ----------------------------------------------------------------------------
287 Procedure convert_defs
288   (p_rec in out nocopy per_bbt_shd.g_rec_type
289   ) is
290 --
291   l_proc  varchar2(72) := g_package||'convert_defs';
292 --
293 Begin
294   --
295   hr_utility.set_location('Entering:'||l_proc, 5);
296   --
297   -- We must now examine each argument value in the
298   -- p_rec plsql record structure
299   -- to see if a system default is being used. If a system default
300   -- is being used then we must set to the 'current' argument value.
301   --
302   If (p_rec.input_value_id = hr_api.g_number) then
303     p_rec.input_value_id :=
304     per_bbt_shd.g_old_rec.input_value_id;
305   End If;
306   If (p_rec.business_group_id = hr_api.g_number) then
307     p_rec.business_group_id :=
308     per_bbt_shd.g_old_rec.business_group_id;
309   End If;
310   If (p_rec.displayed_name = hr_api.g_varchar2) then
311     p_rec.displayed_name :=
312     per_bbt_shd.g_old_rec.displayed_name;
313   End If;
314   If (p_rec.internal_name = hr_api.g_varchar2) then
315     p_rec.internal_name :=
316     per_bbt_shd.g_old_rec.internal_name;
317   End If;
318   If (p_rec.uom = hr_api.g_varchar2) then
319     p_rec.uom :=
320     per_bbt_shd.g_old_rec.uom;
321   End If;
322   If (p_rec.currency = hr_api.g_varchar2) then
323     p_rec.currency :=
324     per_bbt_shd.g_old_rec.currency;
325   End If;
326   If (p_rec.category = hr_api.g_varchar2) then
327     p_rec.category :=
328     per_bbt_shd.g_old_rec.category;
329   End If;
330   If (p_rec.date_from = hr_api.g_date) then
331     p_rec.date_from :=
332     per_bbt_shd.g_old_rec.date_from;
333   End If;
334   If (p_rec.date_to = hr_api.g_date) then
335     p_rec.date_to :=
336     per_bbt_shd.g_old_rec.date_to;
337   End If;
338   --
339   hr_utility.set_location(' Leaving:'||l_proc, 10);
340 --
341 End convert_defs;
342 --
343 -- ----------------------------------------------------------------------------
344 -- |---------------------------------< upd >----------------------------------|
345 -- ----------------------------------------------------------------------------
346 Procedure upd
347   (p_effective_date               in date
348   ,p_rec                          in out nocopy per_bbt_shd.g_rec_type
349   ) is
350 --
351   l_proc  varchar2(72) := g_package||'upd';
352 --
353 Begin
354   hr_utility.set_location('Entering:'||l_proc, 5);
355   --
356   -- We must lock the row which we need to update.
357   --
358   per_bbt_shd.lck
359     (p_rec.balance_type_id
360     ,p_rec.object_version_number
361     );
362   --
363   -- 1. During an update system defaults are used to determine if
364   --    arguments have been defaulted or not. We must therefore
365   --    derive the full record structure values to be updated.
366   --
367   -- 2. Call the supporting update validate operations.
368   --
369   convert_defs(p_rec);
370   per_bbt_bus.update_validate
371      (p_effective_date
372      ,p_rec
373      );
374   --
375   -- Call the supporting pre-update operation
376   --
377   pre_update(p_rec);
378   --
379   -- Update the row.
380   --
381   update_dml(p_rec);
382   --
383   -- Call the supporting post-update operation
384   --
385   post_update
386      (p_effective_date
387      ,p_rec
388      );
389 End upd;
390 --
391 -- ----------------------------------------------------------------------------
392 -- |---------------------------------< upd >----------------------------------|
393 -- ----------------------------------------------------------------------------
394 Procedure upd
395   (p_effective_date               in date
396   ,p_balance_type_id              in number
397   ,p_input_value_id               in number     default hr_api.g_number
398   ,p_displayed_name               in varchar2   default hr_api.g_varchar2
399   ,p_internal_name               in varchar2   default hr_api.g_varchar2
400   ,p_uom                          in varchar2   default hr_api.g_varchar2
401   ,p_currency                     in varchar2   default hr_api.g_varchar2
402   ,p_category                     in varchar2   default hr_api.g_varchar2
403   ,p_date_from                    in date       default hr_api.g_date
404   ,p_date_to                      in date       default hr_api.g_date
405   ,p_object_version_number        in out nocopy number
406   ) is
407 --
408   l_rec	  per_bbt_shd.g_rec_type;
409   l_proc  varchar2(72) := g_package||'upd';
410 --
411 Begin
412   hr_utility.set_location('Entering:'||l_proc, 5);
413   --
414   -- Call conversion function to turn arguments into the
415   -- l_rec structure.
416   --
417   l_rec :=
418   per_bbt_shd.convert_args
419   (p_balance_type_id
420   ,p_input_value_id
421   ,hr_api.g_number
422   ,p_displayed_name
423   ,p_internal_name
424   ,p_uom
425   ,p_currency
426   ,p_category
427   ,p_date_from
428   ,p_date_to
429   ,p_object_version_number
430   );
431   --
432   -- Having converted the arguments into the
433   -- plsql record structure we call the corresponding record
434   -- business process.
435   --
436   upd(p_effective_date
437      ,l_rec
438      );
439   p_object_version_number := l_rec.object_version_number;
440   --
441   hr_utility.set_location(' Leaving:'||l_proc, 10);
442 End upd;
443 --
444 end per_bbt_upd;