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