DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HTC_UPD

Source


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