DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_APP_UPD

Source


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