DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_AHC_UPD

Source


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