DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_FFN_UPD

Source


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