DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_CAL_UPD

Source


1 Package Body hr_cal_upd as
2 /* $Header: hrcalrhi.pkb 115.3 99/10/07 08:14:01 porting ship  $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_cal_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_cal_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_cal_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the hr_calendars Row
68   --
69   update hr_calendars
70   set
71   calendar_name                     = p_rec.calendar_name,
72   object_version_number             = p_rec.object_version_number
73   where calendar_id = p_rec.calendar_id;
74   --
75   hr_cal_shd.g_api_dml := false;   -- Unset the api dml status
76   --
77   hr_utility.set_location(' Leaving:'||l_proc, 10);
78 --
79 Exception
80   When hr_api.check_integrity_violated Then
81     -- A check constraint has been violated
82     hr_cal_shd.g_api_dml := false;   -- Unset the api dml status
83     hr_cal_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     hr_cal_shd.g_api_dml := false;   -- Unset the api dml status
88     hr_cal_shd.constraint_error
89       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90   When hr_api.unique_integrity_violated Then
91     -- Unique integrity has been violated
92     hr_cal_shd.g_api_dml := false;   -- Unset the api dml status
93     hr_cal_shd.constraint_error
94       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95   When Others Then
96     hr_cal_shd.g_api_dml := false;   -- Unset the api dml status
97     Raise;
98 End update_dml;
99 --
100 -- ----------------------------------------------------------------------------
101 -- |------------------------------< pre_update >------------------------------|
102 -- ----------------------------------------------------------------------------
103 -- {Start Of Comments}
104 --
105 -- Description:
106 --   This private procedure contains any processing which is required before
107 --   the update dml.
108 --
109 -- Pre Conditions:
110 --   This is an internal procedure which is called from the upd procedure.
111 --
112 -- In Parameters:
113 --   A Pl/Sql record structre.
114 --
115 -- Post Success:
116 --   Processing continues.
117 --
118 -- Post Failure:
119 --   If an error has occurred, an error message and exception will be raised
120 --   but not handled.
121 --
122 -- Developer Implementation Notes:
123 --   Any pre-processing required before the update dml is issued should be
124 --   coded within this procedure. It is important to note that any 3rd party
125 --   maintenance should be reviewed before placing in this procedure.
126 --
127 -- Access Status:
128 --   Internal Table Handler Use Only.
129 --
130 -- {End Of Comments}
131 -- ----------------------------------------------------------------------------
132 Procedure pre_update(p_rec in hr_cal_shd.g_rec_type) is
133 --
134   l_proc  varchar2(72) := g_package||'pre_update';
135 --
136 Begin
137   hr_utility.set_location('Entering:'||l_proc, 5);
138   --
139   hr_utility.set_location(' Leaving:'||l_proc, 10);
140 End pre_update;
141 --
142 -- ----------------------------------------------------------------------------
143 -- |-----------------------------< post_update >------------------------------|
144 -- ----------------------------------------------------------------------------
145 -- {Start Of Comments}
146 --
147 -- Description:
148 --   This private procedure contains any processing which is required after the
149 --   update dml.
150 --
151 -- Pre Conditions:
152 --   This is an internal procedure which is called from the upd procedure.
153 --
154 -- In Parameters:
155 --   A Pl/Sql record structre.
156 --
157 -- Post Success:
158 --   Processing continues.
159 --
160 -- Post Failure:
161 --   If an error has occurred, an error message and exception will be raised
162 --   but not handled.
163 --
164 -- Developer Implementation Notes:
165 --   Any post-processing required after the update dml is issued should be
166 --   coded within this procedure. It is important to note that any 3rd party
167 --   maintenance should be reviewed before placing in this procedure.
168 --
169 -- Access Status:
170 --   Internal Table Handler Use Only.
171 --
172 -- {End Of Comments}
173 -- ----------------------------------------------------------------------------
174 Procedure post_update(p_rec in hr_cal_shd.g_rec_type) is
175 --
176   l_proc  varchar2(72) := g_package||'post_update';
177 --
178 Begin
179   hr_utility.set_location('Entering:'||l_proc, 5);
180   --
181   hr_utility.set_location(' Leaving:'||l_proc, 10);
182 End post_update;
183 --
184 -- ----------------------------------------------------------------------------
185 -- |-----------------------------< convert_defs >-----------------------------|
186 -- ----------------------------------------------------------------------------
187 -- {Start Of Comments}
188 --
189 -- Description:
190 --   The Convert_Defs procedure has one very important function:
191 --   It must return the record structure for the row with all system defaulted
192 --   values converted into its corresponding parameter value for update. When
193 --   we attempt to update a row through the Upd process , certain
194 --   parameters can be defaulted which enables flexibility in the calling of
195 --   the upd process (e.g. only attributes which need to be updated need to be
196 --   specified). For the upd process to determine which attributes
197 --   have NOT been specified we need to check if the parameter has a reserved
198 --   system default value. Therefore, for all parameters which have a
199 --   corresponding reserved system default mechanism specified we need to
200 --   check if a system default is being used. If a system default is being
201 --   used then we convert the defaulted value into its corresponding attribute
202 --   value held in the g_old_rec data structure.
203 --
204 -- Pre Conditions:
205 --   This private function can only be called from the upd process.
206 --
207 -- In Parameters:
208 --   A Pl/Sql record structre.
209 --
210 -- Post Success:
211 --   The record structure will be returned with all system defaulted parameter
212 --   values converted into its current row attribute value.
213 --
214 -- Post Failure:
215 --   No direct error handling is required within this function. Any possible
216 --   errors within this procedure will be a PL/SQL value error due to conversion
217 
218 --   of datatypes or data lengths.
219 --
220 -- Developer Implementation Notes:
221 --   None.
222 --
223 -- Access Status:
224 --   Internal Table Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure convert_defs(p_rec in out hr_cal_shd.g_rec_type) is
229 --
230   l_proc  varchar2(72) := g_package||'convert_defs';
231 --
232 Begin
233   --
234   hr_utility.set_location('Entering:'||l_proc, 5);
235   --
236   -- We must now examine each argument value in the
237   -- p_rec plsql record structure
238   -- to see if a system default is being used. If a system default
239   -- is being used then we must set to the 'current' argument value.
240   --
241   If (p_rec.calendar_name = hr_api.g_varchar2) then
242     p_rec.calendar_name :=
243     hr_cal_shd.g_old_rec.calendar_name;
244   End If;
245   If (p_rec.pattern_start_position = hr_api.g_number) then
246     p_rec.pattern_start_position :=
247     hr_cal_shd.g_old_rec.pattern_start_position;
248   End If;
249   If (p_rec.calendar_start_time = hr_api.g_date) then
250     p_rec.calendar_start_time :=
251     hr_cal_shd.g_old_rec.calendar_start_time;
252   End If;
253   If (p_rec.pattern_id = hr_api.g_number) then
254     p_rec.pattern_id :=
255     hr_cal_shd.g_old_rec.pattern_id;
256   End If;
257 
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_cal_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_cal;
284   End If;
285   --
286   -- We must lock the row which we need to update.
287   --
288   hr_cal_shd.lck
289 	(
290 	p_rec.calendar_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_cal_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_cal;
329 End upd;
330 --
331 -- ----------------------------------------------------------------------------
332 -- |---------------------------------< upd >----------------------------------|
333 -- ----------------------------------------------------------------------------
334 Procedure upd
335   (
336   p_calendar_id                  in number,
337   p_calendar_name                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_cal_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_cal_shd.convert_args
353   (
354   p_calendar_id,
355   p_calendar_name,
356   hr_api.g_number,
357   hr_api.g_date,
358   hr_api.g_number,
359   p_object_version_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_cal_upd;