DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SFR_UPD

Source


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