1 Package Body hr_ahk_upd as
2 /* $Header: hrahkrhi.pkb 115.8 2002/12/03 16:34:49 apholt ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_ahk_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 hr_ahk_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 --
62 hr_ahk_shd.g_api_dml := true; -- Set the api dml status
63 --
64 -- Update the hr_api_hooks Row
65 --
66 update hr_api_hooks
67 set
68 api_hook_id = p_rec.api_hook_id,
69 api_module_id = p_rec.api_module_id,
70 api_hook_type = p_rec.api_hook_type,
71 hook_package = p_rec.hook_package,
72 hook_procedure = p_rec.hook_procedure,
73 legislation_code = p_rec.legislation_code,
74 legislation_package = p_rec.legislation_package,
75 legislation_function = p_rec.legislation_function,
76 encoded_error = p_rec.encoded_error
77 where api_hook_id = p_rec.api_hook_id;
78 --
79 hr_ahk_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 hr_ahk_shd.g_api_dml := false; -- Unset the api dml status
87 hr_ahk_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 hr_ahk_shd.g_api_dml := false; -- Unset the api dml status
92 hr_ahk_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 hr_ahk_shd.g_api_dml := false; -- Unset the api dml status
97 hr_ahk_shd.constraint_error
98 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99 When Others Then
100 hr_ahk_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 hr_ahk_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(p_rec in hr_ahk_shd.g_rec_type) is
179 --
180 l_proc varchar2(72) := g_package||'post_update';
181 --
182 Begin
183 hr_utility.set_location('Entering:'||l_proc, 5);
184 --
185 hr_utility.set_location(' Leaving:'||l_proc, 10);
186 End post_update;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |-----------------------------< convert_defs >-----------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 -- The Convert_Defs procedure has one very important function:
195 -- It must return the record structure for the row with all system defaulted
196 -- values converted into its corresponding parameter value for update. When
197 -- we attempt to update a row through the Upd process , certain
198 -- parameters can be defaulted which enables flexibility in the calling of
199 -- the upd process (e.g. only attributes which need to be updated need to be
200 -- specified). For the upd process to determine which attributes
201 -- have NOT been specified we need to check if the parameter has a reserved
202 -- system default value. Therefore, for all parameters which have a
203 -- corresponding reserved system default mechanism specified we need to
204 -- check if a system default is being used. If a system default is being
205 -- used then we convert the defaulted value into its corresponding attribute
206 -- value held in the g_old_rec data structure.
207 --
208 -- Prerequisites:
209 -- This private function can only be called from the upd process.
210 --
211 -- In Parameters:
212 -- A Pl/Sql record structre.
213 --
214 -- Post Success:
215 -- The record structure will be returned with all system defaulted parameter
216 -- values converted into its current row attribute value.
217 --
218 -- Post Failure:
219 -- No direct error handling is required within this function. Any possible
220 -- errors within this procedure will be a PL/SQL value error due to conversion
221
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 hr_ahk_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.api_module_id = hr_api.g_number) then
246 p_rec.api_module_id :=
247 hr_ahk_shd.g_old_rec.api_module_id;
248 End If;
249 If (p_rec.api_hook_type = hr_api.g_varchar2) then
250 p_rec.api_hook_type :=
251 hr_ahk_shd.g_old_rec.api_hook_type;
252 End If;
253 If (p_rec.hook_package = hr_api.g_varchar2) then
254 p_rec.hook_package :=
255 hr_ahk_shd.g_old_rec.hook_package;
256 End If;
257 If (p_rec.hook_procedure = hr_api.g_varchar2) then
258 p_rec.hook_procedure :=
259 hr_ahk_shd.g_old_rec.hook_procedure;
260 End If;
261 If (p_rec.legislation_code = hr_api.g_varchar2) then
262 p_rec.legislation_code :=
263 hr_ahk_shd.g_old_rec.legislation_code;
264 End If;
265 If (p_rec.legislation_package = hr_api.g_varchar2) then
266 p_rec.legislation_package :=
267 hr_ahk_shd.g_old_rec.legislation_package;
268 End If;
269 If (p_rec.legislation_function = hr_api.g_varchar2) then
270 p_rec.legislation_function :=
271 hr_ahk_shd.g_old_rec.legislation_function;
272 End If;
273 If (p_rec.encoded_error = hr_api.g_varchar2) then
274 p_rec.encoded_error :=
275 hr_ahk_shd.g_old_rec.encoded_error;
276 End If;
277 --
278 hr_utility.set_location(' Leaving:'||l_proc, 10);
279 --
280 End convert_defs;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |---------------------------------< upd >----------------------------------|
284 -- ----------------------------------------------------------------------------
285 Procedure upd
286 (
287 p_rec in out nocopy hr_ahk_shd.g_rec_type,
288 p_effective_date in date
289 ) is
290 --
291 l_proc varchar2(72) := g_package||'upd';
292 --
293 Begin
294 hr_utility.set_location('Entering:'||l_proc, 5);
295 --
296 -- We must lock the row which we need to update.
297 --
298 hr_ahk_shd.lck
299 (
300 p_rec.api_hook_id
301 );
302 --
303 -- 1. During an update system defaults are used to determine if
304 -- arguments have been defaulted or not. We must therefore
305 -- derive the full record structure values to be updated.
306 --
307 -- 2. Call the supporting update validate operations.
308 --
309 convert_defs(p_rec);
310 hr_ahk_bus.update_validate(p_rec, p_effective_date);
311 --
312 -- Call the supporting pre-update operation
313 --
314 pre_update(p_rec);
315 --
316 -- Update the row.
317 --
318 update_dml(p_rec);
319 --
320 -- Call the supporting post-update operation
321 --
322 post_update(p_rec);
323 End upd;
324 --
325 -- ----------------------------------------------------------------------------
326 -- |---------------------------------< upd >----------------------------------|
327 -- ----------------------------------------------------------------------------
328 Procedure upd
329 (
330 p_api_hook_id in number,
331 p_effective_date in date,
332 p_api_hook_type in varchar2 default hr_api.g_varchar2,
333 p_hook_package in varchar2 default hr_api.g_varchar2,
334 p_hook_procedure in varchar2 default hr_api.g_varchar2,
335 p_legislation_package in varchar2 default hr_api.g_varchar2,
336 p_legislation_function in varchar2 default hr_api.g_varchar2,
337 p_encoded_error in varchar2 default hr_api.g_varchar2
338 ) is
339 --
340 l_rec hr_ahk_shd.g_rec_type;
341 l_proc varchar2(72) := g_package||'upd';
342 --
343 Begin
344 hr_utility.set_location('Entering:'||l_proc, 5);
345 --
346 -- Call conversion function to turn arguments into the
347 -- l_rec structure.
348 --
349 l_rec :=
350 hr_ahk_shd.convert_args
351 (
352 p_api_hook_id,
353 hr_api.g_number,
354 p_api_hook_type,
355 p_hook_package,
356 p_hook_procedure,
357 hr_api.g_varchar2,
358 p_legislation_package,
359 p_legislation_function,
360 p_encoded_error
361 );
362 --
363 -- Having converted the arguments into the
364 -- plsql record structure we call the corresponding record
365 -- business process.
366 --
367 upd(l_rec, p_effective_date);
368 --
369 --
370 hr_utility.set_location(' Leaving:'||l_proc, 10);
371 End upd;
372 --
373 end hr_ahk_upd;