DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_AMD_UPD

Source


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