DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NLA_UPD

Source


1 Package Body ghr_nla_upd as
2 /* $Header: ghnlarhi.pkb 115.4 1999/11/09 22:41:05 pkm ship    $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ghr_nla_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 update the specified row in the schema using the primary key in
21 --      the predicates.
22 --   3) To trap any constraint violations that may have occurred.
23 --   4) To raise any other errors.
24 --
25 -- Prerequisites:
26 --   This is an internal private procedure which must be called from the upd
27 --   procedure.
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be updated in the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   The update 'set' attribute list should be modified if any of your
41 --   attributes are not updateable.
42 --
43 -- Access Status:
44 --   Internal Row Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out ghr_nla_shd.g_rec_type) is
49 --
50   l_proc  varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53   hr_utility.set_location('Entering:'||l_proc, 5);
54   --
55   -- Increment the object version
56   --
57   p_rec.object_version_number := p_rec.object_version_number + 1;
58   --
59   --
60   -- Update the ghr_noac_las Row
61   --
62   update ghr_noac_las
63   set
64   noac_la_id                        = p_rec.noac_la_id,
65   nature_of_action_id               = p_rec.nature_of_action_id,
66   lac_lookup_code                   = p_rec.lac_lookup_code,
67   enabled_flag                      = p_rec.enabled_flag,
68   date_from                         = p_rec.date_from,
69   date_to                           = p_rec.date_to,
70   object_version_number             = p_rec.object_version_number,
71   valid_first_lac_flag              = p_rec.valid_first_lac_flag,
72   valid_second_lac_flag             = p_rec.valid_second_lac_flag
73   where noac_la_id = p_rec.noac_la_id;
74   --
75   --
76   hr_utility.set_location(' Leaving:'||l_proc, 10);
77 --
78 Exception
79   When hr_api.check_integrity_violated Then
80     -- A check constraint has been violated
81     ghr_nla_shd.constraint_error
82       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
83   When hr_api.parent_integrity_violated Then
84     -- Parent integrity has been violated
85     ghr_nla_shd.constraint_error
86       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
87   When hr_api.unique_integrity_violated Then
88     -- Unique integrity has been violated
89     ghr_nla_shd.constraint_error
90       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91   When Others Then
92     Raise;
93 End update_dml;
94 --
95 -- ----------------------------------------------------------------------------
96 -- |------------------------------< pre_update >------------------------------|
97 -- ----------------------------------------------------------------------------
98 -- {Start Of Comments}
99 --
100 -- Description:
101 --   This private procedure contains any processing which is required before
102 --   the update dml.
103 --
104 -- Prerequisites:
105 --   This is an internal procedure which is called from the upd procedure.
106 --
107 -- In Parameters:
108 --   A Pl/Sql record structre.
109 --
110 -- Post Success:
111 --   Processing continues.
112 --
113 -- Post Failure:
114 --   If an error has occurred, an error message and exception will be raised
115 --   but not handled.
116 --
117 -- Developer Implementation Notes:
118 --   Any pre-processing required before the update dml is issued should be
119 --   coded within this procedure. It is important to note that any 3rd party
120 --   maintenance should be reviewed before placing in this procedure.
121 --
122 -- Access Status:
123 --   Internal Row Handler Use Only.
124 --
125 -- {End Of Comments}
126 -- ----------------------------------------------------------------------------
127 Procedure pre_update(p_rec in ghr_nla_shd.g_rec_type) is
128 --
129   l_proc  varchar2(72) := g_package||'pre_update';
130 --
131 Begin
132   hr_utility.set_location('Entering:'||l_proc, 5);
133   --
134   hr_utility.set_location(' Leaving:'||l_proc, 10);
135 End pre_update;
136 --
137 -- ----------------------------------------------------------------------------
138 -- |-----------------------------< post_update >------------------------------|
139 -- ----------------------------------------------------------------------------
140 -- {Start Of Comments}
141 --
142 -- Description:
143 --   This private procedure contains any processing which is required after the
144 --   update dml.
145 --
146 -- Prerequisites:
147 --   This is an internal procedure which is called from the upd procedure.
148 --
149 -- In Parameters:
150 --   A Pl/Sql record structre.
151 --
152 -- Post Success:
153 --   Processing continues.
154 --
155 -- Post Failure:
156 --   If an error has occurred, an error message and exception will be raised
157 --   but not handled.
158 --
159 -- Developer Implementation Notes:
160 --   Any post-processing required after the update dml is issued should be
161 --   coded within this procedure. It is important to note that any 3rd party
162 --   maintenance should be reviewed before placing in this procedure.
163 --
164 -- Access Status:
165 --   Internal Row Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure post_update(
170 p_effective_date in date,p_rec in ghr_nla_shd.g_rec_type) is
171 --
172   l_proc  varchar2(72) := g_package||'post_update';
173 --
174 Begin
175   hr_utility.set_location('Entering:'||l_proc, 5);
176 --
177   --
178   -- Start of API User Hook for post_update.
179   --
180   begin
181     --
182     ghr_nla_rku.after_update
183       (
184   p_noac_la_id                    =>p_rec.noac_la_id
185  ,p_nature_of_action_id           =>p_rec.nature_of_action_id
186  ,p_lac_lookup_code               =>p_rec.lac_lookup_code
187  ,p_enabled_flag                  =>p_rec.enabled_flag
188  ,p_date_from                     =>p_rec.date_from
189  ,p_date_to                       =>p_rec.date_to
190  ,p_object_version_number         =>p_rec.object_version_number
191  ,p_valid_first_lac_flag          =>p_rec.valid_first_lac_flag
192  ,p_valid_second_lac_flag         =>p_rec.valid_second_lac_flag
193  ,p_effective_date                =>p_effective_date
194  ,p_nature_of_action_id_o         =>ghr_nla_shd.g_old_rec.nature_of_action_id
195  ,p_lac_lookup_code_o             =>ghr_nla_shd.g_old_rec.lac_lookup_code
196  ,p_enabled_flag_o                =>ghr_nla_shd.g_old_rec.enabled_flag
197  ,p_date_from_o                   =>ghr_nla_shd.g_old_rec.date_from
198  ,p_date_to_o                     =>ghr_nla_shd.g_old_rec.date_to
199  ,p_object_version_number_o       =>ghr_nla_shd.g_old_rec.object_version_number
200  ,p_valid_first_lac_flag_o        =>ghr_nla_shd.g_old_rec.valid_first_lac_flag
201  ,p_valid_second_lac_flag_o       =>ghr_nla_shd.g_old_rec.valid_second_lac_flag
202       );
203     --
204   exception
205     --
206     when hr_api.cannot_find_prog_unit then
207       --
208       hr_api.cannot_find_prog_unit_error
209         (p_module_name => 'ghr_noac_las'
210         ,p_hook_type   => 'AU');
211       --
212   end;
213   --
214   -- End of API User Hook for post_update.
215   --
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End post_update;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |-----------------------------< convert_defs >-----------------------------|
222 -- ----------------------------------------------------------------------------
223 -- {Start Of Comments}
224 --
225 -- Description:
226 --   The Convert_Defs procedure has one very important function:
227 --   It must return the record structure for the row with all system defaulted
228 --   values converted into its corresponding parameter value for update. When
229 --   we attempt to update a row through the Upd process , certain
230 --   parameters can be defaulted which enables flexibility in the calling of
231 --   the upd process (e.g. only attributes which need to be updated need to be
232 --   specified). For the upd process to determine which attributes
233 --   have NOT been specified we need to check if the parameter has a reserved
234 --   system default value. Therefore, for all parameters which have a
235 --   corresponding reserved system default mechanism specified we need to
236 --   check if a system default is being used. If a system default is being
237 --   used then we convert the defaulted value into its corresponding attribute
238 --   value held in the g_old_rec data structure.
239 --
240 -- Prerequisites:
241 --   This private function can only be called from the upd process.
242 --
243 -- In Parameters:
244 --   A Pl/Sql record structre.
245 --
246 -- Post Success:
247 --   The record structure will be returned with all system defaulted parameter
248 --   values converted into its current row attribute value.
249 --
250 -- Post Failure:
251 --   No direct error handling is required within this function. Any possible
252 --   errors within this procedure will be a PL/SQL value error due to conversion
253 --   of datatypes or data lengths.
254 --
255 -- Developer Implementation Notes:
256 --   None.
257 --
258 -- Access Status:
259 --   Internal Row Handler Use Only.
260 --
261 -- {End Of Comments}
262 -- ----------------------------------------------------------------------------
263 Procedure convert_defs(p_rec in out ghr_nla_shd.g_rec_type) is
264 --
265   l_proc  varchar2(72) := g_package||'convert_defs';
266 --
267 Begin
268   --
269   hr_utility.set_location('Entering:'||l_proc, 5);
270   --
271   -- We must now examine each argument value in the
272   -- p_rec plsql record structure
273   -- to see if a system default is being used. If a system default
274   -- is being used then we must set to the 'current' argument value.
275   --
276   If (p_rec.nature_of_action_id = hr_api.g_number) then
277     p_rec.nature_of_action_id :=
278     ghr_nla_shd.g_old_rec.nature_of_action_id;
279   End If;
280   If (p_rec.lac_lookup_code = hr_api.g_varchar2) then
281     p_rec.lac_lookup_code :=
282     ghr_nla_shd.g_old_rec.lac_lookup_code;
283   End If;
284   If (p_rec.enabled_flag = hr_api.g_varchar2) then
285     p_rec.enabled_flag :=
286     ghr_nla_shd.g_old_rec.enabled_flag;
287   End If;
288   If (p_rec.date_from = hr_api.g_date) then
289     p_rec.date_from :=
290     ghr_nla_shd.g_old_rec.date_from;
291   End If;
292   If (p_rec.date_to = hr_api.g_date) then
293     p_rec.date_to :=
294     ghr_nla_shd.g_old_rec.date_to;
295   End If;
296   If (p_rec.valid_first_lac_flag = hr_api.g_varchar2) then
297     p_rec.valid_first_lac_flag :=
298     ghr_nla_shd.g_old_rec.valid_first_lac_flag;
299   End If;
300   If (p_rec.valid_second_lac_flag = hr_api.g_varchar2) then
301     p_rec.valid_second_lac_flag :=
302     ghr_nla_shd.g_old_rec.valid_second_lac_flag;
303   End If;
304   --
305   hr_utility.set_location(' Leaving:'||l_proc, 10);
306 --
307 End convert_defs;
308 --
309 -- ----------------------------------------------------------------------------
310 -- |---------------------------------< upd >----------------------------------|
311 -- ----------------------------------------------------------------------------
312 Procedure upd
313   (
314   p_effective_date in date,
315   p_rec        in out ghr_nla_shd.g_rec_type
316   ) is
317 --
318   l_proc  varchar2(72) := g_package||'upd';
319 --
320 Begin
321   hr_utility.set_location('Entering:'||l_proc, 5);
322   --
323   -- We must lock the row which we need to update.
324   --
325   ghr_nla_shd.lck
326 	(
327 	p_rec.noac_la_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   ghr_nla_bus.update_validate(p_rec
339   ,p_effective_date);
340   --
341   -- Call the supporting pre-update operation
342   --
343   pre_update(p_rec);
344   --
345   -- Update the row.
346   --
347   update_dml(p_rec);
348   --
349   -- Call the supporting post-update operation
350   --
351   post_update(
352 p_effective_date,p_rec);
353 End upd;
354 --
355 -- ----------------------------------------------------------------------------
356 -- |---------------------------------< upd >----------------------------------|
357 -- ----------------------------------------------------------------------------
358 Procedure upd
359   (
360   p_effective_date in date,
361   p_noac_la_id                   in number,
362   p_nature_of_action_id          in number           default hr_api.g_number,
363   p_lac_lookup_code              in varchar2         default hr_api.g_varchar2,
364   p_enabled_flag                 in varchar2         default hr_api.g_varchar2,
365   p_date_from                    in date             default hr_api.g_date,
366   p_date_to                      in date             default hr_api.g_date,
367   p_object_version_number        in out number,
368   p_valid_first_lac_flag         in varchar2         default hr_api.g_varchar2,
369   p_valid_second_lac_flag        in varchar2         default hr_api.g_varchar2
370   ) is
371 --
372   l_rec	  ghr_nla_shd.g_rec_type;
373   l_proc  varchar2(72) := g_package||'upd';
374 --
375 Begin
376   hr_utility.set_location('Entering:'||l_proc, 5);
377   --
378   -- Call conversion function to turn arguments into the
379   -- l_rec structure.
380   --
381   l_rec :=
382   ghr_nla_shd.convert_args
383   (
384   p_noac_la_id,
385   p_nature_of_action_id,
386   p_lac_lookup_code,
387   p_enabled_flag,
388   p_date_from,
389   p_date_to,
390   p_object_version_number,
391   p_valid_first_lac_flag,
392   p_valid_second_lac_flag
393   );
394   --
395   -- Having converted the arguments into the
396   -- plsql record structure we call the corresponding record
397   -- business process.
398   --
399   upd(
400     p_effective_date,l_rec);
401   p_object_version_number := l_rec.object_version_number;
402   --
403   hr_utility.set_location(' Leaving:'||l_proc, 10);
404 End upd;
405 --
406 end ghr_nla_upd;