DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_RAN_UPD

Source


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