1 Package Body ghr_pre_upd as
2 /* $Header: ghprerhi.pkb 115.3 1999/11/09 22:46:04 pkm ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_pre_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 update the specified row in the schema using the primary key in
21 -- the predicates.
22 -- 3) To trap any constraint violations that may have occurred.
23 -- 4) To raise any other errors.
24 --
25 -- Pre Conditions:
26 -- This is an internal private procedure which must be called from the upd
27 -- procedure.
28 --
29 -- In Parameters:
30 -- A Pl/Sql record structre.
31 --
32 -- Post Success:
33 -- The specified row will be updated in the schema.
34 --
35 -- Post Failure:
36 -- If a check, unique or parent integrity constraint violation is raised the
37 -- constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 -- The update 'set' attribute list should be modified if any of your
41 -- attributes are not updateable.
42 --
43 -- Access Status:
44 -- Internal Table Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out ghr_pre_shd.g_rec_type) is
49 --
50 l_proc varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53 hr_utility.set_location('Entering:'||l_proc, 5);
54 --
55 -- Increment the object version
56 --
57 p_rec.object_version_number := p_rec.object_version_number + 1;
58 --
59 -- Update the ghr_pa_remarks Row
60 --
61 update ghr_pa_remarks
62 set
63 pa_remark_id = p_rec.pa_remark_id,
64 description = p_rec.description,
65 remark_code_information1 = p_rec.remark_code_information1,
66 remark_code_information2 = p_rec.remark_code_information2,
67 remark_code_information3 = p_rec.remark_code_information3,
68 remark_code_information4 = p_rec.remark_code_information4,
69 remark_code_information5 = p_rec.remark_code_information5,
70 object_version_number = p_rec.object_version_number
71 where pa_remark_id = p_rec.pa_remark_id;
72
73 --
74 hr_utility.set_location(' Leaving:'||l_proc, 10);
75 --
76 Exception
77 When hr_api.check_integrity_violated Then
78 -- A check constraint has been violated
79 ghr_pre_shd.constraint_error
80 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
81 When hr_api.parent_integrity_violated Then
82 -- Parent integrity has been violated
83 ghr_pre_shd.constraint_error
84 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
85 When hr_api.unique_integrity_violated Then
86 -- Unique integrity has been violated
87 ghr_pre_shd.constraint_error
88 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
89 When Others Then
90 Raise;
91 End update_dml;
92 --
93 -- ----------------------------------------------------------------------------
94 -- |------------------------------< pre_update >------------------------------|
95 -- ----------------------------------------------------------------------------
96 -- {Start Of Comments}
97 --
98 -- Description:
99 -- This private procedure contains any processing which is required before
100 -- the update dml.
101 --
102 -- Pre Conditions:
103 -- This is an internal procedure which is called from the upd procedure.
104 --
105 -- In Parameters:
106 -- A Pl/Sql record structre.
107 --
108 -- Post Success:
109 -- Processing continues.
110 --
111 -- Post Failure:
112 -- If an error has occurred, an error message and exception will be raised
113 -- but not handled.
114 --
115 -- Developer Implementation Notes:
116 -- Any pre-processing required before the update dml is issued should be
117 -- coded within this procedure. It is important to note that any 3rd party
118 -- maintenance should be reviewed before placing in this procedure.
119 --
120 -- Access Status:
121 -- Internal Table Handler Use Only.
122 --
123 -- {End Of Comments}
124 -- ----------------------------------------------------------------------------
125 Procedure pre_update(p_rec in ghr_pre_shd.g_rec_type) is
126 --
127 l_proc varchar2(72) := g_package||'pre_update';
128 --
129 Begin
130 hr_utility.set_location('Entering:'||l_proc, 5);
131 --
132 hr_utility.set_location(' Leaving:'||l_proc, 10);
133 End pre_update;
134 --
135 -- ----------------------------------------------------------------------------
136 -- |-----------------------------< post_update >------------------------------|
137 -- ----------------------------------------------------------------------------
138 -- {Start Of Comments}
139 --
140 -- Description:
141 -- This private procedure contains any processing which is required after the
142 -- update dml.
143 --
144 -- Pre Conditions:
145 -- This is an internal procedure which is called from the upd procedure.
146 --
147 -- In Parameters:
148 -- A Pl/Sql record structre.
149 --
150 -- Post Success:
151 -- Processing continues.
152 --
153 -- Post Failure:
154 -- If an error has occurred, an error message and exception will be raised
155 -- but not handled.
156 --
157 -- Developer Implementation Notes:
158 -- Any post-processing required after the update dml is issued should be
159 -- coded within this procedure. It is important to note that any 3rd party
160 -- maintenance should be reviewed before placing in this procedure.
161 --
162 -- Access Status:
163 -- Internal Table Handler Use Only.
164 --
165 -- {End Of Comments}
166 -- ----------------------------------------------------------------------------
167 Procedure post_update(p_rec in ghr_pre_shd.g_rec_type) is
168 --
169 l_proc varchar2(72) := g_package||'post_update';
170 --
171 Begin
172 hr_utility.set_location('Entering:'||l_proc, 5);
173 --
174 -- This is a hook point and the user hook for post_update is called here.
175 --
176 begin
177 ghr_pre_rku.after_update (
178 p_pa_remark_id => p_rec.pa_remark_id,
179 p_pa_request_id => p_rec.pa_request_id,
180 p_remark_id => p_rec.remark_id,
181 p_description => p_rec.description,
182 p_remark_code_information1 => p_rec.remark_code_information1,
183 p_remark_code_information2 => p_rec.remark_code_information2,
184 p_remark_code_information3 => p_rec.remark_code_information3,
185 p_remark_code_information4 => p_rec.remark_code_information4,
186 p_remark_code_information5 => p_rec.remark_code_information5,
187 p_object_version_number => p_rec.object_version_number ,
188 p_pa_request_id_o => ghr_pre_shd.g_old_rec.pa_request_id,
189 p_remark_id_o => ghr_pre_shd.g_old_rec.remark_id,
190 p_description_o => ghr_pre_shd.g_old_rec.description,
191 p_remark_code_information1_o =>
192 ghr_pre_shd.g_old_rec.remark_code_information1,
193 p_remark_code_information2_o =>
194 ghr_pre_shd.g_old_rec.remark_code_information2,
195 p_remark_code_information3_o =>
196 ghr_pre_shd.g_old_rec.remark_code_information3,
197 p_remark_code_information4_o =>
198 ghr_pre_shd.g_old_rec.remark_code_information4,
199 p_remark_code_information5_o =>
200 ghr_pre_shd.g_old_rec.remark_code_information5,
201 p_object_version_number_o =>
202 ghr_pre_shd.g_old_rec.object_version_number
203 );
204 exception
205 when hr_api.cannot_find_prog_unit then
206 hr_api.cannot_find_prog_unit_error
207 ( p_module_name => 'GHR_PA_REMARKS'
208 ,p_hook_type => 'AU'
209 );
210 end;
211 -- End of API User Hook for post_update.
212 --
213 hr_utility.set_location(' Leaving:'||l_proc, 10);
214 End post_update;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |-----------------------------< convert_defs >-----------------------------|
218 -- ----------------------------------------------------------------------------
219 -- {Start Of Comments}
220 --
221 -- Description:
222 -- The Convert_Defs procedure has one very important function:
223 -- It must return the record structure for the row with all system defaulted
224 -- values converted into its corresponding parameter value for update. When
225 -- we attempt to update a row through the Upd process , certain
226 -- parameters can be defaulted which enables flexibility in the calling of
227 -- the upd process (e.g. only attributes which need to be updated need to be
228 -- specified). For the upd process to determine which attributes
229 -- have NOT been specified we need to check if the parameter has a reserved
230 -- system default value. Therefore, for all parameters which have a
231 -- corresponding reserved system default mechanism specified we need to
232 -- check if a system default is being used. If a system default is being
233 -- used then we convert the defaulted value into its corresponding attribute
234 -- value held in the g_old_rec data structure.
235 --
236 -- Pre Conditions:
237 -- This private function can only be called from the upd process.
238 --
239 -- In Parameters:
240 -- A Pl/Sql record structre.
241 --
242 -- Post Success:
243 -- The record structure will be returned with all system defaulted parameter
244 -- values converted into its current row attribute value.
245 --
246 -- Post Failure:
247 -- No direct error handling is required within this function. Any possible
248 -- errors within this procedure will be a PL/SQL value error due to conversion
249
250 -- of datatypes or data lengths.
251 --
252 -- Developer Implementation Notes:
253 -- None.
254 --
255 -- Access Status:
256 -- Internal Table Handler Use Only.
257 --
258 -- {End Of Comments}
259 -- ----------------------------------------------------------------------------
260 Procedure convert_defs(p_rec in out ghr_pre_shd.g_rec_type) is
261 --
262 l_proc varchar2(72) := g_package||'convert_defs';
263 --
264 Begin
265 --
266 hr_utility.set_location('Entering:'||l_proc, 5);
267 --
268 -- We must now examine each argument value in the
269 -- p_rec plsql record structure
270 -- to see if a system default is being used. If a system default
271 -- is being used then we must set to the 'current' argument value.
272 --
273 If (p_rec.pa_request_id = hr_api.g_number) then
274 p_rec.pa_request_id :=
275 ghr_pre_shd.g_old_rec.pa_request_id;
276 End If;
277 If (p_rec.remark_id = hr_api.g_number) then
278 p_rec.remark_id :=
279 ghr_pre_shd.g_old_rec.remark_id;
280 End If;
281 If (p_rec.description = hr_api.g_varchar2) then
282 p_rec.description :=
283 ghr_pre_shd.g_old_rec.description;
284 End If;
285
286 --
287 hr_utility.set_location(' Leaving:'||l_proc, 10);
288 --
289 End convert_defs;
290 --
291 -- ----------------------------------------------------------------------------
292 -- |---------------------------------< upd >----------------------------------|
293 -- ----------------------------------------------------------------------------
294 Procedure upd
295 (
296 p_rec in out ghr_pre_shd.g_rec_type,
297 p_validate in boolean default false
298 ) is
299 --
300 l_proc varchar2(72) := g_package||'upd';
301 --
302 Begin
303 hr_utility.set_location('Entering:'||l_proc, 5);
304 --
305 -- Determine if the business process is to be validated.
306 --
307 If p_validate then
308 --
309 -- Issue the savepoint.
310 --
311 SAVEPOINT upd_ghr_pre;
312 End If;
313 --
314 -- We must lock the row which we need to update.
315 --
316 ghr_pre_shd.lck
317 (
318 p_rec.pa_remark_id,
319 p_rec.object_version_number
320 );
321 --
322 -- 1. During an update system defaults are used to determine if
323 -- arguments have been defaulted or not. We must therefore
324 -- derive the full record structure values to be updated.
325 --
326 -- 2. Call the supporting update validate operations.
327 --
328 convert_defs(p_rec);
329 ghr_pre_bus.update_validate(p_rec);
330 --
331 -- Call the supporting pre-update operation
332 --
333 pre_update(p_rec);
334 --
335 -- Update the row.
336 --
337 update_dml(p_rec);
338 --
339 -- Call the supporting post-update operation
340 --
341 post_update(p_rec);
342 --
343 -- If we are validating then raise the Validate_Enabled exception
344 --
345 If p_validate then
346 Raise HR_Api.Validate_Enabled;
347 End If;
348 --
349 hr_utility.set_location(' Leaving:'||l_proc, 10);
350 Exception
351 When HR_Api.Validate_Enabled Then
352 --
353 -- As the Validate_Enabled exception has been raised
354 -- we must rollback to the savepoint
355 --
356 ROLLBACK TO upd_ghr_pre;
357 End upd;
358 --
359 -- ----------------------------------------------------------------------------
360 -- |---------------------------------< upd >----------------------------------|
361 -- ----------------------------------------------------------------------------
362 Procedure upd
363 (
364 p_pa_remark_id in number,
365 p_description in varchar2 default hr_api.g_varchar2,
366 p_object_version_number in out number,
367 p_remark_code_information1 in varchar2 default hr_api.g_varchar2,
368 p_remark_code_information2 in varchar2 default hr_api.g_varchar2,
369 p_remark_code_information3 in varchar2 default hr_api.g_varchar2,
370 p_remark_code_information4 in varchar2 default hr_api.g_varchar2,
371 p_remark_code_information5 in varchar2 default hr_api.g_varchar2,
372 p_validate in boolean default false
373 ) is
374 --
375 l_rec ghr_pre_shd.g_rec_type;
376 l_proc varchar2(72) := g_package||'upd';
377 --
378 Begin
379 hr_utility.set_location('Entering:'||l_proc, 5);
380 --
381 -- Call conversion function to turn arguments into the
382 -- l_rec structure.
383 --
384 l_rec :=
385 ghr_pre_shd.convert_args
386 (
387 p_pa_remark_id,
388 hr_api.g_number,
389 hr_api.g_number,
390 p_description,
391 p_remark_code_information1,
392 p_remark_code_information2,
393 p_remark_code_information3,
394 p_remark_code_information4,
395 p_remark_code_information5,
396 p_object_version_number
397 );
398 --
399 -- Having converted the arguments into the
400 -- plsql record structure we call the corresponding record
401 -- business process.
402 --
403 upd(l_rec, p_validate);
404 p_object_version_number := l_rec.object_version_number;
405 --
406 hr_utility.set_location(' Leaving:'||l_proc, 10);
407 End upd;
408 --
409 end ghr_pre_upd;