DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_EXR_UPD

Source


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