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