1 Package Body hr_nmf_upd as
2 /* $Header: hrnmfrhi.pkb 120.0 2005/05/31 01:34 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_nmf_upd.'; -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- This procedure controls the actual dml update logic. The processing of
18 -- this procedure is:
19 -- 1) Increment the object_version_number by 1 if the object_version_number
20 -- is defined as an attribute for this entity.
21 -- 2) To update the specified row in the schema using the primary key in
22 -- the predicates.
23 -- 3) To trap any constraint violations that may have occurred.
24 -- 4) To raise any other errors.
25 --
26 -- Prerequisites:
27 -- This is an internal private procedure which must be called from the upd
28 -- procedure.
29 --
30 -- In Parameters:
31 -- A Pl/Sql record structre.
32 --
33 -- Post Success:
34 -- The specified row will be updated in the schema.
35 --
36 -- Post Failure:
37 -- If a check, unique or parent integrity constraint violation is raised the
38 -- constraint_error procedure will be called.
39 --
40 -- Developer Implementation Notes:
41 -- The update 'set' attribute list should be modified if any of your
42 -- attributes are not updateable.
43 --
44 -- Access Status:
45 -- Internal Row Handler Use Only.
46 --
47 -- {End Of Comments}
48 -- ----------------------------------------------------------------------------
49 Procedure update_dml
50 (p_rec in out nocopy hr_nmf_shd.g_rec_type
51 ) is
52 --
53 l_proc varchar2(72) := g_package||'update_dml';
54 --
55 Begin
56 if g_debug then
57 hr_utility.set_location('Entering:'||l_proc, 5);
58 end if;
59 --
60 -- Increment the object version
61 p_rec.object_version_number := p_rec.object_version_number + 1;
62 --
63 -- Update the hr_name_formats Row
64 --
65 update hr_name_formats
66 set
67 name_format_id = p_rec.name_format_id
68 ,format_mask = p_rec.format_mask
69 ,object_version_number = p_rec.object_version_number
70 where name_format_id = p_rec.name_format_id;
71 --
72 if g_debug then
73 hr_utility.set_location(' Leaving:'||l_proc, 10);
74 end if;
75 --
76 Exception
77 When hr_api.check_integrity_violated Then
78 -- A check constraint has been violated
79 hr_nmf_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 hr_nmf_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 hr_nmf_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 -- Prerequisites:
103 -- This is an internal procedure which is called from the upd procedure.
104 --
105 -- In Parameters:
106 -- A Pl/Sql record structure.
107 --
108 -- Post Success:
109 -- Processing continues.
110 --
111 -- Post Failure:
112 -- If an error has occurred, an error message and exception wil 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 Row Handler Use Only.
122 --
123 -- {End Of Comments}
124 -- ----------------------------------------------------------------------------
125 Procedure pre_update
126 (p_rec in hr_nmf_shd.g_rec_type
127 ) is
128 --
129 l_proc varchar2(72) := g_package||'pre_update';
130 --
131 Begin
132 if g_debug then
133 hr_utility.set_location('Entering:'||l_proc, 5);
134 end if;
135 --
136 if g_debug then
137 hr_utility.set_location(' Leaving:'||l_proc, 10);
138 end if;
139 End pre_update;
140 --
141 -- ----------------------------------------------------------------------------
142 -- |-----------------------------< post_update >------------------------------|
143 -- ----------------------------------------------------------------------------
144 -- {Start Of Comments}
145 --
146 -- Description:
147 -- This private procedure contains any processing which is required after
148 -- the update dml.
149 --
150 -- Prerequisites:
151 -- This is an internal procedure which is called from the upd procedure.
152 --
153 -- In Parameters:
154 -- A Pl/Sql record structure.
155 --
156 -- Post Success:
157 -- Processing continues.
158 --
159 -- Post Failure:
160 -- If an error has occurred, an error message and exception will be raised
161 -- but not handled.
162 --
163 -- Developer Implementation Notes:
164 -- Any post-processing required after the update dml is issued should be
165 -- coded within this procedure. It is important to note that any 3rd party
166 -- maintenance should be reviewed before placing in this procedure.
167 --
168 -- Access Status:
169 -- Internal Row Handler Use Only.
170 --
171 -- {End Of Comments}
172 -- ----------------------------------------------------------------------------
173 Procedure post_update
174 (p_effective_date in date
175 ,p_rec in hr_nmf_shd.g_rec_type
176 ) is
177 --
178 l_proc varchar2(72) := g_package||'post_update';
179 --
180 Begin
181 if g_debug then
182 hr_utility.set_location('Entering:'||l_proc, 5);
183 end if;
184 begin
185 --
186 hr_nmf_rku.after_update
187 (p_effective_date => p_effective_date
188 ,p_name_format_id
189 => p_rec.name_format_id
190 ,p_format_mask
191 => p_rec.format_mask
192 ,p_object_version_number
193 => p_rec.object_version_number
194 ,p_format_name_o
195 => hr_nmf_shd.g_old_rec.format_name
196 ,p_legislation_code_o
197 => hr_nmf_shd.g_old_rec.legislation_code
198 ,p_user_format_choice_o
199 => hr_nmf_shd.g_old_rec.user_format_choice
200 ,p_format_mask_o
201 => hr_nmf_shd.g_old_rec.format_mask
202 ,p_object_version_number_o
203 => hr_nmf_shd.g_old_rec.object_version_number
204 );
205 --
206 exception
207 --
208 when hr_api.cannot_find_prog_unit then
209 --
210 hr_api.cannot_find_prog_unit_error
211 (p_module_name => 'HR_NAME_FORMATS'
212 ,p_hook_type => 'AU');
213 --
214 end;
215 --
216 if g_debug then
217 hr_utility.set_location(' Leaving:'||l_proc, 10);
218 end if;
219 End post_update;
220 --
221 -- ----------------------------------------------------------------------------
222 -- |-----------------------------< convert_defs >-----------------------------|
223 -- ----------------------------------------------------------------------------
224 -- {Start Of Comments}
225 --
226 -- Description:
227 -- The Convert_Defs procedure has one very important function:
228 -- It must return the record structure for the row with all system defaulted
229 -- values converted into its corresponding parameter value for update. When
230 -- we attempt to update a row through the Upd process , certain
231 -- parameters can be defaulted which enables flexibility in the calling of
232 -- the upd process (e.g. only attributes which need to be updated need to be
233 -- specified). For the upd process to determine which attributes
234 -- have NOT been specified we need to check if the parameter has a reserved
235 -- system default value. Therefore, for all parameters which have a
236 -- corresponding reserved system default mechanism specified we need to
237 -- check if a system default is being used. If a system default is being
238 -- used then we convert the defaulted value into its corresponding attribute
239 -- value held in the g_old_rec data structure.
240 --
241 -- Prerequisites:
242 -- This private function can only be called from the upd process.
243 --
244 -- In Parameters:
245 -- A Pl/Sql record structure.
246 --
247 -- Post Success:
248 -- The record structure will be returned with all system defaulted parameter
249 -- values converted into its current row attribute value.
250 --
251 -- Post Failure:
252 -- No direct error handling is required within this function. Any possible
253 -- errors within this procedure will be a PL/SQL value error due to
254 -- conversion of datatypes or data lengths.
255 --
256 -- Developer Implementation Notes:
257 -- None.
258 --
259 -- Access Status:
260 -- Internal Row Handler Use Only.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure convert_defs
265 (p_rec in out nocopy hr_nmf_shd.g_rec_type
266 ) is
267 --
268 Begin
269 --
270 -- We must now examine each argument value in the
271 -- p_rec plsql record structure
272 -- to see if a system default is being used. If a system default
273 -- is being used then we must set to the 'current' argument value.
274 --
275 If (p_rec.format_name = hr_api.g_varchar2) then
276 p_rec.format_name :=
277 hr_nmf_shd.g_old_rec.format_name;
278 End If;
279 If (p_rec.legislation_code = hr_api.g_varchar2) then
280 p_rec.legislation_code :=
281 hr_nmf_shd.g_old_rec.legislation_code;
282 End If;
283 If (p_rec.user_format_choice = hr_api.g_varchar2) then
284 p_rec.user_format_choice :=
285 hr_nmf_shd.g_old_rec.user_format_choice;
286 End If;
287 If (p_rec.format_mask = hr_api.g_varchar2) then
288 p_rec.format_mask :=
289 hr_nmf_shd.g_old_rec.format_mask;
290 End If;
291 --
292 End convert_defs;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |---------------------------------< upd >----------------------------------|
296 -- ----------------------------------------------------------------------------
297 Procedure upd
298 (p_effective_date in date
299 ,p_rec in out nocopy hr_nmf_shd.g_rec_type
300 ) is
301 --
302 l_proc varchar2(72) := g_package||'upd';
303 --
304 Begin
305 if g_debug then
306 hr_utility.set_location('Entering:'||l_proc, 5);
307 end if;
308 --
309 -- We must lock the row which we need to update.
310 --
311 hr_nmf_shd.lck
312 (p_rec.name_format_id
313 ,p_rec.object_version_number
314 );
315 --
316 -- 1. During an update system defaults are used to determine if
317 -- arguments have been defaulted or not. We must therefore
318 -- derive the full record structure values to be updated.
319 --
320 -- 2. Call the supporting update validate operations.
321 --
322 convert_defs(p_rec);
323 hr_nmf_bus.update_validate
324 (p_effective_date
325 ,p_rec
326 );
327 --
328 -- Call to raise any errors on multi-message list
329 hr_multi_message.end_validation_set;
330 --
331 -- Call the supporting pre-update operation
332 --
333 hr_nmf_upd.pre_update(p_rec);
334 --
335 -- Update the row.
336 --
337 hr_nmf_upd.update_dml(p_rec);
338 --
339 -- Call the supporting post-update operation
340 --
341 hr_nmf_upd.post_update
342 (p_effective_date
343 ,p_rec
344 );
345 --
346 -- Call to raise any errors on multi-message list
347 hr_multi_message.end_validation_set;
348 End upd;
349 --
350 -- ----------------------------------------------------------------------------
351 -- |---------------------------------< upd >----------------------------------|
352 -- ----------------------------------------------------------------------------
353 Procedure upd
354 (p_effective_date in date
355 ,p_name_format_id in number
356 ,p_object_version_number in out nocopy number
357 ,p_format_mask in varchar2 default hr_api.g_varchar2
358 ) is
359 --
360 l_rec hr_nmf_shd.g_rec_type;
361 l_proc varchar2(72) := g_package||'upd';
362 --
363 Begin
364 if g_debug then
365 hr_utility.set_location('Entering:'||l_proc, 5);
366 end if;
367 --
368 -- Call conversion function to turn arguments into the
369 -- l_rec structure.
370 --
371 l_rec :=
372 hr_nmf_shd.convert_args
373 (p_name_format_id
374 ,hr_api.g_varchar2 --p_format_name
375 ,hr_api.g_varchar2 --p_legislation_code
376 ,hr_api.g_varchar2 --p_user_format_choice
377 ,p_format_mask
378 ,p_object_version_number
379 );
380 --
381 -- Having converted the arguments into the
382 -- plsql record structure we call the corresponding record
383 -- business process.
384 --
385 hr_nmf_upd.upd
386 (p_effective_date
387 ,l_rec
388 );
389 p_object_version_number := l_rec.object_version_number;
390 --
391 if g_debug then
392 hr_utility.set_location(' Leaving:'||l_proc, 10);
393 end if;
394 End upd;
395 --
396 end hr_nmf_upd;