1 Package Body irc_ido_upd as
2 /* $Header: iridorhi.pkb 120.5.12010000.2 2008/09/26 13:55:20 pvelugul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' irc_ido_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 irc_ido_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 p_rec.object_version_number := p_rec.object_version_number + 1;
65 --
66 irc_ido_shd.g_api_dml := true; -- Set the dml status
67 --
68 --
69 -- Update the irc_documents Row
70 --
71 update irc_documents
72 set
73 document_id = p_rec.document_id
74 ,party_id = p_rec.party_id
75 ,assignment_id = p_rec.assignment_id
76 ,file_name = p_rec.file_name
77 ,mime_type = p_rec.mime_type
78 ,description = p_rec.description
79 ,type = p_rec.type
80 ,object_version_number = p_rec.object_version_number
81 ,end_date = p_rec.end_date
82 ,character_doc = null
83 where document_id = p_rec.document_id;
84 --
85 irc_ido_shd.g_api_dml := false; -- Unset the dml status
86 --
87 --
88 hr_utility.set_location(' Leaving:'||l_proc, 10);
89 --
90 Exception
91 When hr_api.check_integrity_violated Then
92 -- A check constraint has been violated
93 irc_ido_shd.g_api_dml := false; -- Unset the dml status
94 --
95 irc_ido_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When hr_api.parent_integrity_violated Then
98 -- Parent integrity has been violated
99 irc_ido_shd.g_api_dml := false; -- Unset the dml status
100 --
101 irc_ido_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When hr_api.unique_integrity_violated Then
104 -- Unique integrity has been violated
105 irc_ido_shd.g_api_dml := false; -- Unset the dml status
106 --
107 irc_ido_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When Others Then
110 irc_ido_shd.g_api_dml := false; -- Unset the dml status
111 --
112 Raise;
113 End update_dml;
114 --
115 -- ----------------------------------------------------------------------------
116 -- |------------------------------< pre_update >------------------------------|
117 -- ----------------------------------------------------------------------------
118 -- {Start Of Comments}
119 --
120 -- Description:
121 -- This private procedure contains any processing which is required before
122 -- the update dml.
123 --
124 -- Prerequisites:
125 -- This is an internal procedure which is called from the upd procedure.
126 --
127 -- In Parameters:
128 -- A Pl/Sql record structure.
129 --
130 -- Post Success:
131 -- Processing continues.
132 --
133 -- Post Failure:
134 -- If an error has occurred, an error message and exception wil be raised
135 -- but not handled.
136 --
137 -- Developer Implementation Notes:
138 -- Any pre-processing required before the update dml is issued should be
139 -- coded within this procedure. It is important to note that any 3rd party
140 -- maintenance should be reviewed before placing in this procedure.
141 --
142 -- Access Status:
143 -- Internal Row Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_update
148 (p_rec in out nocopy irc_ido_shd.g_rec_type
149 ) is
150 --
151 l_proc varchar2(72) := g_package||'pre_update';
152 --
153 Begin
154 hr_utility.set_location('Entering:'||l_proc, 5);
155 --
156 --
157 -- Derive file_format from MIME type
158 --
159 if (p_rec.mime_type = 'text/html') OR
160 (p_rec.mime_type = 'text/xml') then
161 p_rec.file_format := 'TEXT';
162 else
163 p_rec.file_format := 'BINARY';
164 end if;
165
166 hr_utility.set_location(' Leaving:'||l_proc, 10);
167 End pre_update;
168 --
169 -- ----------------------------------------------------------------------------
170 -- |-----------------------------< post_update >------------------------------|
171 -- ----------------------------------------------------------------------------
172 -- {Start Of Comments}
173 --
174 -- Description:
175 -- This private procedure contains any processing which is required after
176 -- the update dml.
177 --
178 -- Prerequisites:
179 -- This is an internal procedure which is called from the upd procedure.
180 --
181 -- In Parameters:
182 -- A Pl/Sql record structure.
183 --
184 -- Post Success:
185 -- Processing continues.
186 --
187 -- Post Failure:
188 -- If an error has occurred, an error message and exception will be raised
189 -- but not handled.
190 --
191 -- Developer Implementation Notes:
192 -- Any post-processing required after the update dml is issued should be
193 -- coded within this procedure. It is important to note that any 3rd party
194 -- maintenance should be reviewed before placing in this procedure.
195 --
196 -- Access Status:
197 -- Internal Row Handler Use Only.
198 --
199 -- {End Of Comments}
200 -- ----------------------------------------------------------------------------
201 Procedure post_update
202 (p_effective_date in date
203 ,p_rec in irc_ido_shd.g_rec_type
204 ) is
205 --
206 l_proc varchar2(72) := g_package||'post_update';
207 --
208 Begin
209 hr_utility.set_location('Entering:'||l_proc, 5);
210 begin
211 --
212 irc_ido_rku.after_update
213 (p_effective_date => p_effective_date
214 ,p_document_id
215 => p_rec.document_id
216 ,p_party_id
217 => p_rec.party_id
218 ,p_person_id => p_rec.person_id
219 ,p_assignment_id
220 => p_rec.assignment_id
221 ,p_file_name
222 => p_rec.file_name
223 ,p_file_format
224 => p_rec.file_format
225 ,p_mime_type
226 => p_rec.mime_type
227 ,p_description
228 => p_rec.description
229 ,p_type
230 => p_rec.type
231 ,p_object_version_number
232 => p_rec.object_version_number
233 ,p_end_date
234 => p_rec.end_date
235 ,p_party_id_o
236 => irc_ido_shd.g_old_rec.party_id
237 ,p_person_id_o => irc_ido_shd.g_old_rec.person_id
238 ,p_assignment_id_o
239 => irc_ido_shd.g_old_rec.assignment_id
240 ,p_file_name_o
241 => irc_ido_shd.g_old_rec.file_name
242 ,p_file_format_o
243 => irc_ido_shd.g_old_rec.file_format
244 ,p_mime_type_o
245 => irc_ido_shd.g_old_rec.mime_type
246 ,p_description_o
247 => irc_ido_shd.g_old_rec.description
248 ,p_type_o
249 => irc_ido_shd.g_old_rec.type
250 ,p_object_version_number_o
251 => irc_ido_shd.g_old_rec.object_version_number
252 ,p_end_date_o
253 => irc_ido_shd.g_old_rec.end_date
254 );
255 --
256 exception
257 --
258 when hr_api.cannot_find_prog_unit then
259 --
260 hr_api.cannot_find_prog_unit_error
261 (p_module_name => 'IRC_DOCUMENTS'
262 ,p_hook_type => 'AU');
263 --
264 end;
265 --
266 hr_utility.set_location(' Leaving:'||l_proc, 10);
267 End post_update;
268 --
269 -- ----------------------------------------------------------------------------
270 -- |-----------------------------< convert_defs >-----------------------------|
271 -- ----------------------------------------------------------------------------
272 -- {Start Of Comments}
273 --
274 -- Description:
275 -- The Convert_Defs procedure has one very important function:
276 -- It must return the record structure for the row with all system defaulted
277 -- values converted into its corresponding parameter value for update. When
278 -- we attempt to update a row through the Upd process , certain
279 -- parameters can be defaulted which enables flexibility in the calling of
280 -- the upd process (e.g. only attributes which need to be updated need to be
281 -- specified). For the upd process to determine which attributes
282 -- have NOT been specified we need to check if the parameter has a reserved
283 -- system default value. Therefore, for all parameters which have a
284 -- corresponding reserved system default mechanism specified we need to
285 -- check if a system default is being used. If a system default is being
286 -- used then we convert the defaulted value into its corresponding attribute
287 -- value held in the g_old_rec data structure.
288 --
289 -- Prerequisites:
290 -- This private function can only be called from the upd process.
291 --
292 -- In Parameters:
293 -- A Pl/Sql record structure.
294 --
295 -- Post Success:
296 -- The record structure will be returned with all system defaulted parameter
297 -- values converted into its current row attribute value.
298 --
299 -- Post Failure:
300 -- No direct error handling is required within this function. Any possible
301 -- errors within this procedure will be a PL/SQL value error due to
302 -- conversion of datatypes or data lengths.
303 --
304 -- Developer Implementation Notes:
305 -- None.
306 --
307 -- Access Status:
308 -- Internal Row Handler Use Only.
309 --
310 -- {End Of Comments}
311 -- ----------------------------------------------------------------------------
312 Procedure convert_defs
313 (p_rec in out nocopy irc_ido_shd.g_rec_type
314 ) is
315 --
316 Begin
317 --
318 -- We must now examine each argument value in the
319 -- p_rec plsql record structure
320 -- to see if a system default is being used. If a system default
321 -- is being used then we must set to the 'current' argument value.
322 --
323 If (p_rec.party_id = hr_api.g_number) then
324 p_rec.party_id :=
325 irc_ido_shd.g_old_rec.party_id;
326 End If;
327 If (p_rec.person_id = hr_api.g_number) then
328 p_rec.person_id := irc_ido_shd.g_old_rec.person_id;
329 End If;
330 If (p_rec.assignment_id = hr_api.g_number) then
331 p_rec.assignment_id :=
332 irc_ido_shd.g_old_rec.assignment_id;
333 End If;
334 If (p_rec.file_name = hr_api.g_varchar2) then
335 p_rec.file_name :=
336 irc_ido_shd.g_old_rec.file_name;
337 End If;
338 If (p_rec.file_format = hr_api.g_varchar2) then
339 p_rec.file_format :=
340 irc_ido_shd.g_old_rec.file_format;
341 End If;
342 If (p_rec.mime_type = hr_api.g_varchar2) then
343 p_rec.mime_type :=
344 irc_ido_shd.g_old_rec.mime_type;
345 End If;
346 If (p_rec.description = hr_api.g_varchar2) then
347 p_rec.description :=
348 irc_ido_shd.g_old_rec.description;
349 End If;
350 If (p_rec.type = hr_api.g_varchar2) then
351 p_rec.type :=
352 irc_ido_shd.g_old_rec.type;
353 End If;
354 If (p_rec.end_date = hr_api.g_date) then
355 p_rec.end_date :=
356 irc_ido_shd.g_old_rec.end_date;
357 End If;
358 --
359 End convert_defs;
360 --
361 -- ----------------------------------------------------------------------------
362 -- |---------------------------------< upd >----------------------------------|
363 -- ----------------------------------------------------------------------------
364 Procedure upd
365 (p_effective_date in date
366 ,p_rec in out nocopy irc_ido_shd.g_rec_type
367 ) is
368 --
369 l_proc varchar2(72) := g_package||'upd';
370 --
371 Begin
372 hr_utility.set_location('Entering:'||l_proc, 5);
373 --
374 -- We must lock the row which we need to update.
375 --
376 irc_ido_shd.lck
377 (p_rec.document_id
378 ,p_rec.object_version_number
379 );
380 --
381 -- 1. During an update system defaults are used to determine if
382 -- arguments have been defaulted or not. We must therefore
383 -- derive the full record structure values to be updated.
384 --
385 -- 2. Call the supporting update validate operations.
386 --
387 convert_defs(p_rec);
388 irc_ido_bus.update_validate
389 (p_effective_date
390 ,p_rec
391 );
392 --
393 -- Call the supporting pre-update operation
394 --
395 irc_ido_upd.pre_update(p_rec);
396 --
397 if p_rec.party_id is null then
398 p_rec.party_id := irc_ido_shd.g_old_rec.party_id;
399 end if;
400 if p_rec.person_id is null then
401 p_rec.person_id := irc_ido_shd.g_old_rec.person_id;
402 end if;
403 if p_rec.assignment_id is null then
404 p_rec.assignment_id := irc_ido_shd.g_old_rec.assignment_id;
405 end if;
406
407 --
408 -- Update the row.
409 --
410 irc_ido_upd.update_dml(p_rec);
411 --
412 -- Call the supporting post-update operation
413 --
414 irc_ido_upd.post_update
415 (p_effective_date
416 ,p_rec
417 );
418 End upd;
419 --
420 -- ----------------------------------------------------------------------------
421 -- |---------------------------------< upd >----------------------------------|
422 -- ----------------------------------------------------------------------------
423 Procedure upd
424 (p_effective_date in date
425 ,p_document_id in number
426 ,p_object_version_number in out nocopy number
427 ,p_mime_type in varchar2 default hr_api.g_varchar2
428 ,p_type in varchar2 default hr_api.g_varchar2
429 ,p_file_name in varchar2 default hr_api.g_varchar2
430 ,p_description in varchar2 default hr_api.g_varchar2
431 ,p_end_date in date default hr_api.g_date
432 ) is
433 --
434 l_rec irc_ido_shd.g_rec_type;
435 l_proc varchar2(72) := g_package||'upd';
436 --
437 Begin
438 hr_utility.set_location('Entering:'||l_proc, 5);
439 --
440 -- Call conversion function to turn arguments into the
441 -- l_rec structure.
442 --
443 l_rec :=
444 irc_ido_shd.convert_args
445 (p_document_id
446 ,null
447 ,null
448 ,null
449 ,empty_clob()
450 ,p_file_name
451 ,p_mime_type
452 ,p_description
453 ,p_type
454 ,empty_clob()
455 ,p_object_version_number
456 ,p_end_date
457 );
458 --
459 -- Having converted the arguments into the
460 -- plsql record structure we call the corresponding record
461 -- business process.
462 --
463 irc_ido_upd.upd
464 (p_effective_date
465 ,l_rec
466 );
467 p_object_version_number := l_rec.object_version_number;
468 --
469 hr_utility.set_location(' Leaving:'||l_proc, 10);
470 End upd;
471 --
472 end irc_ido_upd;