1 Package Body ben_ola_upd as
2 /* $Header: beolarhi.pkb 120.0 2005/05/28 09:51:12 appldev noship $ */
3 --
7 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
8 g_package varchar2(33) := ' ben_ola_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 ben_ola_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 -- Increment the object version
62 --
63 p_rec.object_version_number := p_rec.object_version_number + 1;
64 --
65 ben_ola_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_csr_activities Row
68 --
69 update ben_csr_activities
70 set
71 csr_activities_id = p_rec.csr_activities_id,
72 ordr_num = p_rec.ordr_num,
73 function_name = p_rec.function_name,
74 user_function_name = p_rec.user_function_name,
75 function_type = p_rec.function_type,
76 business_group_id = p_rec.business_group_id,
77 object_version_number = p_rec.object_version_number,
78 start_date = p_rec.start_date,
79 end_date = p_rec.end_date
80 where csr_activities_id = p_rec.csr_activities_id;
81 --
82 ben_ola_shd.g_api_dml := false; -- Unset the api dml status
83 --
84 hr_utility.set_location(' Leaving:'||l_proc, 10);
85 --
86 Exception
87 When hr_api.check_integrity_violated Then
88 -- A check constraint has been violated
89 ben_ola_shd.g_api_dml := false; -- Unset the api dml status
90 ben_ola_shd.constraint_error
91 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92 When hr_api.parent_integrity_violated Then
93 -- Parent integrity has been violated
94 ben_ola_shd.g_api_dml := false; -- Unset the api dml status
95 ben_ola_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When hr_api.unique_integrity_violated Then
98 -- Unique integrity has been violated
99 ben_ola_shd.g_api_dml := false; -- Unset the api dml status
100 ben_ola_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When Others Then
103 ben_ola_shd.g_api_dml := false; -- Unset the api dml status
104 Raise;
105 End update_dml;
106 --
107 -- ----------------------------------------------------------------------------
108 -- |------------------------------< pre_update >------------------------------|
109 -- ----------------------------------------------------------------------------
110 -- {Start Of Comments}
111 --
112 -- Description:
113 -- This private procedure contains any processing which is required before
114 -- the update dml.
115 --
116 -- Prerequisites:
117 -- This is an internal procedure which is called from the upd procedure.
118 --
119 -- In Parameters:
120 -- A Pl/Sql record structre.
121 --
122 -- Post Success:
123 -- Processing continues.
124 --
125 -- Post Failure:
126 -- If an error has occurred, an error message and exception will be raised
127 -- but not handled.
128 --
129 -- Developer Implementation Notes:
130 -- Any pre-processing required before the update dml is issued should be
131 -- coded within this procedure. It is important to note that any 3rd party
132 -- maintenance should be reviewed before placing in this procedure.
133 --
134 -- Access Status:
135 -- Internal Row Handler Use Only.
136 --
137 -- {End Of Comments}
141 l_proc varchar2(72) := g_package||'pre_update';
138 -- ----------------------------------------------------------------------------
139 Procedure pre_update(p_rec in ben_ola_shd.g_rec_type) is
140 --
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 the
156 -- 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 structre.
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(p_rec in ben_ola_shd.g_rec_type) is
182 --
183 l_proc varchar2(72) := g_package||'post_update';
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 --
188 --
189 -- Start of API User Hook for post_update.
190 --
191 begin
192 --
193 ben_ola_rku.after_update
194 (
195 p_csr_activities_id =>p_rec.csr_activities_id
196 ,p_ordr_num =>p_rec.ordr_num
197 ,p_function_name =>p_rec.function_name
198 ,p_user_function_name =>p_rec.user_function_name
199 ,p_function_type =>p_rec.function_type
200 ,p_business_group_id =>p_rec.business_group_id
201 ,p_object_version_number =>p_rec.object_version_number
202 ,p_start_date =>p_rec.start_date
203 ,p_end_date =>p_rec.end_date
204 ,p_ordr_num_o =>ben_ola_shd.g_old_rec.ordr_num
205 ,p_function_name_o =>ben_ola_shd.g_old_rec.function_name
206 ,p_user_function_name_o =>ben_ola_shd.g_old_rec.user_function_name
207 ,p_function_type_o =>ben_ola_shd.g_old_rec.function_type
208 ,p_business_group_id_o =>ben_ola_shd.g_old_rec.business_group_id
209 ,p_object_version_number_o =>ben_ola_shd.g_old_rec.object_version_number
210 ,p_start_date_o =>ben_ola_shd.g_old_rec.start_date
211 ,p_end_date_o =>ben_ola_shd.g_old_rec.end_date
212 );
213 --
214 exception
215 --
216 when hr_api.cannot_find_prog_unit then
217 --
218 hr_api.cannot_find_prog_unit_error
219 (p_module_name => 'ben_csr_activities'
220 ,p_hook_type => 'AU');
221 --
222 end;
223 --
224 -- End of API User Hook for post_update.
225 --
226 --
227 hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End post_update;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< convert_defs >-----------------------------|
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 -- The Convert_Defs procedure has one very important function:
237 -- It must return the record structure for the row with all system defaulted
238 -- values converted into its corresponding parameter value for update. When
239 -- we attempt to update a row through the Upd process , certain
240 -- parameters can be defaulted which enables flexibility in the calling of
241 -- the upd process (e.g. only attributes which need to be updated need to be
242 -- specified). For the upd process to determine which attributes
243 -- have NOT been specified we need to check if the parameter has a reserved
244 -- system default value. Therefore, for all parameters which have a
245 -- corresponding reserved system default mechanism specified we need to
246 -- check if a system default is being used. If a system default is being
247 -- used then we convert the defaulted value into its corresponding attribute
248 -- value held in the g_old_rec data structure.
249 --
250 -- Prerequisites:
251 -- This private function can only be called from the upd process.
252 --
253 -- In Parameters:
254 -- A Pl/Sql record structre.
255 --
256 -- Post Success:
257 -- The record structure will be returned with all system defaulted parameter
258 -- values converted into its current row attribute value.
259 --
260 -- Post Failure:
261 -- No direct error handling is required within this function. Any possible
262 -- errors within this procedure will be a PL/SQL value error due to conversion
263 -- of datatypes or data lengths.
264 --
265 -- Developer Implementation Notes:
266 -- None.
267 --
268 -- Access Status:
269 -- Internal Row Handler Use Only.
270 --
271 -- {End Of Comments}
272 -- ----------------------------------------------------------------------------
273 Procedure convert_defs(p_rec in out nocopy ben_ola_shd.g_rec_type) is
274 --
278 --
275 l_proc varchar2(72) := g_package||'convert_defs';
276 --
277 Begin
279 hr_utility.set_location('Entering:'||l_proc, 5);
280 --
281 -- We must now examine each argument value in the
282 -- p_rec plsql record structure
283 -- to see if a system default is being used. If a system default
284 -- is being used then we must set to the 'current' argument value.
285 --
286 If (p_rec.ordr_num = hr_api.g_number) then
287 p_rec.ordr_num :=
288 ben_ola_shd.g_old_rec.ordr_num;
289 End If;
290 If (p_rec.function_name = hr_api.g_varchar2) then
291 p_rec.function_name :=
292 ben_ola_shd.g_old_rec.function_name;
293 End If;
294 If (p_rec.user_function_name = hr_api.g_varchar2) then
295 p_rec.user_function_name :=
296 ben_ola_shd.g_old_rec.user_function_name;
297 End If;
298 If (p_rec.function_type = hr_api.g_varchar2) then
299 p_rec.function_type :=
300 ben_ola_shd.g_old_rec.function_type;
301 End If;
302 If (p_rec.business_group_id = hr_api.g_number) then
303 p_rec.business_group_id :=
304 ben_ola_shd.g_old_rec.business_group_id;
305 End If;
306 If (p_rec.start_date = hr_api.g_date) then
307 p_rec.start_date :=
308 ben_ola_shd.g_old_rec.start_date;
309 End If;
310 If (p_rec.end_date = hr_api.g_date) then
311 p_rec.end_date :=
312 ben_ola_shd.g_old_rec.end_date;
313 End If;
314 --
315 hr_utility.set_location(' Leaving:'||l_proc, 10);
316 --
317 End convert_defs;
318 --
319 -- ----------------------------------------------------------------------------
320 -- |---------------------------------< upd >----------------------------------|
321 -- ----------------------------------------------------------------------------
322 Procedure upd
323 (
324 p_rec in out nocopy ben_ola_shd.g_rec_type
325 ) is
326 --
327 l_proc varchar2(72) := g_package||'upd';
328 --
329 Begin
330 hr_utility.set_location('Entering:'||l_proc, 5);
331 --
332 -- We must lock the row which we need to update.
333 --
334 ben_ola_shd.lck
335 (
336 p_rec.csr_activities_id,
337 p_rec.object_version_number
338 );
339 --
340 -- 1. During an update system defaults are used to determine if
341 -- arguments have been defaulted or not. We must therefore
342 -- derive the full record structure values to be updated.
343 --
344 -- 2. Call the supporting update validate operations.
345 --
346 convert_defs(p_rec);
347 ben_ola_bus.update_validate(p_rec);
348 --
349 -- Call the supporting pre-update operation
350 --
351 pre_update(p_rec);
352 --
353 -- Update the row.
354 --
355 update_dml(p_rec);
356 --
357 -- Call the supporting post-update operation
358 --
359 post_update(p_rec);
360 End upd;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |---------------------------------< upd >----------------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure upd
366 (
367 p_csr_activities_id in number,
368 p_ordr_num in number default hr_api.g_number,
369 p_function_name in varchar2 default hr_api.g_varchar2,
370 p_user_function_name in varchar2 default hr_api.g_varchar2,
371 p_function_type in varchar2 default hr_api.g_varchar2,
372 p_business_group_id in number default hr_api.g_number,
373 p_object_version_number in out nocopy number,
374 p_start_date in date default hr_api.g_date,
375 p_end_date in date default hr_api.g_date
376 ) is
377 --
378 l_rec ben_ola_shd.g_rec_type;
379 l_proc varchar2(72) := g_package||'upd';
380 --
381 Begin
382 hr_utility.set_location('Entering:'||l_proc, 5);
383 --
384 -- Call conversion function to turn arguments into the
385 -- l_rec structure.
386 --
387 l_rec :=
388 ben_ola_shd.convert_args
389 (
390 p_csr_activities_id,
391 p_ordr_num,
392 p_function_name,
393 p_user_function_name,
394 p_function_type,
395 p_business_group_id,
396 p_object_version_number,
397 p_start_date,
398 p_end_date
399 );
400 --
401 -- Having converted the arguments into the
402 -- plsql record structure we call the corresponding record
403 -- business process.
404 --
405 upd(l_rec);
406 p_object_version_number := l_rec.object_version_number;
407 --
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 End upd;
410 --
411 end ben_ola_upd;