DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RHA_UPD

Source


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