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