DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_AVM_UPD

Source


1 Package Body hr_avm_upd as
2 /* $Header: hravmrhi.pkb 115.1 2002/12/02 15:47:59 apholt noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_avm_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 hr_avm_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   --
67   --
68   -- Update the hr_ath_variablemap Row
69   --
70   update hr_ath_variablemap
71     set
72      ath_variablemap_id              = p_rec.ath_variablemap_id
73     ,ath_dsn                         = p_rec.ath_dsn
74     ,ath_tablename                   = p_rec.ath_tablename
75     ,ath_columnname                  = p_rec.ath_columnname
76     ,ath_varname                     = p_rec.ath_varname
77     ,object_version_number           = p_rec.object_version_number
78     where ath_variablemap_id = p_rec.ath_variablemap_id;
79   --
80   --
81   --
82   hr_utility.set_location(' Leaving:'||l_proc, 10);
83 --
84 Exception
85   When hr_api.check_integrity_violated Then
86     -- A check constraint has been violated
87     --
88     hr_avm_shd.constraint_error
89       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90   When hr_api.parent_integrity_violated Then
91     -- Parent integrity has been violated
92     --
93     hr_avm_shd.constraint_error
94       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95   When hr_api.unique_integrity_violated Then
96     -- Unique integrity has been violated
97     --
98     hr_avm_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When Others Then
101     --
102     Raise;
103 End update_dml;
104 --
105 -- ----------------------------------------------------------------------------
106 -- |------------------------------< pre_update >------------------------------|
107 -- ----------------------------------------------------------------------------
108 -- {Start Of Comments}
109 --
110 -- Description:
111 --   This private procedure contains any processing which is required before
112 --   the update dml.
113 --
114 -- Prerequisites:
115 --   This is an internal procedure which is called from the upd procedure.
116 --
117 -- In Parameters:
118 --   A Pl/Sql record structure.
119 --
120 -- Post Success:
121 --   Processing continues.
122 --
123 -- Post Failure:
124 --   If an error has occurred, an error message and exception wil be raised
125 --   but not handled.
126 --
127 -- Developer Implementation Notes:
128 --   Any pre-processing required before the update dml is issued should be
129 --   coded within this procedure. It is important to note that any 3rd party
130 --   maintenance should be reviewed before placing in this procedure.
131 --
132 -- Access Status:
133 --   Internal Row Handler Use Only.
134 --
135 -- {End Of Comments}
136 -- ----------------------------------------------------------------------------
137 Procedure pre_update
138   (p_rec in hr_avm_shd.g_rec_type
139   ) is
140 --
141   l_proc  varchar2(72) := g_package||'pre_update';
142 --
143 Begin
144   hr_utility.set_location('Entering:'||l_proc, 5);
145   --
146   hr_utility.set_location(' Leaving:'||l_proc, 10);
147 End pre_update;
148 --
149 -- ----------------------------------------------------------------------------
150 -- |-----------------------------< post_update >------------------------------|
151 -- ----------------------------------------------------------------------------
152 -- {Start Of Comments}
153 --
154 -- Description:
155 --   This private procedure contains any processing which is required after
156 --   the update dml.
157 --
158 -- Prerequisites:
159 --   This is an internal procedure which is called from the upd procedure.
160 --
161 -- In Parameters:
162 --   A Pl/Sql record structure.
163 --
164 -- Post Success:
165 --   Processing continues.
166 --
167 -- Post Failure:
168 --   If an error has occurred, an error message and exception will be raised
169 --   but not handled.
170 --
171 -- Developer Implementation Notes:
172 --   Any post-processing required after the update dml is issued should be
173 --   coded within this procedure. It is important to note that any 3rd party
174 --   maintenance should be reviewed before placing in this procedure.
175 --
176 -- Access Status:
177 --   Internal Row Handler Use Only.
178 --
179 -- {End Of Comments}
180 -- ----------------------------------------------------------------------------
181 Procedure post_update
182   (p_rec                          in hr_avm_shd.g_rec_type
183   ) is
184 --
185   l_proc  varchar2(72) := g_package||'post_update';
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189   begin
190     --
191     hr_avm_rku.after_update
192       (p_ath_dsn
193       => p_rec.ath_dsn
194       ,p_ath_tablename
195       => p_rec.ath_tablename
196       ,p_ath_columnname
197       => p_rec.ath_columnname
198       ,p_ath_varname
199       => p_rec.ath_varname
200       ,p_object_version_number
201       => p_rec.object_version_number
202       ,p_ath_variablemap_id
203       => p_rec.ath_variablemap_id
204       ,p_ath_dsn_o
205       => hr_avm_shd.g_old_rec.ath_dsn
206       ,p_ath_tablename_o
207       => hr_avm_shd.g_old_rec.ath_tablename
208       ,p_ath_columnname_o
209       => hr_avm_shd.g_old_rec.ath_columnname
210       ,p_ath_varname_o
211       => hr_avm_shd.g_old_rec.ath_varname
212       ,p_object_version_number_o
213       => hr_avm_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 => 'HR_ATH_VARIABLEMAP'
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 hr_avm_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.ath_dsn = hr_api.g_varchar2) then
284     p_rec.ath_dsn :=
285     hr_avm_shd.g_old_rec.ath_dsn;
286   End If;
287   If (p_rec.ath_tablename = hr_api.g_varchar2) then
288     p_rec.ath_tablename :=
289     hr_avm_shd.g_old_rec.ath_tablename;
290   End If;
291   If (p_rec.ath_columnname = hr_api.g_varchar2) then
292     p_rec.ath_columnname :=
293     hr_avm_shd.g_old_rec.ath_columnname;
294   End If;
295   If (p_rec.ath_varname = hr_api.g_varchar2) then
296     p_rec.ath_varname :=
297     hr_avm_shd.g_old_rec.ath_varname;
298   End If;
299   --
300 End convert_defs;
301 --
302 -- ----------------------------------------------------------------------------
303 -- |---------------------------------< upd >----------------------------------|
304 -- ----------------------------------------------------------------------------
305 Procedure upd
306   (p_rec                          in out nocopy hr_avm_shd.g_rec_type
307   ) is
308 --
309   l_proc  varchar2(72) := g_package||'upd';
310 --
311 Begin
312   hr_utility.set_location('Entering:'||l_proc, 5);
313   --
314   -- We must lock the row which we need to update.
315   --
316   hr_avm_shd.lck
317     (p_rec.ath_variablemap_id
318     ,p_rec.object_version_number
319     );
320   --
321   -- 1. During an update system defaults are used to determine if
322   --    arguments have been defaulted or not. We must therefore
323   --    derive the full record structure values to be updated.
324   --
325   -- 2. Call the supporting update validate operations.
326   --
327   convert_defs(p_rec);
328   hr_avm_bus.update_validate
329      (p_rec
330      );
331   --
332   -- Call to raise any errors on multi-message list
333   hr_multi_message.end_validation_set;
334   --
335   -- Call the supporting pre-update operation
336   --
337   hr_avm_upd.pre_update(p_rec);
338   --
339   -- Update the row.
340   --
341   hr_avm_upd.update_dml(p_rec);
342   --
343   -- Call the supporting post-update operation
344   --
345   hr_avm_upd.post_update
346      (p_rec
347      );
348   --
349   -- Call to raise any errors on multi-message list
350   hr_multi_message.end_validation_set;
351 End upd;
352 --
353 -- ----------------------------------------------------------------------------
354 -- |---------------------------------< upd >----------------------------------|
355 -- ----------------------------------------------------------------------------
356 Procedure upd
357   (p_ath_variablemap_id           in     number
358   ,p_object_version_number        in out nocopy number
359   ,p_ath_dsn                      in     varchar2  default hr_api.g_varchar2
360   ,p_ath_tablename                in     varchar2  default hr_api.g_varchar2
361   ,p_ath_columnname               in     varchar2  default hr_api.g_varchar2
362   ,p_ath_varname                  in     varchar2  default hr_api.g_varchar2
363   ) is
364 --
365   l_rec   hr_avm_shd.g_rec_type;
366   l_proc  varchar2(72) := g_package||'upd';
367 --
368 Begin
369   hr_utility.set_location('Entering:'||l_proc, 5);
370   --
371   -- Call conversion function to turn arguments into the
372   -- l_rec structure.
373   --
374   l_rec :=
375   hr_avm_shd.convert_args
376   (p_ath_variablemap_id
377   ,p_ath_dsn
378   ,p_ath_tablename
379   ,p_ath_columnname
380   ,p_ath_varname
381   ,p_object_version_number
382   );
383   --
384   -- Having converted the arguments into the
385   -- plsql record structure we call the corresponding record
386   -- business process.
387   --
388   hr_avm_upd.upd
389      (l_rec
390      );
391   p_object_version_number := l_rec.object_version_number;
392   --
393   hr_utility.set_location(' Leaving:'||l_proc, 10);
394 End upd;
395 --
396 end hr_avm_upd;