DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_WEL_UPD

Source


1 Package Body pqh_wel_upd as
2 /* $Header: pqwelrhi.pkb 115.4 2002/12/13 00:36:31 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_wel_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 update the specified row in the schema using the primary key in
21 --      the predicates.
22 --   3) To trap any constraint violations that may have occurred.
23 --   4) 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_wel_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_worksheet_bdgt_elmnts Row
61   --
62   update pqh_worksheet_bdgt_elmnts
63   set
64   worksheet_bdgt_elmnt_id           = p_rec.worksheet_bdgt_elmnt_id,
65   worksheet_budget_set_id           = p_rec.worksheet_budget_set_id,
66   element_type_id                   = p_rec.element_type_id,
67   distribution_percentage           = p_rec.distribution_percentage,
68   object_version_number             = p_rec.object_version_number
69   where worksheet_bdgt_elmnt_id = p_rec.worksheet_bdgt_elmnt_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_wel_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_wel_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_wel_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_wel_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_wel_shd.g_rec_type) is
166 --
167   l_proc  varchar2(72) := g_package||'post_update';
168 --
169 Begin
170   hr_utility.set_location('Entering:'||l_proc, 5);
171 --
172   --
173   -- Start of API User Hook for post_update.
174   --
175   begin
176     --
177     pqh_wel_rku.after_update
178       (
179   p_worksheet_bdgt_elmnt_id       =>p_rec.worksheet_bdgt_elmnt_id
180  ,p_worksheet_budget_set_id       =>p_rec.worksheet_budget_set_id
181  ,p_element_type_id               =>p_rec.element_type_id
182  ,p_distribution_percentage       =>p_rec.distribution_percentage
183  ,p_object_version_number         =>p_rec.object_version_number
184  ,p_worksheet_budget_set_id_o     =>pqh_wel_shd.g_old_rec.worksheet_budget_set_id
185  ,p_element_type_id_o             =>pqh_wel_shd.g_old_rec.element_type_id
186  ,p_distribution_percentage_o     =>pqh_wel_shd.g_old_rec.distribution_percentage
187  ,p_object_version_number_o       =>pqh_wel_shd.g_old_rec.object_version_number
188       );
189     --
190   exception
191     --
192     when hr_api.cannot_find_prog_unit then
193       --
194       hr_api.cannot_find_prog_unit_error
195         (p_module_name => 'pqh_worksheet_bdgt_elmnts'
196         ,p_hook_type   => 'AU');
197       --
198   end;
199   --
200   -- End of API User Hook for post_update.
201   --
202   --
203   hr_utility.set_location(' Leaving:'||l_proc, 10);
204 End post_update;
205 --
206 -- ----------------------------------------------------------------------------
207 -- |-----------------------------< convert_defs >-----------------------------|
208 -- ----------------------------------------------------------------------------
209 -- {Start Of Comments}
210 --
211 -- Description:
212 --   The Convert_Defs procedure has one very important function:
213 --   It must return the record structure for the row with all system defaulted
214 --   values converted into its corresponding parameter value for update. When
215 --   we attempt to update a row through the Upd process , certain
216 --   parameters can be defaulted which enables flexibility in the calling of
217 --   the upd process (e.g. only attributes which need to be updated need to be
218 --   specified). For the upd process to determine which attributes
219 --   have NOT been specified we need to check if the parameter has a reserved
220 --   system default value. Therefore, for all parameters which have a
221 --   corresponding reserved system default mechanism specified we need to
222 --   check if a system default is being used. If a system default is being
223 --   used then we convert the defaulted value into its corresponding attribute
224 --   value held in the g_old_rec data structure.
225 --
226 -- Prerequisites:
227 --   This private function can only be called from the upd process.
228 --
229 -- In Parameters:
230 --   A Pl/Sql record structre.
231 --
232 -- Post Success:
233 --   The record structure will be returned with all system defaulted parameter
234 --   values converted into its current row attribute value.
235 --
236 -- Post Failure:
237 --   No direct error handling is required within this function. Any possible
238 --   errors within this procedure will be a PL/SQL value error due to conversion
239 --   of datatypes or data lengths.
240 --
241 -- Developer Implementation Notes:
242 --   None.
243 --
244 -- Access Status:
245 --   Internal Row Handler Use Only.
246 --
247 -- {End Of Comments}
248 -- ----------------------------------------------------------------------------
249 Procedure convert_defs(p_rec in out nocopy pqh_wel_shd.g_rec_type) is
250 --
251   l_proc  varchar2(72) := g_package||'convert_defs';
252 --
253 Begin
254   --
255   hr_utility.set_location('Entering:'||l_proc, 5);
256   --
257   -- We must now examine each argument value in the
258   -- p_rec plsql record structure
259   -- to see if a system default is being used. If a system default
260   -- is being used then we must set to the 'current' argument value.
261   --
262   If (p_rec.worksheet_budget_set_id = hr_api.g_number) then
263     p_rec.worksheet_budget_set_id :=
264     pqh_wel_shd.g_old_rec.worksheet_budget_set_id;
265   End If;
266   If (p_rec.element_type_id = hr_api.g_number) then
267     p_rec.element_type_id :=
268     pqh_wel_shd.g_old_rec.element_type_id;
269   End If;
270   If (p_rec.distribution_percentage = hr_api.g_number) then
271     p_rec.distribution_percentage :=
272     pqh_wel_shd.g_old_rec.distribution_percentage;
273   End If;
274 
275   --
276   hr_utility.set_location(' Leaving:'||l_proc, 10);
277 --
278 End convert_defs;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------------< upd >----------------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure upd
284   (
285   p_rec        in out nocopy pqh_wel_shd.g_rec_type
286   ) is
287 --
288   l_proc  varchar2(72) := g_package||'upd';
289 --
290 Begin
291   hr_utility.set_location('Entering:'||l_proc, 5);
292   --
293   -- We must lock the row which we need to update.
294   --
295   pqh_wel_shd.lck
296 	(
297 	p_rec.worksheet_bdgt_elmnt_id,
298 	p_rec.object_version_number
299 	);
300   --
301   -- 1. During an update system defaults are used to determine if
302   --    arguments have been defaulted or not. We must therefore
303   --    derive the full record structure values to be updated.
304   --
305   -- 2. Call the supporting update validate operations.
306   --
307   convert_defs(p_rec);
308   pqh_wel_bus.update_validate(p_rec);
309   --
310   -- Call the supporting pre-update operation
311   --
312   pre_update(p_rec);
313   --
314   -- Update the row.
315   --
316   update_dml(p_rec);
317   --
318   -- Call the supporting post-update operation
319   --
320   post_update(p_rec);
321 End upd;
322 --
323 -- ----------------------------------------------------------------------------
324 -- |---------------------------------< upd >----------------------------------|
325 -- ----------------------------------------------------------------------------
326 Procedure upd
327   (
328   p_worksheet_bdgt_elmnt_id      in number,
329   p_worksheet_budget_set_id      in number           default hr_api.g_number,
330   p_element_type_id              in number           default hr_api.g_number,
331   p_distribution_percentage      in number           default hr_api.g_number,
332   p_object_version_number        in out nocopy number
333   ) is
334 --
335   l_rec	  pqh_wel_shd.g_rec_type;
336   l_proc  varchar2(72) := g_package||'upd';
337 --
338 Begin
339   hr_utility.set_location('Entering:'||l_proc, 5);
340   --
341   -- Call conversion function to turn arguments into the
342   -- l_rec structure.
343   --
344   l_rec :=
345   pqh_wel_shd.convert_args
346   (
347   p_worksheet_bdgt_elmnt_id,
348   p_worksheet_budget_set_id,
349   p_element_type_id,
350   p_distribution_percentage,
351   p_object_version_number
352   );
353   --
354   -- Having converted the arguments into the
355   -- plsql record structure we call the corresponding record
356   -- business process.
357   --
358   upd(l_rec);
359   p_object_version_number := l_rec.object_version_number;
360   --
361   hr_utility.set_location(' Leaving:'||l_proc, 10);
362 End upd;
363 --
364 end pqh_wel_upd;