DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_TKGQC_UPD

Source


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