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