DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_DOA_UPD

Source


1 Package Body pqh_doa_upd as
2 /* $Header: pqdoarhi.pkb 115.0 2003/01/06 09:20:29 svorugan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_doa_upd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_update_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the execution of dml from the datetrack mode
17 --   of CORRECTION only. It is important to note that the object version
18 --   number is only increment by 1 because the datetrack correction is
19 --   soley for one datetracked row.
20 --   This procedure controls the actual dml update logic. The functions of
21 --   this procedure are as follows:
22 --   1) Get the next object_version_number.
23 --   2) To set and unset the g_api_dml status as required (as we are about to
24 --      perform dml).
25 --   3) To update the specified row in the schema using the primary key in
26 --      the predicates.
27 --   4) To trap any constraint violations that may have occurred.
28 --   5) To raise any other errors.
29 --
30 -- Prerequisites:
31 --   This is an internal private procedure which must be called from the
32 --   update_dml procedure.
33 --
34 -- In Parameters:
35 --   A Pl/Sql record structure.
36 --
37 -- Post Success:
38 --   The specified row will be updated in the schema.
39 --
40 -- Post Failure:
41 --   On the update dml failure it is important to note that we always reset the
42 --   g_api_dml status to false.
43 --   If a check or unique integrity constraint violation is raised the
44 --   constraint_error procedure will be called.
45 --   If any other error is reported, the error will be raised after the
46 --   g_api_dml status is reset.
47 --
48 -- Developer Implementation Notes:
49 --   The update 'set' arguments list should be modified if any of your
50 --   attributes are not updateable.
51 --
52 -- Access Status:
53 --   Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_update_dml
58   (p_rec                   in out NOCOPY pqh_doa_shd.g_rec_type
59   ,p_effective_date        in date
60   ,p_datetrack_mode        in varchar2
61   ,p_validation_start_date in date
62   ,p_validation_end_date   in date
63   ) is
64 --
65   l_proc        varchar2(72) := g_package||'dt_update_dml';
66 --
67 Begin
68   hr_utility.set_location('Entering:'||l_proc, 5);
69   --
70   If (p_datetrack_mode = hr_api.g_correction) then
71     hr_utility.set_location(l_proc, 10);
72     --
73     -- Because we are updating a row we must get the next object
74     -- version number.
75     --
76     p_rec.object_version_number :=
77       dt_api.get_object_version_number
78         (p_base_table_name => 'pqh_document_attributes_f'
79         ,p_base_key_column => 'document_attribute_id'
80         ,p_base_key_value  => p_rec.document_attribute_id
81         );
82     --
83     pqh_doa_shd.g_api_dml := true;  -- Set the api dml status
84     --
85     -- Update the pqh_document_attributes_f Row
86     --
87     update  pqh_document_attributes_f
88     set
89      document_attribute_id                = p_rec.document_attribute_id
90     ,document_id                          = p_rec.document_id
91     ,attribute_id                         = p_rec.attribute_id
92     ,tag_name                             = p_rec.tag_name
93     ,object_version_number                = p_rec.object_version_number
94     where   document_attribute_id = p_rec.document_attribute_id
95     and     effective_start_date = p_validation_start_date
96     and     effective_end_date   = p_validation_end_date;
97     --
98     pqh_doa_shd.g_api_dml := false;   -- Unset the api dml status
99     --
100     -- Set the effective start and end dates
101     --
102     p_rec.effective_start_date := p_validation_start_date;
103     p_rec.effective_end_date   := p_validation_end_date;
104   End If;
105 --
106 hr_utility.set_location(' Leaving:'||l_proc, 15);
107 Exception
108   When hr_api.check_integrity_violated Then
109     -- A check constraint has been violated
110     pqh_doa_shd.g_api_dml := false;   -- Unset the api dml status
111     pqh_doa_shd.constraint_error
112       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113   When hr_api.unique_integrity_violated Then
114     -- Unique integrity has been violated
115     pqh_doa_shd.g_api_dml := false;   -- Unset the api dml status
116     pqh_doa_shd.constraint_error
117       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118   When Others Then
119     pqh_doa_shd.g_api_dml := false;   -- Unset the api dml status
120     Raise;
121 End dt_update_dml;
122 --
123 -- ----------------------------------------------------------------------------
124 -- |------------------------------< update_dml >------------------------------|
125 -- ----------------------------------------------------------------------------
126 -- {Start Of Comments}
127 --
128 -- Description:
129 --   This procedure calls the dt_update_dml control logic which handles
130 --   the actual datetrack dml.
131 --
132 -- Prerequisites:
133 --   This is an internal private procedure which must be called from the upd
134 --   procedure.
135 --
136 -- In Parameters:
137 --   A Pl/Sql record structre.
138 --
139 -- Post Success:
140 --   Processing contines.
141 --
142 -- Post Failure:
143 --   No specific error handling is required within this procedure.
144 --
145 -- Developer Implementation Notes:
146 --   The update 'set' arguments list should be modified if any of your
147 --   attributes are not updateable.
148 --
149 -- Access Status:
150 --   Internal Row Handler Use Only.
151 --
152 -- {End Of Comments}
153 -- ----------------------------------------------------------------------------
154 Procedure update_dml
155   (p_rec                      in out NOCOPY pqh_doa_shd.g_rec_type
156   ,p_effective_date           in date
157   ,p_datetrack_mode           in varchar2
158   ,p_validation_start_date    in date
159   ,p_validation_end_date      in date
160   ) is
161 --
162   l_proc        varchar2(72) := g_package||'update_dml';
163 --
164 Begin
165   hr_utility.set_location('Entering:'||l_proc, 5);
166   --
167   pqh_doa_upd.dt_update_dml
168     (p_rec                   => p_rec
169     ,p_effective_date        => p_effective_date
170     ,p_datetrack_mode        => p_datetrack_mode
171     ,p_validation_start_date => p_validation_start_date
172     ,p_validation_end_date   => p_validation_end_date
173     );
174   --
175   hr_utility.set_location(' Leaving:'||l_proc, 10);
176 End update_dml;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |----------------------------< dt_pre_update >-----------------------------|
180 -- ----------------------------------------------------------------------------
181 -- {Start Of Comments}
182 --
183 -- Description:
184 --   The dt_pre_update procedure controls the execution
185 --   of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
186 --   and UPDATE_CHANGE_INSERT only. The execution required is as
187 --   follows:
188 --
189 --   1) Providing the datetrack update mode is not 'CORRECTION'
190 --      then set the effective end date of the current row (this
191 --      will be the validation_start_date - 1).
192 --   2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
193 --      corresponding delete_dml process to delete any future rows
194 --      where the effective_start_date is greater than or equal to
195 --      the validation_start_date.
196 --   3) Call the insert_dml process to insert the new updated row
197 --      details.
198 --
199 -- Prerequisites:
200 --   This is an internal procedure which is called from the
201 --   pre_update procedure.
202 --
203 -- In Parameters:
204 --
205 -- Post Success:
206 --   Processing continues.
207 --
208 -- Post Failure:
209 --   If an error has occurred, an error message and exception will be raised
210 --   but not handled.
211 --
212 -- Developer Implementation Notes:
213 --   This is an internal procedure which is required by Datetrack. Don't
214 --   remove or modify.
215 --
216 -- Access Status:
217 --   Internal Row Handler Use Only.
218 --
219 -- {End Of Comments}
220 -- ----------------------------------------------------------------------------
221 Procedure dt_pre_update
222   (p_rec                     in out NOCOPY     pqh_doa_shd.g_rec_type
223   ,p_effective_date          in date
224   ,p_datetrack_mode          in varchar2
225   ,p_validation_start_date   in date
226   ,p_validation_end_date     in date
227   ) is
228 --
229   l_proc                 varchar2(72) := g_package||'dt_pre_update';
230   l_dummy_version_number number;
231 --
232 Begin
233   hr_utility.set_location('Entering:'||l_proc, 5);
234   If (p_datetrack_mode <> hr_api.g_correction) then
235     --
236     -- Update the current effective end date
237     --
238     pqh_doa_shd.upd_effective_end_date
239       (p_effective_date         => p_effective_date
240       ,p_base_key_value         => p_rec.document_attribute_id
241       ,p_new_effective_end_date => (p_validation_start_date - 1)
242       ,p_validation_start_date  => p_validation_start_date
243       ,p_validation_end_date    => p_validation_end_date
244       ,p_object_version_number  => l_dummy_version_number
245       );
246     --
247     If (p_datetrack_mode = hr_api.g_update_override) then
248       --
249       -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
250       -- delete any future rows
251       --
252       pqh_doa_del.delete_dml
253         (p_rec                   => p_rec
254         ,p_effective_date        => p_effective_date
255         ,p_datetrack_mode        => p_datetrack_mode
256         ,p_validation_start_date => p_validation_start_date
257         ,p_validation_end_date   => p_validation_end_date
258         );
259     End If;
260     --
261     -- We must now insert the updated row
262     --
263     pqh_doa_ins.insert_dml
264       (p_rec                    => p_rec
265       ,p_effective_date         => p_effective_date
266       ,p_datetrack_mode         => p_datetrack_mode
267       ,p_validation_start_date  => p_validation_start_date
268       ,p_validation_end_date    => p_validation_end_date
269       );
270   End If;
271   hr_utility.set_location(' Leaving:'||l_proc, 20);
272 End dt_pre_update;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |------------------------------< pre_update >------------------------------|
276 -- ----------------------------------------------------------------------------
277 -- {Start Of Comments}
278 --
279 -- Description:
280 --   This private procedure contains any processing which is required before
281 --   the update dml.
282 --
283 -- Prerequisites:
284 --   This is an internal procedure which is called from the upd procedure.
285 --
286 -- In Parameters:
287 --   A Pl/Sql record structure.
288 --
289 -- Post Success:
290 --   Processing continues.
291 --
292 -- Post Failure:
293 --   If an error has occurred, an error message and exception will be raised
294 --   but not handled.
295 -- Developer Implementation Notes:
296 --   Any pre-processing required before the update dml is issued should be
297 --   coded within this procedure. It is important to note that any 3rd party
298 --   maintenance should be reviewed before placing in this procedure. The call
299 --   to the dt_update_dml procedure should NOT be removed.
300 --
301 -- Access Status:
302 --   Internal Row Handler Use Only.
303 --
304 -- {End Of Comments}
305 -- ----------------------------------------------------------------------------
306 Procedure pre_update
307   (p_rec                   in out NOCOPY pqh_doa_shd.g_rec_type
308   ,p_effective_date        in date
309   ,p_datetrack_mode        in varchar2
310   ,p_validation_start_date in date
311   ,p_validation_end_date   in date
312   ) is
313 --
314   l_proc        varchar2(72) := g_package||'pre_update';
315 --
316 Begin
317   hr_utility.set_location('Entering:'||l_proc, 5);
318   --
319   --
320   --
321   dt_pre_update
322     (p_rec                   => p_rec
323     ,p_effective_date        => p_effective_date
324     ,p_datetrack_mode        => p_datetrack_mode
325     ,p_validation_start_date => p_validation_start_date
326     ,p_validation_end_date   => p_validation_end_date
327     );
328   --
329   hr_utility.set_location(' Leaving:'||l_proc, 10);
330 End pre_update;
331 --
332 -- ----------------------------------------------------------------------------
333 -- |----------------------------< post_update >-------------------------------|
334 -- ----------------------------------------------------------------------------
335 -- {Start Of Comments}
336 --
337 -- Description:
338 --   This private procedure contains any processing which is required after
339 --   the update dml.
340 --
341 -- Prerequisites:
342 --   This is an internal procedure which is called from the upd procedure.
343 --
344 -- In Parameters:
345 --   A Pl/Sql record structure.
346 --
347 -- Post Success:
348 --   Processing continues.
349 --
350 -- Post Failure:
351 --   If an error has occurred, an error message and exception will be raised
352 --   but not handled.
353 --
354 -- Developer Implementation Notes:
355 --   Any post-processing required after the update dml is issued should be
356 --   coded within this procedure. It is important to note that any 3rd party
357 --   maintenance should be reviewed before placing in this procedure.
358 --
359 -- Access Status:
360 --   Internal Row Handler Use Only.
361 --
362 -- {End Of Comments}
363 -- ----------------------------------------------------------------------------
364 Procedure post_update
365   (p_rec                   in pqh_doa_shd.g_rec_type
366   ,p_effective_date        in date
367   ,p_datetrack_mode        in varchar2
368   ,p_validation_start_date in date
369   ,p_validation_end_date   in date
370   ) is
371 --
372   l_proc        varchar2(72) := g_package||'post_update';
373 --
374 Begin
375   hr_utility.set_location('Entering:'||l_proc, 5);
376   begin
377     --
378     pqh_doa_rku.after_update
379       (p_effective_date
380       => p_effective_date
381       ,p_datetrack_mode
382       => p_datetrack_mode
383       ,p_validation_start_date
384       => p_validation_start_date
385       ,p_validation_end_date
386       => p_validation_end_date
387       ,p_document_attribute_id
388       => p_rec.document_attribute_id
389       ,p_effective_start_date
390       => p_rec.effective_start_date
391       ,p_effective_end_date
392       => p_rec.effective_end_date
393       ,p_document_id
394       => p_rec.document_id
395       ,p_attribute_id
396       => p_rec.attribute_id
397       ,p_tag_name
398       => p_rec.tag_name
399       ,p_object_version_number
400       => p_rec.object_version_number
401       ,p_effective_start_date_o
402       => pqh_doa_shd.g_old_rec.effective_start_date
403       ,p_effective_end_date_o
404       => pqh_doa_shd.g_old_rec.effective_end_date
405       ,p_document_id_o
406       => pqh_doa_shd.g_old_rec.document_id
407       ,p_attribute_id_o
408       => pqh_doa_shd.g_old_rec.attribute_id
409       ,p_tag_name_o
410       => pqh_doa_shd.g_old_rec.tag_name
411       ,p_object_version_number_o
412       => pqh_doa_shd.g_old_rec.object_version_number
413       );
414     --
415   exception
416     --
417     when hr_api.cannot_find_prog_unit then
418       --
419       hr_api.cannot_find_prog_unit_error
420         (p_module_name => 'PQH_DOCUMENT_ATTRIBUTES_F'
421         ,p_hook_type   => 'AU');
422       --
423   end;
424   --
425   hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End post_update;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |-----------------------------< convert_defs >-----------------------------|
430 -- ----------------------------------------------------------------------------
431 -- {Start Of Comments}
432 --
433 -- Description:
434 --   The Convert_Defs procedure has one very important function:
435 --   It must return the record structure for the row with all system defaulted
436 --   values converted into its corresponding parameter value for update. When
437 --   we attempt to update a row through the Upd process , certain
438 --   parameters can be defaulted which enables flexibility in the calling of
439 --   the upd process (e.g. only attributes which need to be updated need to be
440 --   specified). For the upd process to determine which attributes
441 --   have NOT been specified we need to check if the parameter has a reserved
442 --   system default value. Therefore, for all parameters which have a
443 --   corresponding reserved system default mechanism specified we need to
444 --   check if a system default is being used. If a system default is being
445 --   used then we convert the defaulted value into its corresponding attribute
446 --   value held in the g_old_rec data structure.
447 --
448 -- Prerequisites:
449 --   This private function can only be called from the upd process.
450 --
451 -- In Parameters:
452 --   A Pl/Sql record structure.
453 --
454 -- Post Success:
455 --   The record structure will be returned with all system defaulted parameter
456 --   values converted into its current row attribute value.
457 --
458 -- Post Failure:
459 --   No direct error handling is required within this function. Any possible
460 --   errors within this procedure will be a PL/SQL value error due to
461 --   conversion of datatypes or data lengths.
462 --
463 -- Developer Implementation Notes:
464 --   None.
465 --
466 -- Access Status:
467 --   Internal Row Handler Use Only.
468 --
469 -- {End Of Comments}
470 -- ----------------------------------------------------------------------------
471 Procedure convert_defs
472   (p_rec in out NOCOPY pqh_doa_shd.g_rec_type
473   ) is
474 --
475 Begin
476   --
477   -- We must now examine each argument value in the
478   -- p_rec plsql record structure
479   -- to see if a system default is being used. If a system default
480   -- is being used then we must set to the 'current' argument value.
481   --
482   If (p_rec.document_id = hr_api.g_number) then
483     p_rec.document_id :=
484     pqh_doa_shd.g_old_rec.document_id;
485   End If;
486   If (p_rec.attribute_id = hr_api.g_number) then
487     p_rec.attribute_id :=
488     pqh_doa_shd.g_old_rec.attribute_id;
489   End If;
490   If (p_rec.tag_name = hr_api.g_varchar2) then
491     p_rec.tag_name :=
492     pqh_doa_shd.g_old_rec.tag_name;
493   End If;
494   --
495 End convert_defs;
496 --
497 -- ----------------------------------------------------------------------------
498 -- |---------------------------------< upd >----------------------------------|
499 -- ----------------------------------------------------------------------------
500 Procedure upd
501   (p_effective_date in     date
502   ,p_datetrack_mode in     varchar2
503   ,p_rec            in out NOCOPY pqh_doa_shd.g_rec_type
504   ) is
505 --
506   l_proc                        varchar2(72) := g_package||'upd';
507   l_validation_start_date       date;
508   l_validation_end_date         date;
509 --
510 Begin
511   hr_utility.set_location('Entering:'||l_proc, 5);
512   --
513   -- Ensure that the DateTrack update mode is valid
514   --
515   dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
516   --
517   -- We must lock the row which we need to update.
518   --
519   pqh_doa_shd.lck
520     (p_effective_date                   => p_effective_date
521     ,p_datetrack_mode                   => p_datetrack_mode
522     ,p_document_attribute_id            => p_rec.document_attribute_id
523     ,p_object_version_number            => p_rec.object_version_number
524     ,p_validation_start_date            => l_validation_start_date
525     ,p_validation_end_date              => l_validation_end_date
526     );
527   --
528   -- 1. During an update system defaults are used to determine if
529   --    arguments have been defaulted or not. We must therefore
530   --    derive the full record structure values to be updated.
531   --
532   -- 2. Call the supporting update validate operations.
533   --
534   pqh_doa_upd.convert_defs(p_rec);
535   --
536   pqh_doa_bus.update_validate
537     (p_rec                              => p_rec
538     ,p_effective_date                   => p_effective_date
539     ,p_datetrack_mode                   => p_datetrack_mode
540     ,p_validation_start_date            => l_validation_start_date
541     ,p_validation_end_date              => l_validation_end_date
542     );
543   --
544   -- Call to raise any errors on multi-message list
545   hr_multi_message.end_validation_set;
546   --
547   -- Call the supporting pre-update operation
548   --
549   pre_update
550     (p_rec                              => p_rec
551     ,p_effective_date                   => p_effective_date
552     ,p_datetrack_mode                   => p_datetrack_mode
553     ,p_validation_start_date            => l_validation_start_date
554     ,p_validation_end_date              => l_validation_end_date
555     );
556   --
557   -- Update the row.
558   --
559   update_dml
560     (p_rec                              => p_rec
561     ,p_effective_date                   => p_effective_date
562     ,p_datetrack_mode                   => p_datetrack_mode
563     ,p_validation_start_date            => l_validation_start_date
564     ,p_validation_end_date                  => l_validation_end_date
565     );
566   --
567   -- Call the supporting post-update operation
568   --
569   post_update
570     (p_rec                              => p_rec
571     ,p_effective_date                   => p_effective_date
572     ,p_datetrack_mode                   => p_datetrack_mode
573     ,p_validation_start_date            => l_validation_start_date
574     ,p_validation_end_date              => l_validation_end_date
575     );
576   --
577   -- Call to raise any errors on multi-message list
578   hr_multi_message.end_validation_set;
579 End upd;
580 --
581 -- ----------------------------------------------------------------------------
582 -- |------------------------------< upd >-------------------------------------|
583 -- ----------------------------------------------------------------------------
584 Procedure upd
585   (p_effective_date               in     date
586   ,p_datetrack_mode               in     varchar2
587   ,p_document_attribute_id        in     number
588   ,p_object_version_number        in out NOCOPY number
589   ,p_document_id                  in     number    default hr_api.g_number
590   ,p_attribute_id                 in     number    default hr_api.g_number
591   ,p_tag_name                     in     varchar2  default hr_api.g_varchar2
592   ,p_effective_start_date            out NOCOPY date
593   ,p_effective_end_date              out NOCOPY date
594   ) is
595 --
596   l_rec         pqh_doa_shd.g_rec_type;
597   l_proc        varchar2(72) := g_package||'upd';
598 --
599 Begin
600   hr_utility.set_location('Entering:'||l_proc, 5);
601   --
602   -- Call conversion function to turn arguments into the
603   -- l_rec structure.
604   --
605   l_rec :=
606   pqh_doa_shd.convert_args
607     (p_document_attribute_id
608     ,null
609     ,null
610     ,p_document_id
611     ,p_attribute_id
612     ,p_tag_name
613     ,p_object_version_number
614     );
615   --
616   -- Having converted the arguments into the
617   -- plsql record structure we call the corresponding record
618   -- business process.
619   --
620   pqh_doa_upd.upd
621     (p_effective_date
622     ,p_datetrack_mode
623     ,l_rec
624     );
625   --
626   -- Set the out parameters
627   --
628   p_object_version_number            := l_rec.object_version_number;
629   p_effective_start_date             := l_rec.effective_start_date;
630   p_effective_end_date               := l_rec.effective_end_date;
631   --
632   --
633   hr_utility.set_location(' Leaving:'||l_proc, 10);
634 End upd;
635 --
636 end pqh_doa_upd;