DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PWO_UPD

Source


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