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