DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SDB_UPD

Source


1 Package Body pay_sdb_upd as
2 /* $Header: pysdbrhi.pkb 120.0 2005/05/29 08:35:06 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_sdb_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 --      perform dml).
21 --   3) To update the specified row in the schema using the primary key in
22 --      the predicates.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the upd
28 --   procedure.
29 --
30 -- In Parameters:
31 --   A Pl/Sql record structre.
32 --
33 -- Post Success:
34 --   The specified row will be updated in the schema.
35 --
36 -- Post Failure:
37 --   On the update dml failure it is important to note that we always reset the
38 --   If a check, unique or parent integrity constraint violation is raised the
39 --   constraint_error procedure will be called.
40 --   If any other error is reported, the error will be raised after the
41 --
42 -- Developer Implementation Notes:
43 --   The update 'set' attribute list should be modified if any of your
44 --   attributes are not updateable.
45 --
46 -- Access Status:
47 --   Internal Row Handler Use Only.
48 --
49 -- {End Of Comments}
50 -- ----------------------------------------------------------------------------
51 Procedure update_dml(p_rec in out nocopy pay_sdb_shd.g_rec_type) is
52 --
53   l_proc  varchar2(72) := g_package||'update_dml';
54 --
55 Begin
56   hr_utility.set_location('Entering:'||l_proc, 5);
57   --
58   -- Increment the object version
59   --
60   p_rec.object_version_number := p_rec.object_version_number + 1;
61   --
62   --
63   -- Update the pay_shadow_defined_balances Row
64   --
65   update pay_shadow_defined_balances
66   set
67   dimension_name                    = p_rec.dimension_name,
68   force_latest_balance_flag         = p_rec.force_latest_balance_flag,
69   grossup_allowed_flag              = p_rec.grossup_allowed_flag,
70   object_version_number             = p_rec.object_version_number
71  ,exclusion_rule_id                 = p_rec.exclusion_rule_id
72   where defined_balance_id = p_rec.defined_balance_id;
73   --
74   --
75   hr_utility.set_location(' Leaving:'||l_proc, 10);
76 --
77 Exception
78   When hr_api.check_integrity_violated Then
79     -- A check constraint has been violated
80     pay_sdb_shd.constraint_error
81       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82   When hr_api.parent_integrity_violated Then
83     -- Parent integrity has been violated
84     pay_sdb_shd.constraint_error
85       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86   When hr_api.unique_integrity_violated Then
87     -- Unique integrity has been violated
88     pay_sdb_shd.constraint_error
89       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90   When Others Then
91     Raise;
92 End update_dml;
93 --
94 -- ----------------------------------------------------------------------------
95 -- |------------------------------< pre_update >------------------------------|
96 -- ----------------------------------------------------------------------------
97 -- {Start Of Comments}
98 --
99 -- Description:
100 --   This private procedure contains any processing which is required before
101 --   the update dml.
102 --
103 -- Prerequisites:
104 --   This is an internal procedure which is called from the upd procedure.
105 --
106 -- In Parameters:
107 --   A Pl/Sql record structre.
108 --
109 -- Post Success:
110 --   Processing continues.
111 --
112 -- Post Failure:
113 --   If an error has occurred, an error message and exception will be raised
114 --   but not handled.
115 --
116 -- Developer Implementation Notes:
117 --   Any pre-processing required before the update dml is issued should be
118 --   coded within this procedure. It is important to note that any 3rd party
119 --   maintenance should be reviewed before placing in this procedure.
120 --
121 -- Access Status:
122 --   Internal Row Handler Use Only.
123 --
124 -- {End Of Comments}
125 -- ----------------------------------------------------------------------------
126 Procedure pre_update(p_rec in pay_sdb_shd.g_rec_type) is
127 --
128   l_proc  varchar2(72) := g_package||'pre_update';
129 --
130 Begin
131   hr_utility.set_location('Entering:'||l_proc, 5);
132   --
133   hr_utility.set_location(' Leaving:'||l_proc, 10);
134 End pre_update;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |-----------------------------< post_update >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 --   This private procedure contains any processing which is required after the
143 --   update dml.
144 --
145 -- Prerequisites:
146 --   This is an internal procedure which is called from the upd procedure.
147 --
148 -- In Parameters:
149 --   A Pl/Sql record structre.
150 --
151 -- Post Success:
152 --   Processing continues.
153 --
154 -- Post Failure:
155 --   If an error has occurred, an error message and exception will be raised
156 --   but not handled.
157 --
158 -- Developer Implementation Notes:
159 --   Any post-processing required after the update dml is issued should be
160 --   coded within this procedure. It is important to note that any 3rd party
161 --   maintenance should be reviewed before placing in this procedure.
162 --
163 -- Access Status:
164 --   Internal Row Handler Use Only.
165 --
166 -- {End Of Comments}
167 -- ----------------------------------------------------------------------------
168 Procedure post_update(p_rec in pay_sdb_shd.g_rec_type) is
169 --
170   l_proc  varchar2(72) := g_package||'post_update';
171 --
172 Begin
173   hr_utility.set_location('Entering:'||l_proc, 5);
174   --
175   hr_utility.set_location(' Leaving:'||l_proc, 10);
176 End post_update;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |-----------------------------< convert_defs >-----------------------------|
180 -- ----------------------------------------------------------------------------
181 -- {Start Of Comments}
182 --
183 -- Description:
184 --   The Convert_Defs procedure has one very important function:
185 --   It must return the record structure for the row with all system defaulted
186 --   values converted into its corresponding parameter value for update. When
187 --   we attempt to update a row through the Upd process , certain
188 --   parameters can be defaulted which enables flexibility in the calling of
189 --   the upd process (e.g. only attributes which need to be updated need to be
190 --   specified). For the upd process to determine which attributes
191 --   have NOT been specified we need to check if the parameter has a reserved
192 --   system default value. Therefore, for all parameters which have a
193 --   corresponding reserved system default mechanism specified we need to
194 --   check if a system default is being used. If a system default is being
195 --   used then we convert the defaulted value into its corresponding attribute
196 --   value held in the g_old_rec data structure.
197 --
198 -- Prerequisites:
199 --   This private function can only be called from the upd process.
200 --
201 -- In Parameters:
202 --   A Pl/Sql record structre.
203 --
204 -- Post Success:
205 --   The record structure will be returned with all system defaulted parameter
206 --   values converted into its current row attribute value.
207 --
208 -- Post Failure:
209 --   No direct error handling is required within this function. Any possible
210 --   errors within this procedure will be a PL/SQL value error due to conversion
211 
212 --   of datatypes or data lengths.
213 --
214 -- Developer Implementation Notes:
215 --   None.
216 --
217 -- Access Status:
218 --   Internal Row Handler Use Only.
219 --
220 -- {End Of Comments}
221 -- ----------------------------------------------------------------------------
222 Procedure convert_defs(p_rec in out nocopy pay_sdb_shd.g_rec_type) is
223 --
224   l_proc  varchar2(72) := g_package||'convert_defs';
225 --
226 Begin
227   --
228   hr_utility.set_location('Entering:'||l_proc, 5);
229   --
230   -- We must now examine each argument value in the
231   -- p_rec plsql record structure
232   -- to see if a system default is being used. If a system default
233   -- is being used then we must set to the 'current' argument value.
234   --
235   If (p_rec.balance_type_id = hr_api.g_number) then
236     p_rec.balance_type_id :=
237     pay_sdb_shd.g_old_rec.balance_type_id;
238   End If;
239   If (p_rec.dimension_name = hr_api.g_varchar2) then
240     p_rec.dimension_name :=
241     pay_sdb_shd.g_old_rec.dimension_name;
242   End If;
243   If (p_rec.force_latest_balance_flag = hr_api.g_varchar2) then
244     p_rec.force_latest_balance_flag :=
245     pay_sdb_shd.g_old_rec.force_latest_balance_flag;
246   End If;
247   If (p_rec.grossup_allowed_flag = hr_api.g_varchar2) then
248     p_rec.grossup_allowed_flag :=
249     pay_sdb_shd.g_old_rec.grossup_allowed_flag;
250   End If;
251   If (p_rec.exclusion_rule_id = hr_api.g_number) then
252     p_rec.exclusion_rule_id :=
253     pay_sdb_shd.g_old_rec.exclusion_rule_id;
254   End If;
255   --
256   hr_utility.set_location(' Leaving:'||l_proc, 10);
257 --
258 End convert_defs;
259 --
260 -- ----------------------------------------------------------------------------
261 -- |---------------------------------< upd >----------------------------------|
262 -- ----------------------------------------------------------------------------
263 Procedure upd
264   (
265   p_effective_date in date,
266   p_rec        in out nocopy pay_sdb_shd.g_rec_type
267   ) is
268 --
269   l_proc  varchar2(72) := g_package||'upd';
270 --
271 Begin
272   hr_utility.set_location('Entering:'||l_proc, 5);
273   --
274   -- We must lock the row which we need to update.
275   --
276   pay_sdb_shd.lck
277 	(
278 	p_rec.defined_balance_id,
279 	p_rec.object_version_number
280 	);
281   --
282   -- 1. During an update system defaults are used to determine if
283   --    arguments have been defaulted or not. We must therefore
284   --    derive the full record structure values to be updated.
285   --
286   -- 2. Call the supporting update validate operations.
287   --
288   convert_defs(p_rec);
289   pay_sdb_bus.update_validate(p_effective_date, p_rec);
290   --
291   -- Call the supporting pre-update operation
292   --
293   pre_update(p_rec);
294   --
295   -- Update the row.
296   --
297   update_dml(p_rec);
298   --
299   -- Call the supporting post-update operation
300   --
301   post_update(p_rec);
302 End upd;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------------< upd >----------------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure upd
308   (
309   p_effective_date in date,
310   p_defined_balance_id           in number,
311   p_dimension_name               in varchar2         default hr_api.g_varchar2,
312   p_force_latest_balance_flag    in varchar2         default hr_api.g_varchar2,
313   p_grossup_allowed_flag         in varchar2         default hr_api.g_varchar2,
314   p_object_version_number        in out nocopy number
315  ,p_exclusion_rule_id            in number           default hr_api.g_number
316   ) is
317 --
318   l_rec	  pay_sdb_shd.g_rec_type;
319   l_proc  varchar2(72) := g_package||'upd';
320 --
321 Begin
322   hr_utility.set_location('Entering:'||l_proc, 5);
323   --
324   -- Call conversion function to turn arguments into the
325   -- l_rec structure.
326   --
327   l_rec :=
328   pay_sdb_shd.convert_args
329   (
330   p_defined_balance_id,
331   hr_api.g_number,
332   p_dimension_name,
333   p_force_latest_balance_flag,
334   p_grossup_allowed_flag,
335   p_object_version_number
336  ,p_exclusion_rule_id
337   );
338   --
339   -- Having converted the arguments into the
340   -- plsql record structure we call the corresponding record
341   -- business process.
342   --
343   upd(p_effective_date, l_rec);
344   p_object_version_number := l_rec.object_version_number;
345   --
346   hr_utility.set_location(' Leaving:'||l_proc, 10);
347 End upd;
348 --
349 end pay_sdb_upd;