1 Package Body pqh_bfs_upd as
2 /* $Header: pqbfsrhi.pkb 115.10 2003/04/02 20:01:46 srajakum ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_bfs_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 -- 3) To update the specified row in the schema using the primary key in
21 -- the predicates.
22 -- 4) To trap any constraint violations that may have occurred.
23 -- 5) 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 pqh_bfs_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 --
60 -- Update the pqh_budget_fund_srcs Row
61 --
62 update pqh_budget_fund_srcs
63 set
64 budget_fund_src_id = p_rec.budget_fund_src_id,
65 budget_element_id = p_rec.budget_element_id,
66 cost_allocation_keyflex_id = p_rec.cost_allocation_keyflex_id,
67 project_id = p_rec.project_id ,
68 award_id = p_rec.award_id ,
69 task_id = p_rec.task_id ,
70 expenditure_type = p_rec.expenditure_type ,
71 organization_id = p_rec.organization_id ,
72 distribution_percentage = p_rec.distribution_percentage,
73 object_version_number = p_rec.object_version_number
74 where budget_fund_src_id = p_rec.budget_fund_src_id;
75 --
76 --
77 hr_utility.set_location(' Leaving:'||l_proc, 10);
78 --
79 Exception
80 When hr_api.check_integrity_violated Then
81 -- A check constraint has been violated
82 pqh_bfs_shd.constraint_error
83 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
84 When hr_api.parent_integrity_violated Then
85 -- Parent integrity has been violated
86 pqh_bfs_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 pqh_bfs_shd.constraint_error
91 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92 When Others Then
93 Raise;
94 End update_dml;
95 --
96 -- ----------------------------------------------------------------------------
97 -- |------------------------------< pre_update >------------------------------|
98 -- ----------------------------------------------------------------------------
99 -- {Start Of Comments}
100 --
101 -- Description:
102 -- This private procedure contains any processing which is required before
103 -- the update dml.
104 --
105 -- Prerequisites:
106 -- This is an internal procedure which is called from the upd procedure.
107 --
108 -- In Parameters:
109 -- A Pl/Sql record structre.
110 --
111 -- Post Success:
112 -- Processing continues.
113 --
114 -- Post Failure:
115 -- If an error has occurred, an error message and exception will be raised
116 -- but not handled.
117 --
118 -- Developer Implementation Notes:
119 -- Any pre-processing required before the update dml is issued should be
120 -- coded within this procedure. It is important to note that any 3rd party
121 -- maintenance should be reviewed before placing in this procedure.
122 --
123 -- Access Status:
124 -- Internal Row Handler Use Only.
125 --
126 -- {End Of Comments}
127 -- ----------------------------------------------------------------------------
128 Procedure pre_update(p_rec in pqh_bfs_shd.g_rec_type) is
129 --
130 l_proc varchar2(72) := g_package||'pre_update';
131 --
132 Begin
133 hr_utility.set_location('Entering:'||l_proc, 5);
134 --
135 hr_utility.set_location(' Leaving:'||l_proc, 10);
136 End pre_update;
137 --
138 -- ----------------------------------------------------------------------------
139 -- |-----------------------------< post_update >------------------------------|
140 -- ----------------------------------------------------------------------------
141 -- {Start Of Comments}
142 --
143 -- Description:
144 -- This private procedure contains any processing which is required after the
145 -- update dml.
146 --
147 -- Prerequisites:
148 -- This is an internal procedure which is called from the upd procedure.
149 --
150 -- In Parameters:
151 -- A Pl/Sql record structre.
152 --
153 -- Post Success:
154 -- Processing continues.
155 --
156 -- Post Failure:
157 -- If an error has occurred, an error message and exception will be raised
158 -- but not handled.
159 --
160 -- Developer Implementation Notes:
161 -- Any post-processing required after the update dml is issued should be
162 -- coded within this procedure. It is important to note that any 3rd party
163 -- maintenance should be reviewed before placing in this procedure.
164 --
165 -- Access Status:
166 -- Internal Row Handler Use Only.
167 --
168 -- {End Of Comments}
169 -- ----------------------------------------------------------------------------
170 Procedure post_update(p_rec in pqh_bfs_shd.g_rec_type) is
171 --
172 l_proc varchar2(72) := g_package||'post_update';
173 --
174 Begin
175 hr_utility.set_location('Entering:'||l_proc, 5);
176 --
177 --
178 -- Start of API User Hook for post_update.
179 --
180 begin
181 --
182 pqh_bfs_rku.after_update
183 (
184 p_budget_fund_src_id =>p_rec.budget_fund_src_id
185 ,p_budget_element_id =>p_rec.budget_element_id
186 ,p_cost_allocation_keyflex_id =>p_rec.cost_allocation_keyflex_id
187 ,p_project_id =>p_rec.project_id
188 ,p_award_id =>p_rec.award_id
189 ,p_task_id =>p_rec.task_id
190 ,p_expenditure_type =>p_rec.expenditure_type
191 ,p_organization_id =>p_rec.organization_id
192 ,p_distribution_percentage =>p_rec.distribution_percentage
193 ,p_object_version_number =>p_rec.object_version_number
194 ,p_budget_element_id_o =>pqh_bfs_shd.g_old_rec.budget_element_id
195 ,p_cost_allocation_keyflex_id_o =>pqh_bfs_shd.g_old_rec.cost_allocation_keyflex_id
196 ,p_project_id_o =>pqh_wfs_shd.g_old_rec.project_id
197 ,p_award_id_o =>pqh_wfs_shd.g_old_rec.award_id
198 ,p_task_id_o =>pqh_wfs_shd.g_old_rec.task_id
199 ,p_expenditure_type_o =>pqh_wfs_shd.g_old_rec.expenditure_type
200 ,p_organization_id_o =>pqh_wfs_shd.g_old_rec.organization_id
201 ,p_distribution_percentage_o =>pqh_bfs_shd.g_old_rec.distribution_percentage
202 ,p_object_version_number_o =>pqh_bfs_shd.g_old_rec.object_version_number
203 );
204 --
205 exception
206 --
207 when hr_api.cannot_find_prog_unit then
208 --
209 hr_api.cannot_find_prog_unit_error
210 (p_module_name => 'pqh_budget_fund_srcs'
211 ,p_hook_type => 'AU');
212 --
213 end;
214 --
215 -- End of API User Hook for post_update.
216 --
217 --
218 hr_utility.set_location(' Leaving:'||l_proc, 10);
219 End post_update;
220 --
221 -- ----------------------------------------------------------------------------
222 -- |-----------------------------< convert_defs >-----------------------------|
223 -- ----------------------------------------------------------------------------
224 -- {Start Of Comments}
225 --
226 -- Description:
227 -- The Convert_Defs procedure has one very important function:
228 -- It must return the record structure for the row with all system defaulted
229 -- values converted into its corresponding parameter value for update. When
230 -- we attempt to update a row through the Upd process , certain
231 -- parameters can be defaulted which enables flexibility in the calling of
232 -- the upd process (e.g. only attributes which need to be updated need to be
233 -- specified). For the upd process to determine which attributes
234 -- have NOT been specified we need to check if the parameter has a reserved
235 -- system default value. Therefore, for all parameters which have a
236 -- corresponding reserved system default mechanism specified we need to
237 -- check if a system default is being used. If a system default is being
238 -- used then we convert the defaulted value into its corresponding attribute
239 -- value held in the g_old_rec data structure.
240 --
241 -- Prerequisites:
242 -- This private function can only be called from the upd process.
243 --
244 -- In Parameters:
245 -- A Pl/Sql record structre.
246 --
247 -- Post Success:
248 -- The record structure will be returned with all system defaulted parameter
249 -- values converted into its current row attribute value.
250 --
251 -- Post Failure:
252 -- No direct error handling is required within this function. Any possible
253 -- errors within this procedure will be a PL/SQL value error due to conversion
254 -- of datatypes or data lengths.
255 --
256 -- Developer Implementation Notes:
257 -- None.
258 --
259 -- Access Status:
260 -- Internal Row Handler Use Only.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure convert_defs(p_rec in out nocopy pqh_bfs_shd.g_rec_type) is
265 --
266 l_proc varchar2(72) := g_package||'convert_defs';
267 --
268 Begin
269 --
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 --
272 -- We must now examine each argument value in the
273 -- p_rec plsql record structure
274 -- to see if a system default is being used. If a system default
275 -- is being used then we must set to the 'current' argument value.
276 --
277 If (p_rec.budget_element_id = hr_api.g_number) then
278 p_rec.budget_element_id :=
279 pqh_bfs_shd.g_old_rec.budget_element_id;
280 End If;
281 If (p_rec.cost_allocation_keyflex_id = hr_api.g_number) then
282 p_rec.cost_allocation_keyflex_id :=
283 pqh_bfs_shd.g_old_rec.cost_allocation_keyflex_id;
284 End If;
285 If (p_rec.distribution_percentage = hr_api.g_number) then
286 p_rec.distribution_percentage :=
287 pqh_bfs_shd.g_old_rec.distribution_percentage;
288 End If;
289 If (p_rec.project_id = hr_api.g_number) then
290 p_rec.project_id :=
291 pqh_bfs_shd.g_old_rec.project_id;
292 End If;
293 If (p_rec.award_id = hr_api.g_number) then
294 p_rec.award_id :=
295 pqh_bfs_shd.g_old_rec.award_id;
296 End If;
297 If (p_rec.task_id = hr_api.g_number) then
298 p_rec.task_id :=
299 pqh_bfs_shd.g_old_rec.task_id;
300 End If;
301 If (p_rec.expenditure_type = hr_api.g_varchar2) then
302 p_rec.expenditure_type :=
303 pqh_bfs_shd.g_old_rec.expenditure_type;
304 End If;
305 If (p_rec.organization_id = hr_api.g_number) then
306 p_rec.organization_id :=
307 pqh_bfs_shd.g_old_rec.organization_id;
308 End If;
309
310 --
311 hr_utility.set_location(' Leaving:'||l_proc, 10);
312 --
313 End convert_defs;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |---------------------------------< upd >----------------------------------|
317 -- ----------------------------------------------------------------------------
318 Procedure upd
319 (
320 p_rec in out nocopy pqh_bfs_shd.g_rec_type
321 ) is
322 --
323 l_proc varchar2(72) := g_package||'upd';
324 --
325 Begin
326 hr_utility.set_location('Entering:'||l_proc, 5);
327 --
328 -- We must lock the row which we need to update.
329 --
330 pqh_bfs_shd.lck
331 (
332 p_rec.budget_fund_src_id,
333 p_rec.object_version_number
334 );
335 --
336 -- 1. During an update system defaults are used to determine if
337 -- arguments have been defaulted or not. We must therefore
338 -- derive the full record structure values to be updated.
339 --
340 -- 2. Call the supporting update validate operations.
341 --
342 convert_defs(p_rec);
343 pqh_bfs_bus.update_validate(p_rec);
344 --
345 -- Call the supporting pre-update operation
346 --
347 pre_update(p_rec);
348 --
349 -- Update the row.
350 --
351 update_dml(p_rec);
352 --
353 -- Call the supporting post-update operation
354 --
355 post_update(p_rec);
356 End upd;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------------< upd >----------------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure upd
362 (
363 p_budget_fund_src_id in number,
364 p_budget_element_id in number default hr_api.g_number,
365 p_cost_allocation_keyflex_id in number default hr_api.g_number,
366 p_project_id in number default hr_api.g_number,
367 p_award_id in number default hr_api.g_number,
368 p_task_id in number default hr_api.g_number,
369 p_expenditure_type in varchar2 default hr_api.g_varchar2,
370 p_organization_id in number default hr_api.g_number,
371 p_distribution_percentage in number default hr_api.g_number,
372 p_object_version_number in out nocopy number
373 ) is
374 --
375 l_rec pqh_bfs_shd.g_rec_type;
376 l_proc varchar2(72) := g_package||'upd';
377 --
378 Begin
379 hr_utility.set_location('Entering:'||l_proc, 5);
380 --
381 -- Call conversion function to turn arguments into the
382 -- l_rec structure.
383 --
384 l_rec :=
385 pqh_bfs_shd.convert_args
386 (
387 p_budget_fund_src_id,
388 p_budget_element_id,
389 p_cost_allocation_keyflex_id,
390 p_project_id,
391 p_award_id,
392 p_task_id,
393 p_expenditure_type,
394 p_organization_id,
395 p_distribution_percentage,
396 p_object_version_number
397 );
398 --
399 -- Having converted the arguments into the
400 -- plsql record structure we call the corresponding record
401 -- business process.
402 --
403 upd(l_rec);
404 p_object_version_number := l_rec.object_version_number;
405 --
406 hr_utility.set_location(' Leaving:'||l_proc, 10);
407 End upd;
408 --
409 end pqh_bfs_upd;