DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_DTL_UPD

Source


1 Package Body hxc_dtl_upd as
2 /* $Header: hxcdtlrhi.pkb 120.2 2005/09/23 08:07:34 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_dtl_upd.';  -- Global package name
9 g_debug boolean :=hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 --   This procedure controls the actual dml update logic. The processing of
18 --   this procedure is:
19 --   1) Increment the object_version_number by 1 if the object_version_number
20 --      is defined as an attribute for this entity.
21 --   2) To set and unset the g_api_dml status as required (as we are about to
22 --      perform dml).
23 --   3) To update the specified row in the schema using the primary key in
24 --      the predicates.
25 --   4) To trap any constraint violations that may have occurred.
26 --   5) To raise any other errors.
27 --
28 -- Prerequisites:
29 --   This is an internal private procedure which must be called from the upd
30 --   procedure.
31 --
32 -- In Parameters:
33 --   A Pl/Sql record structre.
34 --
35 -- Post Success:
36 --   The specified row will be updated in the schema.
37 --
38 -- Post Failure:
39 --   On the update dml failure it is important to note that we always reset the
40 --   g_api_dml status to false.
41 --   If a check, unique or parent integrity constraint violation is raised the
42 --   constraint_error procedure will be called.
43 --   If any other error is reported, the error will be raised after the
44 --   g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 --   The update 'set' attribute list should be modified if any of your
48 --   attributes are not updateable.
49 --
50 -- Access Status:
51 --   Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure update_dml
56   (p_rec in out nocopy hxc_dtl_shd.g_rec_type
57   ) is
58 --
59   l_proc  varchar2(72);
60 --
61 Begin
62   if g_debug then
63 	l_proc := g_package||'update_dml';
64 	hr_utility.set_location('Entering:'||l_proc, 5);
65   end if;
66   --
67   --
68   --
69   --
70   -- Update the hxc_alias_definitions_tl Row
71   --
72   update hxc_alias_definitions_tl
73     set
74      alias_definition_id             = p_rec.alias_definition_id
75     ,alias_definition_name           = p_rec.alias_definition_name
76     ,description                     = p_rec.description
77     ,prompt                          = p_rec.prompt
78     ,language                        = p_rec.language
79     ,source_lang                     = p_rec.source_lang
80         ,last_updated_by		     = fnd_global.user_id
81     ,last_update_date		     = sysdate
82     ,last_update_login	             = fnd_global.login_id
83 
84     where alias_definition_id = p_rec.alias_definition_id
85     and language = p_rec.language;
86   --
87   --
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     --
97     hxc_dtl_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     --
102     hxc_dtl_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     --
107     hxc_dtl_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     --
111     Raise;
112 End update_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_update >------------------------------|
116 -- ----------------------------------------------------------------------------
117 -- {Start Of Comments}
118 --
119 -- Description:
120 --   This private procedure contains any processing which is required before
121 --   the update dml.
122 --
123 -- Prerequisites:
124 --   This is an internal procedure which is called from the upd procedure.
125 --
126 -- In Parameters:
127 --   A Pl/Sql record structure.
128 --
129 -- Post Success:
130 --   Processing continues.
131 --
132 -- Post Failure:
133 --   If an error has occurred, an error message and exception wil be raised
134 --   but not handled.
135 --
136 -- Developer Implementation Notes:
137 --   Any pre-processing required before the update dml is issued should be
138 --   coded within this procedure. It is important to note that any 3rd party
139 --   maintenance should be reviewed before placing in this procedure.
140 --
141 -- Access Status:
142 --   Internal Row Handler Use Only.
143 --
144 -- {End Of Comments}
145 -- ----------------------------------------------------------------------------
146 Procedure pre_update
147   (p_rec in hxc_dtl_shd.g_rec_type
148   ) is
149 --
150   l_proc  varchar2(72) ;
151 --
152 Begin
153   if g_debug then
154 	l_proc:= g_package||'pre_update';
155 	hr_utility.set_location('Entering:'||l_proc, 5);
156 	hr_utility.set_location(' Leaving:'||l_proc, 10);
157   end if;
158 End pre_update;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------------< post_update >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This private procedure contains any processing which is required after the
167 --   update dml.
168 --
169 -- Prerequisites:
170 --   This is an internal procedure which is called from the upd procedure.
171 --
172 -- In Parameters:
173 --   A Pl/Sql record structure.
174 --
175 -- Post Success:
176 --   Processing continues.
177 --
178 -- Post Failure:
179 --   If an error has occurred, an error message and exception will be raised
180 --   but not handled.
181 --
182 -- Developer Implementation Notes:
183 --   Any post-processing required after the update dml is issued should be
184 --   coded within this procedure. It is important to note that any 3rd party
185 --   maintenance should be reviewed before placing in this procedure.
186 --
187 -- Access Status:
188 --   Internal Row Handler Use Only.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure post_update
193   (p_rec                          in hxc_dtl_shd.g_rec_type
194   ) is
195 --
196   l_proc  varchar2(72);
197 --
198 Begin
199   if g_debug then
200 	l_proc := g_package||'post_update';
201 	hr_utility.set_location('Entering:'||l_proc, 5);
202   end if;
203   begin
204     --
205     hxc_dtl_rku.after_update
206       (p_alias_definition_id
207       => p_rec.alias_definition_id
208       ,p_alias_definition_name
209       => p_rec.alias_definition_name
210       ,p_description
211       => p_rec.description
212       ,p_prompt
213       => p_rec.prompt
214       ,p_language
215       => p_rec.language
216       ,p_source_lang
217       => p_rec.source_lang
218       ,p_alias_definition_name_o
219       => hxc_dtl_shd.g_old_rec.alias_definition_name
220       ,p_description_o
221       => hxc_dtl_shd.g_old_rec.description
222       ,p_prompt_o
223       => hxc_dtl_shd.g_old_rec.prompt
224       ,p_source_lang_o
225       => hxc_dtl_shd.g_old_rec.source_lang
226       );
227     --
228   exception
229     --
230     when hr_api.cannot_find_prog_unit then
231       --
232       hr_api.cannot_find_prog_unit_error
233         (p_module_name => 'HXC_ALIAS_DEFINITIONS_TL'
234         ,p_hook_type   => 'AU');
235       --
236   end;
237   --
238   if g_debug then
239 	 hr_utility.set_location(' Leaving:'||l_proc, 10);
240   end if;
241 End post_update;
242 --
243 -- ----------------------------------------------------------------------------
244 -- |-----------------------------< convert_defs >-----------------------------|
245 -- ----------------------------------------------------------------------------
246 -- {Start Of Comments}
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 -- {End Of Comments}
285 -- ----------------------------------------------------------------------------
286 Procedure convert_defs
287   (p_rec in out nocopy hxc_dtl_shd.g_rec_type
288   ) is
289 --
290 Begin
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.alias_definition_name = hr_api.g_varchar2) then
298     p_rec.alias_definition_name :=
299     hxc_dtl_shd.g_old_rec.alias_definition_name;
300   End If;
301   If (p_rec.description = hr_api.g_varchar2) then
302     p_rec.description :=
303     hxc_dtl_shd.g_old_rec.description;
304   End If;
305   If (p_rec.source_lang = hr_api.g_varchar2) then
306     p_rec.source_lang :=
307     hxc_dtl_shd.g_old_rec.source_lang;
308   End If;
309   --
310 End convert_defs;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< upd >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure upd
316   (p_rec                          in out nocopy hxc_dtl_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 	 hr_utility.set_location('Entering:'||l_proc, 5);
326   end if;
327   --
328   -- We must lock the row which we need to update.
329   --
330   hxc_dtl_shd.lck
331     (p_rec.alias_definition_id
332     ,p_rec.language
333     );
334   --
335   -- 1. During an update system defaults are used to determine if
336   --    arguments have been defaulted or not. We must therefore
337   --    derive the full record structure values to be updated.
338   --
339   -- 2. Call the supporting update validate operations.
340   --
341   convert_defs(p_rec);
342   hxc_dtl_bus.update_validate
343      (p_rec
344      );
345   --
346   -- Call the supporting pre-update operation
347   --
348   hxc_dtl_upd.pre_update(p_rec);
349   --
350   -- Update the row.
351   --
352   hxc_dtl_upd.update_dml(p_rec);
353   --
354   -- Call the supporting post-update operation
355   --
356   hxc_dtl_upd.post_update
357      (p_rec
358      );
359 End upd;
360 --
361 -- ----------------------------------------------------------------------------
362 -- |---------------------------------< upd >----------------------------------|
363 -- ----------------------------------------------------------------------------
364 Procedure upd
365   (p_alias_definition_id          in     number
366   ,p_alias_definition_name        in     varchar2  default hr_api.g_varchar2
367   ,p_language                     in     varchar2
368   ,p_source_lang                  in     varchar2  default hr_api.g_varchar2
369   ,p_description                  in     varchar2  default hr_api.g_varchar2
370   ,p_prompt                       in     varchar2  default hr_api.g_varchar2
371   ) is
372 --
373   l_rec	  hxc_dtl_shd.g_rec_type;
374   l_proc  varchar2(72);
375 --
376 Begin
377   g_debug:=hr_utility.debug_enabled;
378   if g_debug then
379 	l_proc := g_package||'upd';
380 	hr_utility.set_location('Entering:'||l_proc, 5);
381   end if;
382   --
383   -- Call conversion function to turn arguments into the
384   -- l_rec structure.
385   --
386   l_rec :=
387   hxc_dtl_shd.convert_args
388   (p_alias_definition_id
389   ,p_alias_definition_name
390   ,p_description
391   ,p_prompt
392   ,p_language
393   ,p_source_lang
394   );
395   --
396   -- Having converted the arguments into the
397   -- plsql record structure we call the corresponding record
398   -- business process.
399   --
400   hxc_dtl_upd.upd
401      (l_rec
402      );
403   --
404   --
405   if g_debug then
406 	hr_utility.set_location(' Leaving:'||l_proc, 10);
407   end if;
408 End upd;
409 --
410 -- ----------------------------------------------------------------------------
411 -- |------------------------------< upd_tl >----------------------------------|
412 -- ----------------------------------------------------------------------------
413 Procedure upd_tl
414   (p_language_code                 in varchar2
415   ,p_alias_definition_id          in number
416   ,p_alias_definition_name        in varchar2 default hr_api.g_varchar2
417   ,p_description                  in varchar2 default hr_api.g_varchar2
418   ,p_prompt                       in varchar2 default hr_api.g_varchar2
419   ) is
420   --
421   -- Cursor to obtain the translation rows where the language or
422   -- source_lang match the specified language.
423   --
424   cursor csr_upd_langs is
425     select dtl.language
426       from hxc_alias_definitions_tl dtl
427      where dtl.alias_definition_id = p_alias_definition_id
428        and p_language_code in (dtl.language
429                               ,dtl.source_lang);
430   --
431   l_proc  varchar2(72);
432   --
433 Begin
434   g_debug:=hr_utility.debug_enabled;
435   if g_debug then
436 	l_proc := g_package||'upd_tl';
437 	hr_utility.set_location('Entering:'||l_proc,10);
438   end if;
439   --
440   -- Update the translated values for every matching row
441   -- setting SOURCE_LANG to the specified language.
442   --
443   for l_lang in csr_upd_langs loop
444     hxc_dtl_upd.upd
445       (p_alias_definition_id         => p_alias_definition_id
446       ,p_language                    => l_lang.language
447       ,p_source_lang                 => p_language_code
448       ,p_alias_definition_name       => p_alias_definition_name
449       ,p_description                 => p_description
450       ,p_prompt                      => p_prompt
451       );
452   end loop;
453   --
454   if g_debug then
455 	hr_utility.set_location(' Leaving:'||l_proc,20);
456   end if;
457 End upd_tl;
458 --
459 end hxc_dtl_upd;