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