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