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