DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_EXU_UPD

Source


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