DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SBC_UPD

Source


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