1 Package Body ghr_nre_upd as
2 /* $Header: ghnrerhi.pkb 115.3 1999/11/09 22:41:35 pkm ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_nre_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 -- Prerequisites:
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 Row Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out ghr_nre_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 --
60 -- Update the ghr_noac_remarks Row
61 --
62 update ghr_noac_remarks
63 set
64 noac_remark_id = p_rec.noac_remark_id,
65 nature_of_action_id = p_rec.nature_of_action_id,
66 remark_id = p_rec.remark_id,
67 required_flag = p_rec.required_flag,
68 enabled_flag = p_rec.enabled_flag,
69 date_from = p_rec.date_from,
70 date_to = p_rec.date_to,
71 object_version_number = p_rec.object_version_number
72 where noac_remark_id = p_rec.noac_remark_id;
73 --
74 --
75 hr_utility.set_location(' Leaving:'||l_proc, 10);
76 --
77 Exception
78 When hr_api.check_integrity_violated Then
79 -- A check constraint has been violated
80 ghr_nre_shd.constraint_error
81 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82 When hr_api.parent_integrity_violated Then
83 -- Parent integrity has been violated
84 ghr_nre_shd.constraint_error
85 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86 When hr_api.unique_integrity_violated Then
87 -- Unique integrity has been violated
88 ghr_nre_shd.constraint_error
89 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90 When Others Then
91 Raise;
92 End update_dml;
93 --
94 -- ----------------------------------------------------------------------------
95 -- |------------------------------< pre_update >------------------------------|
96 -- ----------------------------------------------------------------------------
97 -- {Start Of Comments}
98 --
99 -- Description:
100 -- This private procedure contains any processing which is required before
101 -- the update dml.
102 --
103 -- Prerequisites:
104 -- This is an internal procedure which is called from the upd procedure.
105 --
106 -- In Parameters:
107 -- A Pl/Sql record structre.
108 --
109 -- Post Success:
110 -- Processing continues.
111 --
112 -- Post Failure:
113 -- If an error has occurred, an error message and exception will be raised
114 -- but not handled.
115 --
116 -- Developer Implementation Notes:
117 -- Any pre-processing required before the update dml is issued should be
118 -- coded within this procedure. It is important to note that any 3rd party
119 -- maintenance should be reviewed before placing in this procedure.
120 --
121 -- Access Status:
122 -- Internal Row Handler Use Only.
123 --
124 -- {End Of Comments}
125 -- ----------------------------------------------------------------------------
126 Procedure pre_update(p_rec in ghr_nre_shd.g_rec_type) is
127 --
128 l_proc varchar2(72) := g_package||'pre_update';
129 --
130 Begin
131 hr_utility.set_location('Entering:'||l_proc, 5);
132 --
133 hr_utility.set_location(' Leaving:'||l_proc, 10);
134 End pre_update;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |-----------------------------< post_update >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 -- This private procedure contains any processing which is required after the
143 -- update dml.
144 --
145 -- Prerequisites:
146 -- This is an internal procedure which is called from the upd procedure.
147 --
148 -- In Parameters:
149 -- A Pl/Sql record structre.
150 --
151 -- Post Success:
152 -- Processing continues.
153 --
154 -- Post Failure:
155 -- If an error has occurred, an error message and exception will be raised
156 -- but not handled.
157 --
158 -- Developer Implementation Notes:
159 -- Any post-processing required after the update dml is issued should be
160 -- coded within this procedure. It is important to note that any 3rd party
161 -- maintenance should be reviewed before placing in this procedure.
162 --
163 -- Access Status:
164 -- Internal Row Handler Use Only.
165 --
166 -- {End Of Comments}
167 -- ----------------------------------------------------------------------------
168 Procedure post_update(
169 p_effective_date in date,p_rec in ghr_nre_shd.g_rec_type) is
170 --
171 l_proc varchar2(72) := g_package||'post_update';
172 --
173 Begin
174 hr_utility.set_location('Entering:'||l_proc, 5);
175 --
176 --
177 -- Start of API User Hook for post_update.
178 --
179 begin
180 --
181 ghr_nre_rku.after_update
182 (
183 p_noac_remark_id =>p_rec.noac_remark_id
184 ,p_nature_of_action_id =>p_rec.nature_of_action_id
185 ,p_remark_id =>p_rec.remark_id
186 ,p_required_flag =>p_rec.required_flag
187 ,p_enabled_flag =>p_rec.enabled_flag
188 ,p_date_from =>p_rec.date_from
189 ,p_date_to =>p_rec.date_to
190 ,p_object_version_number =>p_rec.object_version_number
191 ,p_effective_date =>p_effective_date
192 ,p_nature_of_action_id_o =>ghr_nre_shd.g_old_rec.nature_of_action_id
193 ,p_remark_id_o =>ghr_nre_shd.g_old_rec.remark_id
194 ,p_required_flag_o =>ghr_nre_shd.g_old_rec.required_flag
195 ,p_enabled_flag_o =>ghr_nre_shd.g_old_rec.enabled_flag
196 ,p_date_from_o =>ghr_nre_shd.g_old_rec.date_from
197 ,p_date_to_o =>ghr_nre_shd.g_old_rec.date_to
198 ,p_object_version_number_o =>ghr_nre_shd.g_old_rec.object_version_number
199 );
200 --
201 exception
202 --
203 when hr_api.cannot_find_prog_unit then
204 --
205 hr_api.cannot_find_prog_unit_error
206 (p_module_name => 'ghr_noac_remarks'
207 ,p_hook_type => 'AU');
208 --
209 end;
210 --
211 -- End of API User Hook for post_update.
212 --
213 --
214 hr_utility.set_location(' Leaving:'||l_proc, 10);
215 End post_update;
216 --
217 -- ----------------------------------------------------------------------------
218 -- |-----------------------------< convert_defs >-----------------------------|
219 -- ----------------------------------------------------------------------------
220 -- {Start Of Comments}
221 --
222 -- Description:
223 -- The Convert_Defs procedure has one very important function:
224 -- It must return the record structure for the row with all system defaulted
225 -- values converted into its corresponding parameter value for update. When
226 -- we attempt to update a row through the Upd process , certain
227 -- parameters can be defaulted which enables flexibility in the calling of
228 -- the upd process (e.g. only attributes which need to be updated need to be
229 -- specified). For the upd process to determine which attributes
230 -- have NOT been specified we need to check if the parameter has a reserved
231 -- system default value. Therefore, for all parameters which have a
232 -- corresponding reserved system default mechanism specified we need to
233 -- check if a system default is being used. If a system default is being
234 -- used then we convert the defaulted value into its corresponding attribute
235 -- value held in the g_old_rec data structure.
236 --
237 -- Prerequisites:
238 -- This private function can only be called from the upd process.
239 --
240 -- In Parameters:
241 -- A Pl/Sql record structre.
242 --
243 -- Post Success:
244 -- The record structure will be returned with all system defaulted parameter
245 -- values converted into its current row attribute value.
246 --
247 -- Post Failure:
248 -- No direct error handling is required within this function. Any possible
249 -- errors within this procedure will be a PL/SQL value error due to conversion
250 -- of datatypes or data lengths.
251 --
252 -- Developer Implementation Notes:
253 -- None.
254 --
255 -- Access Status:
256 -- Internal Row Handler Use Only.
257 --
258 -- {End Of Comments}
259 -- ----------------------------------------------------------------------------
260 Procedure convert_defs(p_rec in out ghr_nre_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.nature_of_action_id = hr_api.g_number) then
274 p_rec.nature_of_action_id :=
275 ghr_nre_shd.g_old_rec.nature_of_action_id;
276 End If;
277 If (p_rec.remark_id = hr_api.g_number) then
278 p_rec.remark_id :=
279 ghr_nre_shd.g_old_rec.remark_id;
280 End If;
281 If (p_rec.required_flag = hr_api.g_varchar2) then
282 p_rec.required_flag :=
283 ghr_nre_shd.g_old_rec.required_flag;
284 End If;
285 If (p_rec.enabled_flag = hr_api.g_varchar2) then
286 p_rec.enabled_flag :=
287 ghr_nre_shd.g_old_rec.enabled_flag;
288 End If;
289 If (p_rec.date_from = hr_api.g_date) then
290 p_rec.date_from :=
291 ghr_nre_shd.g_old_rec.date_from;
292 End If;
293 If (p_rec.date_to = hr_api.g_date) then
294 p_rec.date_to :=
295 ghr_nre_shd.g_old_rec.date_to;
296 End If;
297
298 --
299 hr_utility.set_location(' Leaving:'||l_proc, 10);
300 --
301 End convert_defs;
302 --
303 -- ----------------------------------------------------------------------------
304 -- |---------------------------------< upd >----------------------------------|
305 -- ----------------------------------------------------------------------------
306 Procedure upd
307 (
308 p_effective_date in date,
309 p_rec in out ghr_nre_shd.g_rec_type
310 ) is
311 --
312 l_proc varchar2(72) := g_package||'upd';
313 --
314 Begin
315 hr_utility.set_location('Entering:'||l_proc, 5);
316 --
317 -- We must lock the row which we need to update.
318 --
319 ghr_nre_shd.lck
320 (
321 p_rec.noac_remark_id,
322 p_rec.object_version_number
323 );
324 --
325 -- 1. During an update system defaults are used to determine if
326 -- arguments have been defaulted or not. We must therefore
327 -- derive the full record structure values to be updated.
328 --
329 -- 2. Call the supporting update validate operations.
330 --
331 convert_defs(p_rec);
332 ghr_nre_bus.update_validate(p_rec
333 ,p_effective_date);
334 --
335 -- Call the supporting pre-update operation
336 --
337 pre_update(p_rec);
338 --
339 -- Update the row.
340 --
341 update_dml(p_rec);
342 --
343 -- Call the supporting post-update operation
344 --
345 post_update(
346 p_effective_date,p_rec);
347 End upd;
348 --
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------------< upd >----------------------------------|
351 -- ----------------------------------------------------------------------------
352 Procedure upd
353 (
354 p_effective_date in date,
355 p_noac_remark_id in number,
356 p_nature_of_action_id in number default hr_api.g_number,
357 p_remark_id in number default hr_api.g_number,
358 p_required_flag in varchar2 default hr_api.g_varchar2,
359 p_enabled_flag in varchar2 default hr_api.g_varchar2,
360 p_date_from in date default hr_api.g_date,
361 p_date_to in date default hr_api.g_date,
362 p_object_version_number in out number
363 ) is
364 --
365 l_rec ghr_nre_shd.g_rec_type;
366 l_proc varchar2(72) := g_package||'upd';
367 --
368 Begin
369 hr_utility.set_location('Entering:'||l_proc, 5);
370 --
371 -- Call conversion function to turn arguments into the
372 -- l_rec structure.
373 --
374 l_rec :=
375 ghr_nre_shd.convert_args
376 (
377 p_noac_remark_id,
378 p_nature_of_action_id,
379 p_remark_id,
380 p_required_flag,
381 p_enabled_flag,
382 p_date_from,
383 p_date_to,
384 p_object_version_number
385 );
386 --
387 -- Having converted the arguments into the
388 -- plsql record structure we call the corresponding record
389 -- business process.
390 --
391 upd(
392 p_effective_date,l_rec);
393 p_object_version_number := l_rec.object_version_number;
394 --
395 hr_utility.set_location(' Leaving:'||l_proc, 10);
396 End upd;
397 --
398 end ghr_nre_upd;