1 Package Body hr_trv_upd as
2 /* $Header: hrtrvrhi.pkb 115.2 99/10/04 06:00:25 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_trv_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 -- Pre Conditions:
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 Table Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out hr_trv_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_trv_shd.g_api_dml := true; -- Set the api dml status
63 --
64 -- Update the hr_api_transaction_values Row
65 --
66 update hr_api_transaction_values
67 set
68 transaction_value_id = p_rec.transaction_value_id,
69 transaction_step_id = p_rec.transaction_step_id,
70 datatype = p_rec.datatype,
71 name = p_rec.name,
72 varchar2_value = p_rec.varchar2_value,
73 number_value = p_rec.number_value,
74 date_value = p_rec.date_value,
75 original_varchar2_value = p_rec.original_varchar2_value,
76 original_number_value = p_rec.original_number_value,
77 original_date_value = p_rec.original_date_value
78 where transaction_value_id = p_rec.transaction_value_id;
79 --
80 hr_trv_shd.g_api_dml := false; -- Unset the api dml status
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 hr_trv_shd.g_api_dml := false; -- Unset the api dml status
88 hr_trv_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 hr_trv_shd.g_api_dml := false; -- Unset the api dml status
93 hr_trv_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 hr_trv_shd.g_api_dml := false; -- Unset the api dml status
98 hr_trv_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When Others Then
101 hr_trv_shd.g_api_dml := false; -- Unset the api dml status
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 -- Pre Conditions:
115 -- This is an internal procedure which is called from the upd procedure.
116 --
117 -- In Parameters:
118 -- A Pl/Sql record structre.
119 --
120 -- Post Success:
121 -- Processing continues.
122 --
123 -- Post Failure:
124 -- If an error has occurred, an error message and exception will 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 Table Handler Use Only.
134 --
135 -- {End Of Comments}
136 -- ----------------------------------------------------------------------------
137 Procedure pre_update(p_rec in hr_trv_shd.g_rec_type) is
138 --
139 l_proc varchar2(72) := g_package||'pre_update';
140 --
141 Begin
142 hr_utility.set_location('Entering:'||l_proc, 5);
143 --
144 hr_utility.set_location(' Leaving:'||l_proc, 10);
145 End pre_update;
146 --
147 -- ----------------------------------------------------------------------------
148 -- |-----------------------------< post_update >------------------------------|
149 -- ----------------------------------------------------------------------------
150 -- {Start Of Comments}
151 --
152 -- Description:
153 -- This private procedure contains any processing which is required after the
154 -- update dml.
155 --
156 -- Pre Conditions:
157 -- This is an internal procedure which is called from the upd procedure.
158 --
159 -- In Parameters:
160 -- A Pl/Sql record structre.
161 --
162 -- Post Success:
163 -- Processing continues.
164 --
165 -- Post Failure:
166 -- If an error has occurred, an error message and exception will be raised
167 -- but not handled.
168 --
169 -- Developer Implementation Notes:
170 -- Any post-processing required after the update dml is issued should be
171 -- coded within this procedure. It is important to note that any 3rd party
172 -- maintenance should be reviewed before placing in this procedure.
173 --
174 -- Access Status:
175 -- Internal Table Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure post_update(p_rec in hr_trv_shd.g_rec_type) is
180 --
181 l_proc varchar2(72) := g_package||'post_update';
182 --
183 Begin
184 hr_utility.set_location('Entering:'||l_proc, 5);
185 --
186 hr_utility.set_location(' Leaving:'||l_proc, 10);
187 End post_update;
188 --
189 -- ----------------------------------------------------------------------------
190 -- |-----------------------------< convert_defs >-----------------------------|
191 -- ----------------------------------------------------------------------------
192 -- {Start Of Comments}
193 --
194 -- Description:
195 -- The Convert_Defs procedure has one very important function:
196 -- It must return the record structure for the row with all system defaulted
197 -- values converted into its corresponding parameter value for update. When
198 -- we attempt to update a row through the Upd process , certain
199 -- parameters can be defaulted which enables flexibility in the calling of
200 -- the upd process (e.g. only attributes which need to be updated need to be
201 -- specified). For the upd process to determine which attributes
202 -- have NOT been specified we need to check if the parameter has a reserved
203 -- system default value. Therefore, for all parameters which have a
204 -- corresponding reserved system default mechanism specified we need to
205 -- check if a system default is being used. If a system default is being
206 -- used then we convert the defaulted value into its corresponding attribute
207 -- value held in the g_old_rec data structure.
208 --
209 -- Pre Conditions:
210 -- This private function can only be called from the upd process.
211 --
212 -- In Parameters:
213 -- A Pl/Sql record structre.
214 --
215 -- Post Success:
216 -- The record structure will be returned with all system defaulted parameter
217 -- values converted into its current row attribute value.
218 --
219 -- Post Failure:
220 -- No direct error handling is required within this function. Any possible
221 -- errors within this procedure will be a PL/SQL value error due to conversion
222
223 -- of datatypes or data lengths.
224 --
225 -- Developer Implementation Notes:
226 -- None.
227 --
228 -- Access Status:
229 -- Internal Table Handler Use Only.
230 --
231 -- {End Of Comments}
232 -- ----------------------------------------------------------------------------
233 Procedure convert_defs(p_rec in out hr_trv_shd.g_rec_type) is
234 --
235 l_proc varchar2(72) := g_package||'convert_defs';
236 --
237 Begin
238 --
239 hr_utility.set_location('Entering:'||l_proc, 5);
240 --
241 -- We must now examine each argument value in the
242 -- p_rec plsql record structure
243 -- to see if a system default is being used. If a system default
244 -- is being used then we must set to the 'current' argument value.
245 --
246 If (p_rec.transaction_step_id = hr_api.g_number) then
247 p_rec.transaction_step_id :=
248 hr_trv_shd.g_old_rec.transaction_step_id;
249 End If;
250 If (p_rec.datatype = hr_api.g_varchar2) then
251 p_rec.datatype :=
252 hr_trv_shd.g_old_rec.datatype;
253 End If;
254 If (p_rec.name = hr_api.g_varchar2) then
255 p_rec.name :=
256 hr_trv_shd.g_old_rec.name;
257 End If;
258 If (p_rec.varchar2_value = hr_api.g_varchar2) then
259 p_rec.varchar2_value :=
260 hr_trv_shd.g_old_rec.varchar2_value;
261 End If;
262 If (p_rec.number_value = hr_api.g_number) then
263 p_rec.number_value :=
264 hr_trv_shd.g_old_rec.number_value;
265 End If;
266 If (p_rec.date_value = hr_api.g_date) then
267 p_rec.date_value :=
268 hr_trv_shd.g_old_rec.date_value;
269 End If;
270 If (p_rec.original_varchar2_value = hr_api.g_varchar2) then
271 p_rec.original_varchar2_value :=
272 hr_trv_shd.g_old_rec.original_varchar2_value;
273 End If;
274 If (p_rec.original_number_value = hr_api.g_number) then
275 p_rec.original_number_value :=
276 hr_trv_shd.g_old_rec.original_number_value;
277 End If;
278 If (p_rec.original_date_value = hr_api.g_date) then
279 p_rec.original_date_value :=
280 hr_trv_shd.g_old_rec.original_date_value;
281 End If;
282 --
283 hr_utility.set_location(' Leaving:'||l_proc, 10);
284 --
285 End convert_defs;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |---------------------------------< upd >----------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure upd
291 (
292 p_rec in out hr_trv_shd.g_rec_type,
293 p_validate in boolean default false
294 ) is
295 --
296 l_proc varchar2(72) := g_package||'upd';
297 --
298 Begin
299 hr_utility.set_location('Entering:'||l_proc, 5);
300 --
301 -- Determine if the business process is to be validated.
302 --
303 If p_validate then
304 --
305 -- Issue the savepoint.
306 --
307 SAVEPOINT upd_hr_trv;
308 End If;
309 --
310 -- We must lock the row which we need to update.
311 --
312 hr_trv_shd.lck
313 (
314 p_rec.transaction_value_id
315 );
316 --
317 -- 1. During an update system defaults are used to determine if
318 -- arguments have been defaulted or not. We must therefore
319 -- derive the full record structure values to be updated.
320 --
321 -- 2. Call the supporting update validate operations.
322 --
323 convert_defs(p_rec);
324 hr_trv_bus.update_validate(p_rec);
325 --
326 -- Call the supporting pre-update operation
327 --
328 pre_update(p_rec);
329 --
330 -- Update the row.
331 --
332 update_dml(p_rec);
333 --
334 -- Call the supporting post-update operation
335 --
336 post_update(p_rec);
337 --
338 -- If we are validating then raise the Validate_Enabled exception
339 --
340 If p_validate then
341 Raise HR_Api.Validate_Enabled;
342 End If;
343 --
344 hr_utility.set_location(' Leaving:'||l_proc, 10);
345 Exception
346 When HR_Api.Validate_Enabled Then
347 --
348 -- As the Validate_Enabled exception has been raised
349 -- we must rollback to the savepoint
350 --
351 ROLLBACK TO upd_hr_trv;
352 End upd;
353 --
354 -- ----------------------------------------------------------------------------
355 -- |---------------------------------< upd >----------------------------------|
356 -- ----------------------------------------------------------------------------
357 Procedure upd
358 (
359 p_transaction_value_id in number,
360 p_transaction_step_id in number default hr_api.g_number,
361 p_datatype in varchar2 default hr_api.g_varchar2,
362 p_name in varchar2 default hr_api.g_varchar2,
363 p_varchar2_value in varchar2 default hr_api.g_varchar2,
364 p_number_value in number default hr_api.g_number,
365 p_date_value in date default hr_api.g_date,
366 p_original_varchar2_value in varchar2 default hr_api.g_varchar2,
367 p_original_number_value in number default hr_api.g_number,
368 p_original_date_value in date default hr_api.g_date,
369 p_validate in boolean default false
370 ) is
371 --
372 l_rec hr_trv_shd.g_rec_type;
373 l_proc varchar2(72) := g_package||'upd';
374 --
375 Begin
376 hr_utility.set_location('Entering:'||l_proc, 5);
377 --
378 -- Call conversion function to turn arguments into the
379 -- l_rec structure.
380 --
381 l_rec :=
382 hr_trv_shd.convert_args
383 (
384 p_transaction_value_id,
385 p_transaction_step_id,
386 p_datatype,
387 p_name,
388 p_varchar2_value,
389 p_number_value,
390 p_date_value,
391 p_original_varchar2_value,
392 p_original_number_value,
393 p_original_date_value
394 );
395 --
396 -- Having converted the arguments into the
397 -- plsql record structure we call the corresponding record
398 -- business process.
399 --
400 upd(l_rec, p_validate);
401 --
402 --
403 hr_utility.set_location(' Leaving:'||l_proc, 10);
404 End upd;
405 --
406 end hr_trv_upd;