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