DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BPR_UPD

Source


1 Package Body pqh_bpr_upd as
2 /* $Header: pqbprrhi.pkb 115.8 2002/12/05 19:29:59 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_bpr_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 --   3) To update the specified row in the schema using the primary key in
21 --      the predicates.
22 --   4) To trap any constraint violations that may have occurred.
23 --   5) To raise any other errors.
24 --
25 -- Prerequisites:
26 --   This is an internal private procedure which must be called from the upd
27 --   procedure.
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be updated in the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   The update 'set' attribute list should be modified if any of your
41 --   attributes are not updateable.
42 --
43 -- Access Status:
44 --   Internal Row Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out nocopy pqh_bpr_shd.g_rec_type) is
49 --
50   l_proc  varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53   hr_utility.set_location('Entering:'||l_proc, 5);
54   --
55   -- Increment the object version
56   --
57   p_rec.object_version_number := p_rec.object_version_number + 1;
58   --
59   --
60   -- Update the pqh_budget_periods Row
61   --
62   update pqh_budget_periods
63   set
64   budget_period_id                  = p_rec.budget_period_id,
65   budget_detail_id                  = p_rec.budget_detail_id,
66   start_time_period_id              = p_rec.start_time_period_id,
67   end_time_period_id                = p_rec.end_time_period_id,
68   budget_unit1_percent              = p_rec.budget_unit1_percent,
69   budget_unit2_percent              = p_rec.budget_unit2_percent,
70   budget_unit3_percent              = p_rec.budget_unit3_percent,
71   budget_unit1_value                = p_rec.budget_unit1_value,
72   budget_unit2_value                = p_rec.budget_unit2_value,
73   budget_unit3_value                = p_rec.budget_unit3_value,
74   budget_unit1_value_type_cd                 = p_rec.budget_unit1_value_type_cd,
75   budget_unit2_value_type_cd                 = p_rec.budget_unit2_value_type_cd,
76   budget_unit3_value_type_cd                 = p_rec.budget_unit3_value_type_cd,
77   budget_unit1_available             = p_rec.budget_unit1_available,
78   budget_unit2_available             = p_rec.budget_unit2_available,
79   budget_unit3_available             = p_rec.budget_unit3_available,
80   object_version_number             = p_rec.object_version_number
81   where budget_period_id = p_rec.budget_period_id;
82   --
83   --
84   hr_utility.set_location(' Leaving:'||l_proc, 10);
85 --
86 Exception
87   When hr_api.check_integrity_violated Then
88     -- A check constraint has been violated
89     pqh_bpr_shd.constraint_error
90       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91   When hr_api.parent_integrity_violated Then
92     -- Parent integrity has been violated
93     pqh_bpr_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     pqh_bpr_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When Others Then
100     Raise;
101 End update_dml;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |------------------------------< pre_update >------------------------------|
105 -- ----------------------------------------------------------------------------
106 -- {Start Of Comments}
107 --
108 -- Description:
109 --   This private procedure contains any processing which is required before
110 --   the update dml.
111 --
112 -- Prerequisites:
113 --   This is an internal procedure which is called from the upd procedure.
114 --
115 -- In Parameters:
116 --   A Pl/Sql record structre.
117 --
118 -- Post Success:
119 --   Processing continues.
120 --
121 -- Post Failure:
122 --   If an error has occurred, an error message and exception will be raised
123 --   but not handled.
124 --
125 -- Developer Implementation Notes:
126 --   Any pre-processing required before the update dml is issued should be
127 --   coded within this procedure. It is important to note that any 3rd party
128 --   maintenance should be reviewed before placing in this procedure.
129 --
130 -- Access Status:
131 --   Internal Row Handler Use Only.
132 --
133 -- {End Of Comments}
134 -- ----------------------------------------------------------------------------
135 Procedure pre_update(p_rec in pqh_bpr_shd.g_rec_type) is
136 --
137   l_proc  varchar2(72) := g_package||'pre_update';
138 --
139 Begin
140   hr_utility.set_location('Entering:'||l_proc, 5);
141   --
142   hr_utility.set_location(' Leaving:'||l_proc, 10);
143 End pre_update;
144 --
145 -- ----------------------------------------------------------------------------
146 -- |-----------------------------< post_update >------------------------------|
147 -- ----------------------------------------------------------------------------
148 -- {Start Of Comments}
149 --
150 -- Description:
151 --   This private procedure contains any processing which is required after the
152 --   update dml.
153 --
154 -- Prerequisites:
155 --   This is an internal procedure which is called from the upd procedure.
156 --
157 -- In Parameters:
158 --   A Pl/Sql record structre.
159 --
160 -- Post Success:
161 --   Processing continues.
162 --
163 -- Post Failure:
164 --   If an error has occurred, an error message and exception will be raised
165 --   but not handled.
166 --
167 -- Developer Implementation Notes:
168 --   Any post-processing required after the update dml is issued should be
169 --   coded within this procedure. It is important to note that any 3rd party
170 --   maintenance should be reviewed before placing in this procedure.
171 --
172 -- Access Status:
173 --   Internal Row Handler Use Only.
174 --
175 -- {End Of Comments}
176 -- ----------------------------------------------------------------------------
177 Procedure post_update(p_rec in pqh_bpr_shd.g_rec_type) is
178 --
179   l_proc  varchar2(72) := g_package||'post_update';
180 --
181 Begin
182   hr_utility.set_location('Entering:'||l_proc, 5);
183 --
184   --
185   -- Start of API User Hook for post_update.
186   --
187   begin
188     --
189     pqh_bpr_rku.after_update
190       (
191   p_budget_period_id              =>p_rec.budget_period_id
192  ,p_budget_detail_id              =>p_rec.budget_detail_id
193  ,p_start_time_period_id          =>p_rec.start_time_period_id
194  ,p_end_time_period_id            =>p_rec.end_time_period_id
195  ,p_budget_unit1_percent          =>p_rec.budget_unit1_percent
196  ,p_budget_unit2_percent          =>p_rec.budget_unit2_percent
197  ,p_budget_unit3_percent          =>p_rec.budget_unit3_percent
198  ,p_budget_unit1_value            =>p_rec.budget_unit1_value
199  ,p_budget_unit2_value            =>p_rec.budget_unit2_value
200  ,p_budget_unit3_value            =>p_rec.budget_unit3_value
201  ,p_budget_unit1_value_type_cd             =>p_rec.budget_unit1_value_type_cd
202  ,p_budget_unit2_value_type_cd             =>p_rec.budget_unit2_value_type_cd
203  ,p_budget_unit3_value_type_cd             =>p_rec.budget_unit3_value_type_cd
204  ,p_budget_unit1_available         =>p_rec.budget_unit1_available
205  ,p_budget_unit2_available         =>p_rec.budget_unit2_available
206  ,p_budget_unit3_available         =>p_rec.budget_unit3_available
207  ,p_object_version_number         =>p_rec.object_version_number
208  ,p_budget_detail_id_o            =>pqh_bpr_shd.g_old_rec.budget_detail_id
209  ,p_start_time_period_id_o        =>pqh_bpr_shd.g_old_rec.start_time_period_id
210  ,p_end_time_period_id_o          =>pqh_bpr_shd.g_old_rec.end_time_period_id
211  ,p_budget_unit1_percent_o        =>pqh_bpr_shd.g_old_rec.budget_unit1_percent
212  ,p_budget_unit2_percent_o        =>pqh_bpr_shd.g_old_rec.budget_unit2_percent
213  ,p_budget_unit3_percent_o        =>pqh_bpr_shd.g_old_rec.budget_unit3_percent
214  ,p_budget_unit1_value_o          =>pqh_bpr_shd.g_old_rec.budget_unit1_value
215  ,p_budget_unit2_value_o          =>pqh_bpr_shd.g_old_rec.budget_unit2_value
216  ,p_budget_unit3_value_o          =>pqh_bpr_shd.g_old_rec.budget_unit3_value
217  ,p_budget_unit1_value_type_cd_o           =>pqh_bpr_shd.g_old_rec.budget_unit1_value_type_cd
218  ,p_budget_unit2_value_type_cd_o           =>pqh_bpr_shd.g_old_rec.budget_unit2_value_type_cd
219  ,p_budget_unit3_value_type_cd_o           =>pqh_bpr_shd.g_old_rec.budget_unit3_value_type_cd
220  ,p_budget_unit1_available_o       =>pqh_bpr_shd.g_old_rec.budget_unit1_available
221  ,p_budget_unit2_available_o       =>pqh_bpr_shd.g_old_rec.budget_unit2_available
222  ,p_budget_unit3_available_o       =>pqh_bpr_shd.g_old_rec.budget_unit3_available
223  ,p_object_version_number_o       =>pqh_bpr_shd.g_old_rec.object_version_number
224       );
225     --
226   exception
227     --
228     when hr_api.cannot_find_prog_unit then
229       --
230       hr_api.cannot_find_prog_unit_error
231         (p_module_name => 'pqh_budget_periods'
232         ,p_hook_type   => 'AU');
233       --
234   end;
235   --
236   -- End of API User Hook for post_update.
237   --
238   --
239   hr_utility.set_location(' Leaving:'||l_proc, 10);
240 End post_update;
241 --
242 -- ----------------------------------------------------------------------------
243 -- |-----------------------------< convert_defs >-----------------------------|
244 -- ----------------------------------------------------------------------------
245 -- {Start Of Comments}
246 --
247 -- Description:
248 --   The Convert_Defs procedure has one very important function:
249 --   It must return the record structure for the row with all system defaulted
250 --   values converted into its corresponding parameter value for update. When
251 --   we attempt to update a row through the Upd process , certain
252 --   parameters can be defaulted which enables flexibility in the calling of
253 --   the upd process (e.g. only attributes which need to be updated need to be
254 --   specified). For the upd process to determine which attributes
255 --   have NOT been specified we need to check if the parameter has a reserved
256 --   system default value. Therefore, for all parameters which have a
257 --   corresponding reserved system default mechanism specified we need to
258 --   check if a system default is being used. If a system default is being
259 --   used then we convert the defaulted value into its corresponding attribute
260 --   value held in the g_old_rec data structure.
261 --
262 -- Prerequisites:
263 --   This private function can only be called from the upd process.
264 --
265 -- In Parameters:
266 --   A Pl/Sql record structre.
267 --
268 -- Post Success:
269 --   The record structure will be returned with all system defaulted parameter
270 --   values converted into its current row attribute value.
271 --
272 -- Post Failure:
273 --   No direct error handling is required within this function. Any possible
274 --   errors within this procedure will be a PL/SQL value error due to conversion
275 --   of datatypes or data lengths.
276 --
277 -- Developer Implementation Notes:
278 --   None.
279 --
280 -- Access Status:
281 --   Internal Row Handler Use Only.
282 --
283 -- {End Of Comments}
284 -- ----------------------------------------------------------------------------
285 Procedure convert_defs(p_rec in out nocopy pqh_bpr_shd.g_rec_type) is
286 --
287   l_proc  varchar2(72) := g_package||'convert_defs';
288 --
289 Begin
290   --
291   hr_utility.set_location('Entering:'||l_proc, 5);
292   --
293   -- We must now examine each argument value in the
294   -- p_rec plsql record structure
295   -- to see if a system default is being used. If a system default
296   -- is being used then we must set to the 'current' argument value.
297   --
298   If (p_rec.budget_detail_id = hr_api.g_number) then
299     p_rec.budget_detail_id :=
300     pqh_bpr_shd.g_old_rec.budget_detail_id;
301   End If;
302   If (p_rec.start_time_period_id = hr_api.g_number) then
303     p_rec.start_time_period_id :=
304     pqh_bpr_shd.g_old_rec.start_time_period_id;
305   End If;
306   If (p_rec.end_time_period_id = hr_api.g_number) then
307     p_rec.end_time_period_id :=
308     pqh_bpr_shd.g_old_rec.end_time_period_id;
309   End If;
310   If (p_rec.budget_unit1_percent = hr_api.g_number) then
311     p_rec.budget_unit1_percent :=
312     pqh_bpr_shd.g_old_rec.budget_unit1_percent;
313   End If;
314   If (p_rec.budget_unit2_percent = hr_api.g_number) then
315     p_rec.budget_unit2_percent :=
316     pqh_bpr_shd.g_old_rec.budget_unit2_percent;
317   End If;
318   If (p_rec.budget_unit3_percent = hr_api.g_number) then
319     p_rec.budget_unit3_percent :=
320     pqh_bpr_shd.g_old_rec.budget_unit3_percent;
321   End If;
322   If (p_rec.budget_unit1_value = hr_api.g_number) then
323     p_rec.budget_unit1_value :=
324     pqh_bpr_shd.g_old_rec.budget_unit1_value;
325   End If;
326   If (p_rec.budget_unit2_value = hr_api.g_number) then
327     p_rec.budget_unit2_value :=
328     pqh_bpr_shd.g_old_rec.budget_unit2_value;
329   End If;
330   If (p_rec.budget_unit3_value = hr_api.g_number) then
331     p_rec.budget_unit3_value :=
332     pqh_bpr_shd.g_old_rec.budget_unit3_value;
333   End If;
334   If (p_rec.budget_unit1_value_type_cd = hr_api.g_varchar2) then
335     p_rec.budget_unit1_value_type_cd :=
336     pqh_bpr_shd.g_old_rec.budget_unit1_value_type_cd;
337   End If;
338   If (p_rec.budget_unit2_value_type_cd = hr_api.g_varchar2) then
339     p_rec.budget_unit2_value_type_cd :=
340     pqh_bpr_shd.g_old_rec.budget_unit2_value_type_cd;
341   End If;
342   If (p_rec.budget_unit3_value_type_cd = hr_api.g_varchar2) then
343     p_rec.budget_unit3_value_type_cd :=
344     pqh_bpr_shd.g_old_rec.budget_unit3_value_type_cd;
345   End If;
346   If (p_rec.budget_unit1_available = hr_api.g_number) then
347     p_rec.budget_unit1_available :=
348     pqh_bpr_shd.g_old_rec.budget_unit1_available;
349   End If;
350   If (p_rec.budget_unit2_available = hr_api.g_number) then
351     p_rec.budget_unit2_available :=
352     pqh_bpr_shd.g_old_rec.budget_unit2_available;
353   End If;
354   If (p_rec.budget_unit3_available = hr_api.g_number) then
355     p_rec.budget_unit3_available :=
356     pqh_bpr_shd.g_old_rec.budget_unit3_available;
357   End If;
358 
359   --
360   hr_utility.set_location(' Leaving:'||l_proc, 10);
361 --
362 End convert_defs;
363 --
364 -- ----------------------------------------------------------------------------
365 -- |---------------------------------< upd >----------------------------------|
366 -- ----------------------------------------------------------------------------
367 Procedure upd
368   (
369   p_rec        in out nocopy pqh_bpr_shd.g_rec_type
370   ) is
371 --
372   l_proc  varchar2(72) := g_package||'upd';
373 --
374 Begin
375   hr_utility.set_location('Entering:'||l_proc, 5);
376   --
377   -- We must lock the row which we need to update.
378   --
379   pqh_bpr_shd.lck
380 	(
381 	p_rec.budget_period_id,
382 	p_rec.object_version_number
383 	);
384   --
385   -- 1. During an update system defaults are used to determine if
386   --    arguments have been defaulted or not. We must therefore
387   --    derive the full record structure values to be updated.
388   --
389   -- 2. Call the supporting update validate operations.
390   --
391   convert_defs(p_rec);
392   pqh_bpr_bus.update_validate(p_rec);
393   --
394   -- Call the supporting pre-update operation
395   --
396   pre_update(p_rec);
397   --
398   -- Update the row.
399   --
400   update_dml(p_rec);
401   --
402   -- Call the supporting post-update operation
403   --
404   post_update(p_rec);
405 End upd;
406 --
407 -- ----------------------------------------------------------------------------
408 -- |---------------------------------< upd >----------------------------------|
409 -- ----------------------------------------------------------------------------
410 Procedure upd
411   (
412   p_budget_period_id             in number,
413   p_budget_detail_id             in number           default hr_api.g_number,
414   p_start_time_period_id         in number           default hr_api.g_number,
415   p_end_time_period_id           in number           default hr_api.g_number,
416   p_budget_unit1_percent         in number           default hr_api.g_number,
417   p_budget_unit2_percent         in number           default hr_api.g_number,
418   p_budget_unit3_percent         in number           default hr_api.g_number,
419   p_budget_unit1_value           in number           default hr_api.g_number,
420   p_budget_unit2_value           in number           default hr_api.g_number,
421   p_budget_unit3_value           in number           default hr_api.g_number,
422   p_budget_unit1_value_type_cd            in varchar2         default hr_api.g_varchar2,
423   p_budget_unit2_value_type_cd            in varchar2         default hr_api.g_varchar2,
424   p_budget_unit3_value_type_cd            in varchar2         default hr_api.g_varchar2,
425   p_budget_unit1_available        in number           default hr_api.g_number,
426   p_budget_unit2_available        in number           default hr_api.g_number,
427   p_budget_unit3_available        in number           default hr_api.g_number,
428   p_object_version_number        in out nocopy number
429   ) is
430 --
431   l_rec	  pqh_bpr_shd.g_rec_type;
432   l_proc  varchar2(72) := g_package||'upd';
433 --
434 Begin
435   hr_utility.set_location('Entering:'||l_proc, 5);
436   --
437   -- Call conversion function to turn arguments into the
438   -- l_rec structure.
439   --
440   l_rec :=
441   pqh_bpr_shd.convert_args
442   (
443   p_budget_period_id,
444   p_budget_detail_id,
445   p_start_time_period_id,
446   p_end_time_period_id,
447   p_budget_unit1_percent,
448   p_budget_unit2_percent,
449   p_budget_unit3_percent,
450   p_budget_unit1_value,
451   p_budget_unit2_value,
452   p_budget_unit3_value,
453   p_budget_unit1_value_type_cd,
454   p_budget_unit2_value_type_cd,
455   p_budget_unit3_value_type_cd,
456   p_budget_unit1_available,
457   p_budget_unit2_available,
458   p_budget_unit3_available,
459   p_object_version_number
460   );
461   --
462   -- Having converted the arguments into the
463   -- plsql record structure we call the corresponding record
464   -- business process.
465   --
466   upd(l_rec);
467   p_object_version_number := l_rec.object_version_number;
468   --
469   hr_utility.set_location(' Leaving:'||l_proc, 10);
470 End upd;
471 --
472 end pqh_bpr_upd;