DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PWA_UPD

Source


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