DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_DEL_UPD

Source


1 Package Body pqh_del_upd as
2 /* $Header: pqdelrhi.pkb 115.7 2002/12/05 19:31:43 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_del_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_del_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_dflt_budget_elements Row
61   --
62   update pqh_dflt_budget_elements
63   set
64   dflt_budget_element_id            = p_rec.dflt_budget_element_id,
65   dflt_budget_set_id                = p_rec.dflt_budget_set_id,
66   element_type_id                   = p_rec.element_type_id,
67   dflt_dist_percentage              = p_rec.dflt_dist_percentage,
68   object_version_number             = p_rec.object_version_number
69   where dflt_budget_element_id = p_rec.dflt_budget_element_id;
70   --
71   --
72   hr_utility.set_location(' Leaving:'||l_proc, 10);
73 --
74 Exception
75   When hr_api.check_integrity_violated Then
76     -- A check constraint has been violated
77     pqh_del_shd.constraint_error
78       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
79   When hr_api.parent_integrity_violated Then
80     -- Parent integrity has been violated
81     pqh_del_shd.constraint_error
82       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
83   When hr_api.unique_integrity_violated Then
84     -- Unique integrity has been violated
85     pqh_del_shd.constraint_error
86       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
87   When Others Then
88     Raise;
89 End update_dml;
90 --
91 -- ----------------------------------------------------------------------------
92 -- |------------------------------< pre_update >------------------------------|
93 -- ----------------------------------------------------------------------------
94 -- {Start Of Comments}
95 --
96 -- Description:
97 --   This private procedure contains any processing which is required before
98 --   the update dml.
99 --
100 -- Prerequisites:
101 --   This is an internal procedure which is called from the upd procedure.
102 --
103 -- In Parameters:
104 --   A Pl/Sql record structre.
105 --
106 -- Post Success:
107 --   Processing continues.
108 --
109 -- Post Failure:
110 --   If an error has occurred, an error message and exception will be raised
111 --   but not handled.
112 --
113 -- Developer Implementation Notes:
114 --   Any pre-processing required before the update dml is issued should be
115 --   coded within this procedure. It is important to note that any 3rd party
116 --   maintenance should be reviewed before placing in this procedure.
117 --
118 -- Access Status:
119 --   Internal Row Handler Use Only.
120 --
121 -- {End Of Comments}
122 -- ----------------------------------------------------------------------------
123 Procedure pre_update(p_rec in pqh_del_shd.g_rec_type) is
124 --
125   l_proc  varchar2(72) := g_package||'pre_update';
126 --
127 Begin
128   hr_utility.set_location('Entering:'||l_proc, 5);
129   --
130   hr_utility.set_location(' Leaving:'||l_proc, 10);
131 End pre_update;
132 --
133 -- ----------------------------------------------------------------------------
134 -- |-----------------------------< post_update >------------------------------|
135 -- ----------------------------------------------------------------------------
136 -- {Start Of Comments}
137 --
138 -- Description:
139 --   This private procedure contains any processing which is required after the
140 --   update dml.
141 --
142 -- Prerequisites:
143 --   This is an internal procedure which is called from the upd procedure.
144 --
145 -- In Parameters:
146 --   A Pl/Sql record structre.
147 --
148 -- Post Success:
149 --   Processing continues.
150 --
151 -- Post Failure:
152 --   If an error has occurred, an error message and exception will be raised
153 --   but not handled.
154 --
155 -- Developer Implementation Notes:
156 --   Any post-processing required after the update dml is issued should be
157 --   coded within this procedure. It is important to note that any 3rd party
158 --   maintenance should be reviewed before placing in this procedure.
159 --
160 -- Access Status:
161 --   Internal Row Handler Use Only.
162 --
163 -- {End Of Comments}
164 -- ----------------------------------------------------------------------------
165 Procedure post_update(p_rec in pqh_del_shd.g_rec_type) is
166 --
167   l_proc  varchar2(72) := g_package||'post_update';
168 --
169 -- check if sum of percentage is more then 100 after the update
170 --
171 l_sum       number(15,2) := 0;
172 
173  cursor csr_element(p_dflt_budget_set_id in number) is
174  select SUM(NVL(dflt_dist_percentage,0))
175  from pqh_dflt_budget_elements
176  where dflt_budget_set_id = p_dflt_budget_set_id;
177 
178 
179 --
180 Begin
181   hr_utility.set_location('Entering:'||l_proc, 5);
182 --
183   --
184   open csr_element(p_dflt_budget_set_id      => p_rec.dflt_budget_set_id );
185    fetch csr_element into l_sum;
186   close csr_element;
187 
188    if l_sum > 100 then
189      -- sum cannot be more then 100
190      --
191       hr_utility.set_message(8302,'PQH_WKS_INVALID_ELMNT_SUM');
192       hr_utility.raise_error;
193     --
194    end if;
195   --
196   --
197   -- Start of API User Hook for post_update.
198   --
199   begin
200     --
201     pqh_del_rku.after_update
202       (
203   p_dflt_budget_element_id        =>p_rec.dflt_budget_element_id
204  ,p_dflt_budget_set_id            =>p_rec.dflt_budget_set_id
205  ,p_element_type_id               =>p_rec.element_type_id
206  ,p_dflt_dist_percentage          =>p_rec.dflt_dist_percentage
207  ,p_object_version_number         =>p_rec.object_version_number
208  ,p_dflt_budget_set_id_o          =>pqh_del_shd.g_old_rec.dflt_budget_set_id
209  ,p_element_type_id_o             =>pqh_del_shd.g_old_rec.element_type_id
210  ,p_dflt_dist_percentage_o        =>pqh_del_shd.g_old_rec.dflt_dist_percentage
211  ,p_object_version_number_o       =>pqh_del_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 => 'pqh_dflt_budget_elements'
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 pqh_del_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.dflt_budget_set_id = hr_api.g_number) then
287     p_rec.dflt_budget_set_id :=
288     pqh_del_shd.g_old_rec.dflt_budget_set_id;
289   End If;
290   If (p_rec.element_type_id = hr_api.g_number) then
291     p_rec.element_type_id :=
292     pqh_del_shd.g_old_rec.element_type_id;
293   End If;
294   If (p_rec.dflt_dist_percentage = hr_api.g_number) then
295     p_rec.dflt_dist_percentage :=
296     pqh_del_shd.g_old_rec.dflt_dist_percentage;
297   End If;
298 
299   --
300   hr_utility.set_location(' Leaving:'||l_proc, 10);
301 --
302 End convert_defs;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------------< upd >----------------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure upd
308   (
309   p_rec        in out nocopy pqh_del_shd.g_rec_type
310   ) is
311 --
312   l_proc  varchar2(72) := g_package||'upd';
313 --
314 Begin
315   hr_utility.set_location('Entering:'||l_proc, 5);
316   --
317   -- We must lock the row which we need to update.
318   --
319   pqh_del_shd.lck
320 	(
321 	p_rec.dflt_budget_element_id,
322 	p_rec.object_version_number
323 	);
324   --
325   -- 1. During an update system defaults are used to determine if
326   --    arguments have been defaulted or not. We must therefore
327   --    derive the full record structure values to be updated.
328   --
329   -- 2. Call the supporting update validate operations.
330   --
331   convert_defs(p_rec);
332   pqh_del_bus.update_validate(p_rec);
333   --
334   -- Call the supporting pre-update operation
335   --
336   pre_update(p_rec);
337   --
338   -- Update the row.
339   --
340   update_dml(p_rec);
341   --
342   -- Call the supporting post-update operation
343   --
344   post_update(p_rec);
345 End upd;
346 --
347 -- ----------------------------------------------------------------------------
348 -- |---------------------------------< upd >----------------------------------|
349 -- ----------------------------------------------------------------------------
350 Procedure upd
351   (
352   p_dflt_budget_element_id       in number,
353   p_dflt_budget_set_id           in number           default hr_api.g_number,
354   p_element_type_id              in number           default hr_api.g_number,
355   p_dflt_dist_percentage         in number           default hr_api.g_number,
356   p_object_version_number        in out nocopy number
357   ) is
358 --
359   l_rec	  pqh_del_shd.g_rec_type;
360   l_proc  varchar2(72) := g_package||'upd';
361 --
362 Begin
363   hr_utility.set_location('Entering:'||l_proc, 5);
364   --
365   -- Call conversion function to turn arguments into the
366   -- l_rec structure.
367   --
368   l_rec :=
369   pqh_del_shd.convert_args
370   (
371   p_dflt_budget_element_id,
372   p_dflt_budget_set_id,
373   p_element_type_id,
374   p_dflt_dist_percentage,
375   p_object_version_number
376   );
377   --
378   -- Having converted the arguments into the
379   -- plsql record structure we call the corresponding record
380   -- business process.
381   --
382   upd(l_rec);
383   p_object_version_number := l_rec.object_version_number;
384   --
385   hr_utility.set_location(' Leaving:'||l_proc, 10);
386 End upd;
387 --
388 end pqh_del_upd;