1 Package Body hxc_aps_upd as
2 /* $Header: hxcaprpsrhi.pkb 120.2 2005/09/23 10:38:57 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_aps_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 set and unset the g_api_dml status as required (as we are about to
22 -- perform dml).
23 -- 3) To update the specified row in the schema using the primary key in
24 -- the predicates.
25 -- 4) To trap any constraint violations that may have occurred.
26 -- 5) To raise any other errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the upd
30 -- procedure.
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be updated in the schema.
37 --
38 -- Post Failure:
39 -- On the update dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If a check, unique or parent integrity constraint violation is raised the
42 -- constraint_error procedure will be called.
43 -- If any other error is reported, the error will be raised after the
44 -- g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 -- The update 'set' attribute list should be modified if any of your
48 -- attributes are not updateable.
49 --
50 -- Access Status:
51 -- Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure update_dml
56 (p_rec in out nocopy hxc_aps_shd.g_rec_type
57 ) is
58 --
59 l_proc varchar2(72);
60 --
61 Begin
62 if g_debug then
63 l_proc := g_package||'update_dml';
64 hr_utility.set_location('Entering:'||l_proc, 5);
65 end if;
66 --
67 -- Increment the object version
68 p_rec.object_version_number := p_rec.object_version_number + 1;
69 --
70 hxc_aps_shd.g_api_dml := true; -- Set the api dml status
71 --
72 -- Update the hxc_approval_period_sets Row
73 --
74 update hxc_approval_period_sets
75 set
76 approval_period_set_id = p_rec.approval_period_set_id
77 ,name = p_rec.name
78 ,object_version_number = p_rec.object_version_number
79 ,last_updated_by = fnd_global.user_id
80 ,last_update_date = sysdate
81 ,last_update_login = fnd_global.login_id
82 where approval_period_set_id = p_rec.approval_period_set_id;
83 --
84 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
85 --
86 if g_debug then
87 hr_utility.set_location(' Leaving:'||l_proc, 10);
88 end if;
89 --
90 Exception
91 When hr_api.check_integrity_violated Then
92 -- A check constraint has been violated
93 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
94 hxc_aps_shd.constraint_error
95 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96 When hr_api.parent_integrity_violated Then
97 -- Parent integrity has been violated
98 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
99 hxc_aps_shd.constraint_error
100 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101 When hr_api.unique_integrity_violated Then
102 -- Unique integrity has been violated
103 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
104 hxc_aps_shd.constraint_error
105 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106 When Others Then
107 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
108 Raise;
109 End update_dml;
110 --
111 -- ----------------------------------------------------------------------------
112 -- |------------------------------< pre_update >------------------------------|
113 -- ----------------------------------------------------------------------------
114 -- {Start Of Comments}
115 --
116 -- Description:
117 -- This private procedure contains any processing which is required before
118 -- the update dml.
119 --
120 -- Prerequisites:
121 -- This is an internal procedure which is called from the upd procedure.
122 --
123 -- In Parameters:
124 -- A Pl/Sql record structure.
125 --
126 -- Post Success:
127 -- Processing continues.
128 --
129 -- Post Failure:
130 -- If an error has occurred, an error message and exception wil be raised
131 -- but not handled.
132 --
133 -- Developer Implementation Notes:
134 -- Any pre-processing required before the update dml is issued should be
135 -- coded within this procedure. It is important to note that any 3rd party
136 -- maintenance should be reviewed before placing in this procedure.
137 --
138 -- Access Status:
139 -- Internal Row Handler Use Only.
140 --
141 -- {End Of Comments}
142 -- ----------------------------------------------------------------------------
143 Procedure pre_update
144 (p_rec in hxc_aps_shd.g_rec_type
145 ) is
146 --
147 l_proc varchar2(72);
148 --
149 Begin
150 if g_debug then
151 l_proc:= g_package||'pre_update';
152 hr_utility.set_location('Entering:'||l_proc, 5);
153 --
154 hr_utility.set_location(' Leaving:'||l_proc, 10);
155 end if;
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 the
165 -- 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_rec in hxc_aps_shd.g_rec_type
192 ) is
193 --
194 l_proc varchar2(72);
195 --
196 Begin
197 if g_debug then
198 l_proc := g_package||'post_update';
199 hr_utility.set_location('Entering:'||l_proc, 5);
200 end if;
201 begin
202 --
203 hxc_aps_rku.after_update
204 (p_approval_period_set_id
205 => p_rec.approval_period_set_id
206 ,p_name
207 => p_rec.name
208 ,p_object_version_number
209 => p_rec.object_version_number
210 ,p_name_o
211 => hxc_aps_shd.g_old_rec.name
212 ,p_object_version_number_o
213 => hxc_aps_shd.g_old_rec.object_version_number
214 );
215 --
216 exception
217 --
218 when hr_api.cannot_find_prog_unit then
219 --
220 hr_api.cannot_find_prog_unit_error
221 (p_module_name => 'HXC_APPROVAL_PERIOD_SETS'
222 ,p_hook_type => 'AU');
223 --
224 end;
225 --
226 if g_debug then
227 hr_utility.set_location(' Leaving:'||l_proc, 10);
228 end if;
229 End post_update;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |-----------------------------< convert_defs >-----------------------------|
233 -- ----------------------------------------------------------------------------
234 -- {Start Of Comments}
235 --
236 -- Description:
237 -- The Convert_Defs procedure has one very important function:
238 -- It must return the record structure for the row with all system defaulted
239 -- values converted into its corresponding parameter value for update. When
240 -- we attempt to update a row through the Upd process , certain
241 -- parameters can be defaulted which enables flexibility in the calling of
242 -- the upd process (e.g. only attributes which need to be updated need to be
243 -- specified). For the upd process to determine which attributes
244 -- have NOT been specified we need to check if the parameter has a reserved
245 -- system default value. Therefore, for all parameters which have a
246 -- corresponding reserved system default mechanism specified we need to
247 -- check if a system default is being used. If a system default is being
248 -- used then we convert the defaulted value into its corresponding attribute
249 -- value held in the g_old_rec data structure.
250 --
251 -- Prerequisites:
252 -- This private function can only be called from the upd process.
253 --
254 -- In Parameters:
255 -- A Pl/Sql record structure.
256 --
257 -- Post Success:
258 -- The record structure will be returned with all system defaulted parameter
259 -- values converted into its current row attribute value.
260 --
261 -- Post Failure:
262 -- No direct error handling is required within this function. Any possible
263 -- errors within this procedure will be a PL/SQL value error due to
264 -- conversion of datatypes or data lengths.
265 --
266 -- Developer Implementation Notes:
267 -- None.
268 --
269 -- Access Status:
270 -- Internal Row Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure convert_defs
275 (p_rec in out nocopy hxc_aps_shd.g_rec_type
276 ) is
277 --
278 Begin
279 --
280 -- We must now examine each argument value in the
281 -- p_rec plsql record structure
282 -- to see if a system default is being used. If a system default
283 -- is being used then we must set to the 'current' argument value.
284 --
285 If (p_rec.name = hr_api.g_varchar2) then
286 p_rec.name :=
287 hxc_aps_shd.g_old_rec.name;
288 End If;
289 --
290 End convert_defs;
291 --
292 -- ----------------------------------------------------------------------------
293 -- |---------------------------------< upd >----------------------------------|
294 -- ----------------------------------------------------------------------------
295 Procedure upd
296 (p_rec in out nocopy hxc_aps_shd.g_rec_type
297 ) is
298 --
299 l_proc varchar2(72);
300 --
301 Begin
302 g_debug:=hr_utility.debug_enabled;
303 if g_debug then
304 l_proc := g_package||'upd';
305 hr_utility.set_location('Entering:'||l_proc, 5);
306 end if;
307 --
308 -- We must lock the row which we need to update.
309 --
310 hxc_aps_shd.lck
311 (p_rec.approval_period_set_id
312 ,p_rec.object_version_number
313 );
314 --
315 -- 1. During an update system defaults are used to determine if
316 -- arguments have been defaulted or not. We must therefore
317 -- derive the full record structure values to be updated.
318 --
319 -- 2. Call the supporting update validate operations.
320 --
321 convert_defs(p_rec);
322 hxc_aps_bus.update_validate
323 (p_rec
324 );
325 --
326 -- Call the supporting pre-update operation
327 --
328 hxc_aps_upd.pre_update(p_rec);
329 --
330 -- Update the row.
331 --
332 hxc_aps_upd.update_dml(p_rec);
333 --
334 -- Call the supporting post-update operation
335 --
336 hxc_aps_upd.post_update
337 (p_rec
338 );
339 End upd;
340 --
341 -- ----------------------------------------------------------------------------
342 -- |---------------------------------< upd >----------------------------------|
343 -- ----------------------------------------------------------------------------
344 Procedure upd
345 (p_approval_period_set_id in number
346 ,p_object_version_number in out nocopy number
347 ,p_name in varchar2 default hr_api.g_varchar2
348 ) is
349 --
350 l_rec hxc_aps_shd.g_rec_type;
351 l_proc varchar2(72);
352 --
353 Begin
354 g_debug:=hr_utility.debug_enabled;
355 if g_debug then
356 l_proc:= g_package||'upd';
357 hr_utility.set_location('Entering:'||l_proc, 5);
358 end if;
359 --
360 -- Call conversion function to turn arguments into the
361 -- l_rec structure.
362 --
363 l_rec :=
364 hxc_aps_shd.convert_args
365 (p_approval_period_set_id
366 ,p_name
367 ,p_object_version_number
368 );
369 --
370 -- Having converted the arguments into the
371 -- plsql record structure we call the corresponding record
372 -- business process.
373 --
374 hxc_aps_upd.upd
375 (l_rec
376 );
377 p_object_version_number := l_rec.object_version_number;
378 --
379 if g_debug then
380 hr_utility.set_location(' Leaving:'||l_proc, 10);
381 end if;
382 End upd;
383 --
384 end hxc_aps_upd;