DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_CAU_UPD

Source


1 Package Body hr_cau_upd as
2 /* $Header: hrcaurhi.pkb 120.0 2005/05/29 02:29:58 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_cau_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 nocopy hr_cau_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_cau_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the hr_calendar_usages Row
68   --
69   update hr_calendar_usages
70   set
71   start_date                        = p_rec.start_date,
72   end_date                          = p_rec.end_date,
73   object_version_number             = p_rec.object_version_number
74   where calendar_usage_id = p_rec.calendar_usage_id;
75   --
76   hr_cau_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_cau_shd.g_api_dml := false;   -- Unset the api dml status
84     hr_cau_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_cau_shd.g_api_dml := false;   -- Unset the api dml status
89     hr_cau_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_cau_shd.g_api_dml := false;   -- Unset the api dml status
94     hr_cau_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When Others Then
97     hr_cau_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_cau_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_cau_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 nocopy hr_cau_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.calendar_id = hr_api.g_number) then
243     p_rec.calendar_id :=
244     hr_cau_shd.g_old_rec.calendar_id;
245   End If;
246   If (p_rec.primary_key_value = hr_api.g_number) then
247     p_rec.primary_key_value :=
248     hr_cau_shd.g_old_rec.primary_key_value;
249   End If;
250   If (p_rec.purpose_usage_id = hr_api.g_number) then
251     p_rec.purpose_usage_id :=
252     hr_cau_shd.g_old_rec.purpose_usage_id;
253   End If;
254   If (p_rec.start_date = hr_api.g_date) then
255     p_rec.start_date :=
256     hr_cau_shd.g_old_rec.start_date;
257   End If;
258   If (p_rec.end_date = hr_api.g_date) then
259     p_rec.end_date :=
260     hr_cau_shd.g_old_rec.end_date;
261   End If;
262 
263   --
264   hr_utility.set_location(' Leaving:'||l_proc, 10);
265 --
266 End convert_defs;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |---------------------------------< upd >----------------------------------|
270 -- ----------------------------------------------------------------------------
271 Procedure upd
272   (
273   p_rec        in out nocopy hr_cau_shd.g_rec_type,
274   p_validate   in     boolean default false
275   ) is
276 --
277   l_proc  varchar2(72) := g_package||'upd';
278 --
279 Begin
280   hr_utility.set_location('Entering:'||l_proc, 5);
281   --
282   -- Determine if the business process is to be validated.
283   --
284   If p_validate then
285     --
286     -- Issue the savepoint.
287     --
288     SAVEPOINT upd_hr_cau;
289   End If;
290   --
291   -- We must lock the row which we need to update.
292   --
293   hr_cau_shd.lck
294 	(
295 	p_rec.calendar_usage_id,
296 	p_rec.object_version_number
297 	);
298   --
299   -- 1. During an update system defaults are used to determine if
300   --    arguments have been defaulted or not. We must therefore
301   --    derive the full record structure values to be updated.
302   --
303   -- 2. Call the supporting update validate operations.
304   --
305   convert_defs(p_rec);
306   hr_cau_bus.update_validate(p_rec);
307   --
308   -- Call the supporting pre-update operation
309   --
310   pre_update(p_rec);
311   --
312   -- Update the row.
313   --
314   update_dml(p_rec);
315   --
316   -- Call the supporting post-update operation
317   --
318   post_update(p_rec);
319   --
320   -- If we are validating then raise the Validate_Enabled exception
321   --
322   If p_validate then
323     Raise HR_Api.Validate_Enabled;
324   End If;
325   --
326   hr_utility.set_location(' Leaving:'||l_proc, 10);
327 Exception
328   When HR_Api.Validate_Enabled Then
329     --
330     -- As the Validate_Enabled exception has been raised
331     -- we must rollback to the savepoint
332     --
333     ROLLBACK TO upd_hr_cau;
334 End upd;
335 --
336 -- ----------------------------------------------------------------------------
337 -- |---------------------------------< upd >----------------------------------|
338 -- ----------------------------------------------------------------------------
339 Procedure upd
340   (
341   p_calendar_usage_id            in number,
342   p_start_date                   in date             default hr_api.g_date,
343   p_end_date                     in date             default hr_api.g_date,
344   p_object_version_number        in out nocopy number,
345   p_validate                     in boolean      default false
346   ) is
347 --
348   l_rec	  hr_cau_shd.g_rec_type;
349   l_proc  varchar2(72) := g_package||'upd';
350 --
351 Begin
352   hr_utility.set_location('Entering:'||l_proc, 5);
353   --
354   -- Call conversion function to turn arguments into the
355   -- l_rec structure.
356   --
357   l_rec :=
358   hr_cau_shd.convert_args
359   (
360   hr_api.g_number,
361   p_calendar_usage_id,
362   hr_api.g_number,
363   hr_api.g_number,
364   p_start_date,
365   p_end_date,
366   p_object_version_number
367   );
368   --
369   -- Having converted the arguments into the
370   -- plsql record structure we call the corresponding record
371   -- business process.
372   --
373   upd(l_rec, p_validate);
374   p_object_version_number := l_rec.object_version_number;
375   --
376   hr_utility.set_location(' Leaving:'||l_proc, 10);
377 End upd;
378 --
379 end hr_cau_upd;