DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NRE_UPD

Source


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