DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_TCC_UPD

Source


1 Package Body hxc_tcc_upd as
2 /* $Header: hxctccrhi.pkb 120.3 2006/07/07 06:27:47 gsirigin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_tcc_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_tcc_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_tcc_shd.g_api_dml := true;  -- Set the api dml status
74   --
75   -- Update the hxc_time_category_comps Row
76   --
77   update hxc_time_category_comps
78     set
79        time_category_id     = p_rec.time_category_id
80       ,ref_time_category_id = p_rec.ref_time_category_id
81       ,component_type_id    = p_rec.component_type_id
82       ,flex_value_set_id    = p_rec.flex_value_set_id
83       ,value_id             = p_rec.value_id
84       ,is_null              = p_rec.is_null
85       ,equal_to             = p_rec.equal_to
86       ,type                 = p_rec.type
87       ,object_version_number= p_rec.object_version_number
88       ,last_updated_by		     = fnd_global.user_id
89     ,last_update_date		     = sysdate
90     ,last_update_login	             = fnd_global.login_id
91 
92     where time_category_comp_id = p_rec.time_category_comp_id;
93 
94   hxc_tcc_shd.g_api_dml := false;   -- Unset the api dml status
95 
96   if g_debug then
97   	hr_utility.set_location(' Leaving:'||l_proc, 10);
98   end if;
99 
100 Exception
101   When hr_api.check_integrity_violated Then
102     -- A check constraint has been violated
103     hxc_tcc_shd.g_api_dml := false;   -- Unset the api dml status
104     hxc_tcc_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When hr_api.parent_integrity_violated Then
107     -- Parent integrity has been violated
108     hxc_tcc_shd.g_api_dml := false;   -- Unset the api dml status
109     hxc_tcc_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When hr_api.unique_integrity_violated Then
112     -- Unique integrity has been violated
113     hxc_tcc_shd.g_api_dml := false;   -- Unset the api dml status
114     hxc_tcc_shd.constraint_error
115       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116   When Others Then
117     hxc_tcc_shd.g_api_dml := false;   -- Unset the api dml status
118     Raise;
119 End update_dml;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |------------------------------< pre_update >------------------------------|
123 -- ----------------------------------------------------------------------------
124 -- {Start Of Comments}
125 --
126 -- Description:
127 --   This private procedure contains any processing which is required before
128 --   the update dml.
129 --
130 -- Prerequisites:
131 --   This is an internal procedure which is called from the upd procedure.
132 --
133 -- In Parameters:
134 --   A Pl/Sql record structure.
135 --
136 -- Post Success:
137 --   Processing continues.
138 --
139 -- Post Failure:
140 --   If an error has occurred, an error message and exception wil be raised
141 --   but not handled.
142 --
143 -- Developer Implementation Notes:
144 --   Any pre-processing required before the update dml is issued should be
145 --   coded within this procedure. It is important to note that any 3rd party
146 --   maintenance should be reviewed before placing in this procedure.
147 --
148 -- Access Status:
149 --   Internal Row Handler Use Only.
150 --
151 -- {End Of Comments}
152 -- ----------------------------------------------------------------------------
153 Procedure pre_update
154   (p_rec in hxc_tcc_shd.g_rec_type
155   ) is
156 --
157   l_proc  varchar2(72);
158 --
159 Begin
160 
161 
162   if g_debug then
163   	l_proc := g_package||'pre_update';
164   	hr_utility.set_location('Entering:'||l_proc, 5);
165   	--
166   	hr_utility.set_location(' Leaving:'||l_proc, 10);
167   end if;
168 End pre_update;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_update >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This private procedure contains any processing which is required after the
177 --   update dml.
178 --
179 -- Prerequisites:
180 --   This is an internal procedure which is called from the upd procedure.
181 --
182 -- In Parameters:
183 --   A Pl/Sql record structure.
184 --
185 -- Post Success:
186 --   Processing continues.
187 --
188 -- Post Failure:
189 --   If an error has occurred, an error message and exception will be raised
190 --   but not handled.
191 --
192 -- Developer Implementation Notes:
193 --   Any post-processing required after the update dml is issued should be
194 --   coded within this procedure. It is important to note that any 3rd party
195 --   maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 --   Internal Row Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_update
203   (p_rec                          in hxc_tcc_shd.g_rec_type
204   ) is
205 --
206   l_proc  varchar2(72);
207 --
208 Begin
209 
210 
211   if g_debug then
212   	l_proc := g_package||'post_update';
213   	hr_utility.set_location('Entering:'||l_proc, 5);
214   end if;
215   begin
216 
217     hxc_tcc_rku.after_update (
218      p_time_category_comp_id  => p_rec.time_category_comp_id
219     ,p_time_category_id       => p_rec.time_category_id
220     ,p_ref_time_category_id   => p_rec.ref_time_category_id
221     ,p_component_type_id      => p_rec.component_type_id
222     ,p_flex_value_set_id      => p_rec.flex_value_set_id
223     ,p_value_id               => p_rec.value_id
224     ,p_is_null                => p_rec.is_null
225     ,p_equal_to               => p_rec.equal_to
226     ,p_type                   => p_rec.type
227     ,p_object_version_number  => p_rec.object_version_number
228     ,p_time_category_comp_id_o=> hxc_tcc_shd.g_old_rec.time_category_comp_id
229     ,p_time_category_id_o     => hxc_tcc_shd.g_old_rec.time_category_id
230     ,p_ref_time_category_id_o => hxc_tcc_shd.g_old_rec.ref_time_category_id
231     ,p_component_type_id_o    => hxc_tcc_shd.g_old_rec.component_type_id
232     ,p_flex_value_set_id_o    => hxc_tcc_shd.g_old_rec.flex_value_set_id
233     ,p_value_id_o             => hxc_tcc_shd.g_old_rec.value_id
234     ,p_is_null_o              => hxc_tcc_shd.g_old_rec.is_null
235     ,p_equal_to_o             => hxc_tcc_shd.g_old_rec.equal_to
236     ,p_type_o                 => hxc_tcc_shd.g_old_rec.type
237     ,p_object_version_number_o=> hxc_tcc_shd.g_old_rec.object_version_number );
238 
239   exception
240 
241     when hr_api.cannot_find_prog_unit then
242 
243       hr_api.cannot_find_prog_unit_error
244         (p_module_name => 'HXC_TIME_CATEGORY_COMPS'
245         ,p_hook_type   => 'AU');
246 
247   end;
248 
249   if g_debug then
250   	hr_utility.set_location(' Leaving:'||l_proc, 10);
251   end if;
252 End post_update;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< convert_defs >-----------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 --   The Convert_Defs procedure has one very important function:
261 --   It must return the record structure for the row with all system defaulted
262 --   values converted into its corresponding parameter value for update. When
263 --   we attempt to update a row through the Upd process , certain
264 --   parameters can be defaulted which enables flexibility in the calling of
265 --   the upd process (e.g. only attributes which need to be updated need to be
266 --   specified). For the upd process to determine which attributes
267 --   have NOT been specified we need to check if the parameter has a reserved
268 --   system default value. Therefore, for all parameters which have a
269 --   corresponding reserved system default mechanism specified we need to
270 --   check if a system default is being used. If a system default is being
271 --   used then we convert the defaulted value into its corresponding attribute
272 --   value held in the g_old_rec data structure.
273 --
274 -- Prerequisites:
275 --   This private function can only be called from the upd process.
276 --
277 -- In Parameters:
278 --   A Pl/Sql record structure.
279 --
280 -- Post Success:
281 --   The record structure will be returned with all system defaulted parameter
282 --   values converted into its current row attribute value.
283 --
284 -- Post Failure:
285 --   No direct error handling is required within this function. Any possible
286 --   errors within this procedure will be a PL/SQL value error due to
287 --   conversion of datatypes or data lengths.
288 --
289 -- Developer Implementation Notes:
290 --   None.
291 --
292 -- Access Status:
293 --   Internal Row Handler Use Only.
294 --
295 -- {End Of Comments}
296 -- ----------------------------------------------------------------------------
297 Procedure convert_defs
298   (p_rec in out nocopy hxc_tcc_shd.g_rec_type
299   ) is
300 --
301 Begin
302 
303   -- We must now examine each argument value in the
304   -- p_rec plsql record structure
305   -- to see if a system default is being used. If a system default
306   -- is being used then we must set to the 'current' argument value.
307 
308   If (p_rec.time_category_id = hr_api.g_number) then
309       p_rec.time_category_id := hxc_tcc_shd.g_old_rec.time_category_id;
310   End If;
311 
312   If (p_rec.ref_time_category_id = hr_api.g_number) then
313       p_rec.ref_time_category_id := hxc_tcc_shd.g_old_rec.ref_time_category_id;
314   End If;
315 
316   If (p_rec.component_type_id = hr_api.g_number) then
317       p_rec.component_type_id := hxc_tcc_shd.g_old_rec.component_type_id;
318   End If;
319 
320   If (p_rec.flex_value_set_id = hr_api.g_number) then
321       p_rec.flex_value_set_id := hxc_tcc_shd.g_old_rec.flex_value_set_id;
322   End If;
323 
324   If (p_rec.value_id = hr_api.g_varchar2) then
325       p_rec.value_id := hxc_tcc_shd.g_old_rec.value_id;
326   End If;
327 
328   If (p_rec.is_null = hr_api.g_varchar2) then
329       p_rec.is_null := hxc_tcc_shd.g_old_rec.is_null;
330   End If;
331 
332   If (p_rec.equal_to = hr_api.g_varchar2) then
333       p_rec.equal_to := hxc_tcc_shd.g_old_rec.equal_to;
334   End If;
335 
336   If (p_rec.type = hr_api.g_varchar2) then
337       p_rec.type := hxc_tcc_shd.g_old_rec.type;
338   End If;
339 
340 End convert_defs;
341 --
342 -- ----------------------------------------------------------------------------
343 -- |---------------------------------< upd >----------------------------------|
344 -- ----------------------------------------------------------------------------
345 Procedure upd
346   (p_rec                          in out nocopy hxc_tcc_shd.g_rec_type
347   ) is
348 --
349   l_proc  varchar2(72);
350 
351   l_sql_string CLOB; -- not used, needed for caching strategy which
352                      -- reuses update_time_cat...
353 --
354 Begin
355   g_debug := hr_utility.debug_enabled;
356 
357   if g_debug then
358   	l_proc := g_package||'upd';
359   	hr_utility.set_location('Entering:'||l_proc, 5);
360   end if;
361   --
362   -- We must lock the row which we need to update.
363   --
364   hxc_tcc_shd.lck
365     (p_rec.time_category_comp_id
366     ,p_rec.object_version_number
367     );
368   --
369   -- 1. During an update system defaults are used to determine if
370   --    arguments have been defaulted or not. We must therefore
371   --    derive the full record structure values to be updated.
372   --
373   -- 2. Call the supporting update validate operations.
374   --
375   convert_defs(p_rec);
376   hxc_tcc_bus.update_validate
377      (p_rec
378      );
379   --
380   -- Call the supporting pre-update operation
381   --
382   hxc_tcc_upd.pre_update(p_rec);
383   --
384   -- Update the row.
385   --
386   hxc_tcc_upd.update_dml(p_rec);
387   --
388   -- Call the supporting post-update operation
389   --
390   hxc_tcc_upd.post_update
391      (p_rec
392      );
393 
394   IF ( p_rec.type IN ( 'AN', 'MC_VS' ) )
395   THEN
396 	hxc_time_category_utils_pkg.update_time_category_comp_sql ( p_rec );
397 
398   END IF;
399 
400   IF ( p_rec.type = 'MC' OR hxc_tcc_shd.g_old_rec.type = 'MC' )
401   THEN
402         hxc_time_category_api.set_dynamic_sql_string ( p_time_category_id => p_rec.time_category_id );
403 
404   END IF;
405 
406 End upd;
407 --
408 -- ----------------------------------------------------------------------------
409 -- |---------------------------------< upd >----------------------------------|
410 -- ----------------------------------------------------------------------------
411 Procedure upd
412   (
413    p_time_category_comp_id        in number
414   ,p_time_category_id             in number
415   ,p_object_version_number        in out nocopy number
416   ,p_ref_time_category_id         in number default hr_api.g_number
417   ,p_component_type_id            in number default hr_api.g_number
418   ,p_flex_value_set_id            in number default hr_api.g_number
419   ,p_value_id                     in varchar2 default hr_api.g_varchar2
420   ,p_is_null                      in varchar2 default hr_api.g_varchar2
421   ,p_equal_to                     in varchar2 default hr_api.g_varchar2
422   ,p_type                         in varchar2 default hr_api.g_varchar2
423   ) is
424 --
425   l_rec	  hxc_tcc_shd.g_rec_type;
426   l_proc  varchar2(72);
427 --
428 Begin
429   g_debug := hr_utility.debug_enabled;
430 
431   if g_debug then
432   	l_proc := g_package||'upd';
433   	hr_utility.set_location('Entering:'||l_proc, 5);
434   end if;
435 
436   -- Call conversion function to turn arguments into the
437   -- l_rec structure.
438 
439   l_rec :=
440   hxc_tcc_shd.convert_args (
441    p_time_category_comp_id
442   ,p_time_category_id
443   ,p_ref_time_category_id
444   ,p_component_type_id
445   ,p_flex_value_set_id
446   ,p_value_id
447   ,p_is_null
448   ,p_equal_to
449   ,p_type
450   ,p_object_version_number
451   );
452   --
453   -- Having converted the arguments into the
454   -- plsql record structure we call the corresponding record
455   -- business process.
456   --
457   hxc_tcc_upd.upd
458      (l_rec
459      );
460   p_object_version_number := l_rec.object_version_number;
461   --
462   if g_debug then
463   	hr_utility.set_location(' Leaving:'||l_proc, 10);
464   end if;
465 End upd;
466 --
467 end hxc_tcc_upd;