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