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