1 Package Body pqh_rtl_upd as
2 /* $Header: pqrtlrhi.pkb 115.7 2003/01/26 02:01:52 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rtl_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 update the specified row in the schema using the primary key in
21 -- the predicates.
22 -- 3) To trap any constraint violations that may have occurred.
23 -- 4) 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_rtl_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 --
56 --
57 -- Update the pqh_rule_sets_tl Row
58 --
59 update pqh_rule_sets_tl
60 set
61 rule_set_id = p_rec.rule_set_id,
62 rule_set_name = p_rec.rule_set_name,
63 description = p_rec.description,
64 language = p_rec.language,
65 source_lang = p_rec.source_lang
66 where rule_set_id = p_rec.rule_set_id
67 and language = p_rec.language;
68 --
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_rtl_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_rtl_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_rtl_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_rtl_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(p_rec in pqh_rtl_shd.g_rec_type) is
164 --
165 l_proc varchar2(72) := g_package||'post_update';
166 --
167 Begin
168 hr_utility.set_location('Entering:'||l_proc, 5);
169 --
170 --
171 -- Start of API User Hook for post_update.
172 --
173 begin
174 --
175 pqh_rtl_rku.after_update
176 (
177 p_rule_set_id =>p_rec.rule_set_id
178 ,p_rule_set_name =>p_rec.rule_set_name
179 ,p_description =>p_rec.description
180 ,p_language =>p_rec.language
181 ,p_source_lang =>p_rec.source_lang
182 ,p_rule_set_name_o =>pqh_rtl_shd.g_old_rec.rule_set_name
183 ,p_description_o =>pqh_rtl_shd.g_old_rec.description
184 ,p_language_o =>pqh_rtl_shd.g_old_rec.language
185 ,p_source_lang_o =>pqh_rtl_shd.g_old_rec.source_lang
186 );
187 --
188 exception
189 --
190 when hr_api.cannot_find_prog_unit then
191 --
192 hr_api.cannot_find_prog_unit_error
193 (p_module_name => 'pqh_rule_sets_tl'
194 ,p_hook_type => 'AU');
195 --
196 end;
197 --
198 -- End of API User Hook for post_update.
199 --
200 --
201 hr_utility.set_location(' Leaving:'||l_proc, 10);
202 End post_update;
203 --
204 -- ----------------------------------------------------------------------------
205 -- |-----------------------------< convert_defs >-----------------------------|
206 -- ----------------------------------------------------------------------------
207 -- {Start Of Comments}
208 --
209 -- Description:
210 -- The Convert_Defs procedure has one very important function:
211 -- It must return the record structure for the row with all system defaulted
212 -- values converted into its corresponding parameter value for update. When
213 -- we attempt to update a row through the Upd process , certain
214 -- parameters can be defaulted which enables flexibility in the calling of
215 -- the upd process (e.g. only attributes which need to be updated need to be
216 -- specified). For the upd process to determine which attributes
217 -- have NOT been specified we need to check if the parameter has a reserved
218 -- system default value. Therefore, for all parameters which have a
219 -- corresponding reserved system default mechanism specified we need to
220 -- check if a system default is being used. If a system default is being
221 -- used then we convert the defaulted value into its corresponding attribute
222 -- value held in the g_old_rec data structure.
223 --
224 -- Prerequisites:
225 -- This private function can only be called from the upd process.
226 --
227 -- In Parameters:
228 -- A Pl/Sql record structre.
229 --
230 -- Post Success:
231 -- The record structure will be returned with all system defaulted parameter
232 -- values converted into its current row attribute value.
233 --
234 -- Post Failure:
235 -- No direct error handling is required within this function. Any possible
236 -- errors within this procedure will be a PL/SQL value error due to conversion
237 -- of datatypes or data lengths.
238 --
239 -- Developer Implementation Notes:
240 -- None.
241 --
242 -- Access Status:
243 -- Internal Row Handler Use Only.
244 --
245 -- {End Of Comments}
246 -- ----------------------------------------------------------------------------
247 Procedure convert_defs(p_rec in out nocopy pqh_rtl_shd.g_rec_type) is
248 --
249 l_proc varchar2(72) := g_package||'convert_defs';
250 --
251 Begin
252 --
253 hr_utility.set_location('Entering:'||l_proc, 5);
254 --
255 -- We must now examine each argument value in the
256 -- p_rec plsql record structure
257 -- to see if a system default is being used. If a system default
258 -- is being used then we must set to the 'current' argument value.
259 --
260 If (p_rec.rule_set_name = hr_api.g_varchar2) then
261 p_rec.rule_set_name :=
262 pqh_rtl_shd.g_old_rec.rule_set_name;
263 End If;
264 If (p_rec.description = hr_api.g_varchar2) then
265 p_rec.description :=
266 pqh_rtl_shd.g_old_rec.description;
267 End If;
268 If (p_rec.source_lang = hr_api.g_varchar2) then
269 p_rec.source_lang :=
270 pqh_rtl_shd.g_old_rec.source_lang;
271 End If;
272 --
273 hr_utility.set_location(' Leaving:'||l_proc, 10);
274 --
275 End convert_defs;
276 --
277 -- ----------------------------------------------------------------------------
278 -- |---------------------------------< upd >----------------------------------|
279 -- ----------------------------------------------------------------------------
280 Procedure upd
281 (
282 p_rec in out nocopy pqh_rtl_shd.g_rec_type
283 ) is
284 --
285 l_proc varchar2(72) := g_package||'upd';
286 --
287 Begin
288 hr_utility.set_location('Entering:'||l_proc, 5);
289 --
290 -- We must lock the row which we need to update.
291 --
292 pqh_rtl_shd.lck
293 (
294 p_rec.rule_set_id,
295 p_rec.language
296 );
297 --
298 -- 1. During an update system defaults are used to determine if
299 -- arguments have been defaulted or not. We must therefore
300 -- derive the full record structure values to be updated.
301 --
302 -- 2. Call the supporting update validate operations.
303 --
304 convert_defs(p_rec);
305 pqh_rtl_bus.update_validate(p_rec);
306 --
307 -- Call the supporting pre-update operation
308 --
309 pre_update(p_rec);
310 --
311 -- Update the row.
312 --
313 update_dml(p_rec);
314 --
315 -- Call the supporting post-update operation
316 --
317 post_update(p_rec);
318 End upd;
319 --
320 -- ----------------------------------------------------------------------------
321 -- |---------------------------------< upd >----------------------------------|
322 -- ----------------------------------------------------------------------------
323 Procedure upd
324 (
325 p_rule_set_id in number,
326 p_rule_set_name in varchar2 default hr_api.g_varchar2,
327 p_description in varchar2 default hr_api.g_varchar2,
328 p_language in varchar2,
329 p_source_lang in varchar2 default hr_api.g_varchar2
330 ) is
331 --
332 l_rec pqh_rtl_shd.g_rec_type;
333 l_proc varchar2(72) := g_package||'upd';
334 --
335 Begin
336 hr_utility.set_location('Entering:'||l_proc, 5);
337 --
338 -- Call conversion function to turn arguments into the
339 -- l_rec structure.
340 --
341 l_rec :=
342 pqh_rtl_shd.convert_args
343 (
344 p_rule_set_id,
345 p_rule_set_name,
346 p_description,
347 p_language,
348 p_source_lang
349 );
350 --
351 -- Having converted the arguments into the
352 -- plsql record structure we call the corresponding record
353 -- business process.
354 --
355 upd(l_rec);
356 --
357 --
358 hr_utility.set_location(' Leaving:'||l_proc, 10);
359 End upd;
360 --
361 -- ----------------------------------------------------------------------------
362 -- |------------------------------< upd_tl >----------------------------------|
363 -- ----------------------------------------------------------------------------
364 --
365 procedure upd_tl ( p_language_code in varchar2,
366 p_rule_set_id in number,
367 p_rule_set_name in varchar2,
368 p_description in varchar2
369 ) is
370 --
371 cursor csr_upd_langs is
372 select rtl.language
373 from pqh_rule_sets_tl rtl
374 where rtl.rule_set_id = p_rule_set_id
375 AND p_language_code in (rtl.language,rtl.source_lang);
376 --
377 l_proc varchar2(72) := g_package||'upd_tl';
378 --
379 begin
380 --
381 hr_utility.set_location(' Entering:'||l_proc, 10);
382 --
383 for l_lang in csr_upd_langs loop
384 --
385 --
386 upd
387 (p_rule_set_id => p_rule_set_id,
388 p_rule_set_name => p_rule_set_name,
389 p_description => p_description,
390 p_language => l_lang.language,
391 p_source_lang => p_language_code) ;
392 --
393 --
394 end loop;
395 --
396 hr_utility.set_location(' Leaving:'||l_proc, 20);
397 --
398 end upd_tl;
399 --
400 -- ----------- Translate Row -------------------------------------------
401 --
402 Procedure translate_row (
403 p_short_name in varchar2,
404 p_rule_set_name in varchar2 ,
405 p_description in varchar2,
406 p_owner in varchar2
407 ) is
408
409 --
410 l_rule_set_id pqh_rule_sets.rule_set_id%type := 0;
411 --
412 --
413 l_created_by pqh_rule_sets.created_by%TYPE;
414 l_last_updated_by pqh_rule_sets.last_updated_by%TYPE;
415 l_creation_date pqh_rule_sets.creation_date%TYPE;
416 l_last_update_date pqh_rule_sets.last_update_date%TYPE;
417 l_last_update_login pqh_rule_sets.last_update_login%TYPE;
418 --
419 --
420 Cursor c1 is select rule_set_id
421 from pqh_rule_sets
422 where short_name = p_short_name ;
423 --
424 --
425 BEGIN
426 --
427 --
428 Open c1;
429 Fetch c1 into l_rule_set_id;
430 Close c1;
431 --
432 --
433 -- populate WHO columns
434 --
435 if p_owner = 'SEED' then
436 l_created_by := 1;
437 l_last_updated_by := -1;
438 else
439 l_created_by := 0;
440 l_last_updated_by := 0;
441 end if;
442
443 l_creation_date := sysdate;
444 l_last_update_date := sysdate;
445 l_last_update_login := 0;
446
447 --
448 --
449 update pqh_rule_sets_tl
450 set rule_set_name = p_rule_set_name ,
451 description = p_description,
452 last_updated_by = l_last_updated_by,
453 last_update_date = l_last_update_date,
454 last_update_login = l_last_update_login,
455 source_lang = USERENV('LANG')
456 where USERENV('LANG') in (language,source_lang)
457 and rule_set_id = l_rule_set_id ;
458 --
459 end translate_row;
460 --
461 --
462 end pqh_rtl_upd;