DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TCT_UPD

Source


1 Package Body pqh_tct_upd as
2 /* $Header: pqtctrhi.pkb 120.7 2011/04/28 09:34:04 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_tct_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(p_rec in out nocopy pqh_tct_shd.g_rec_type) is
49 --
50   l_proc  varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53   hr_utility.set_location('Entering:'||l_proc, 5);
54   --
55   -- Increment the object version
56   --
57   p_rec.object_version_number := p_rec.object_version_number + 1;
58   --
59   --
60   -- Update the pqh_transaction_categories Row
61   --
62   update pqh_transaction_categories
63   set
64   transaction_category_id           = p_rec.transaction_category_id,
65   custom_wf_process_name            = p_rec.custom_wf_process_name,
66   custom_workflow_name              = p_rec.custom_workflow_name,
67   form_name                         = p_rec.form_name,
68   freeze_status_cd                  = p_rec.freeze_status_cd,
69   future_action_cd                  = p_rec.future_action_cd,
70   member_cd                         = p_rec.member_cd,
71   name                              = p_rec.name,
72   short_name                        = p_rec.short_name,
73   post_style_cd                     = p_rec.post_style_cd,
74   post_txn_function                 = p_rec.post_txn_function,
75   route_validated_txn_flag          = p_rec.route_validated_txn_flag,
76   prevent_approver_skip             = p_rec.prevent_approver_skip,
77   workflow_enable_flag          = p_rec.workflow_enable_flag,
78   enable_flag          = p_rec.enable_flag,
79   timeout_days                      = p_rec.timeout_days,
80   object_version_number             = p_rec.object_version_number,
81   consolidated_table_route_id       = p_rec.consolidated_table_route_id,
82   business_group_id                 = p_rec.business_group_id,
83   setup_type_cd                     = p_rec.setup_type_cd,
84   master_table_route_id       = p_rec.master_table_route_id
85   where transaction_category_id = p_rec.transaction_category_id;
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     pqh_tct_shd.constraint_error
94       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95   When hr_api.parent_integrity_violated Then
96     -- Parent integrity has been violated
97     pqh_tct_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When hr_api.unique_integrity_violated Then
100     -- Unique integrity has been violated
101     pqh_tct_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When Others Then
104     Raise;
105 End update_dml;
106 --
107 -- ----------------------------------------------------------------------------
108 -- |------------------------------< pre_update >------------------------------|
109 -- ----------------------------------------------------------------------------
110 -- {Start Of Comments}
111 --
112 -- Description:
113 --   This private procedure contains any processing which is required before
114 --   the update dml.
115 --
116 -- Prerequisites:
117 --   This is an internal procedure which is called from the upd procedure.
118 --
119 -- In Parameters:
120 --   A Pl/Sql record structre.
121 --
122 -- Post Success:
123 --   Processing continues.
124 --
125 -- Post Failure:
126 --   If an error has occurred, an error message and exception will be raised
127 --   but not handled.
128 --
129 -- Developer Implementation Notes:
130 --   Any pre-processing required before the update dml is issued should be
131 --   coded within this procedure. It is important to note that any 3rd party
132 --   maintenance should be reviewed before placing in this procedure.
133 --
134 -- Access Status:
135 --   Internal Row Handler Use Only.
136 --
137 -- {End Of Comments}
138 -- ----------------------------------------------------------------------------
139 Procedure pre_update(p_rec in pqh_tct_shd.g_rec_type) is
140 --
141   l_proc  varchar2(72) := g_package||'pre_update';
142 --
143 Begin
144   hr_utility.set_location('Entering:'||l_proc, 5);
145   --
146   hr_utility.set_location(' Leaving:'||l_proc, 10);
147 End pre_update;
148 --
149 -- ----------------------------------------------------------------------------
150 -- |-----------------------------< post_update >------------------------------|
151 -- ----------------------------------------------------------------------------
152 -- {Start Of Comments}
153 --
154 -- Description:
155 --   This private procedure contains any processing which is required after the
156 --   update dml.
157 --
158 -- Prerequisites:
159 --   This is an internal procedure which is called from the upd procedure.
160 --
161 -- In Parameters:
162 --   A Pl/Sql record structre.
163 --
164 -- Post Success:
165 --   Processing continues.
166 --
167 -- Post Failure:
168 --   If an error has occurred, an error message and exception will be raised
169 --   but not handled.
170 --
171 -- Developer Implementation Notes:
172 --   Any post-processing required after the update dml is issued should be
173 --   coded within this procedure. It is important to note that any 3rd party
174 --   maintenance should be reviewed before placing in this procedure.
175 --
176 -- Access Status:
177 --   Internal Row Handler Use Only.
178 --
179 -- {End Of Comments}
180 -- ----------------------------------------------------------------------------
181 Procedure post_update(
182 p_effective_date in date,p_rec in pqh_tct_shd.g_rec_type) is
183 --
184   l_proc  varchar2(72) := g_package||'post_update';
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188 --
189   --
190   -- Start of API User Hook for post_update.
191   --
192   begin
193     --
194     pqh_tct_rku.after_update
195       (
196   p_transaction_category_id       =>p_rec.transaction_category_id
197  ,p_custom_wf_process_name        =>p_rec.custom_wf_process_name
198  ,p_custom_workflow_name          =>p_rec.custom_workflow_name
199  ,p_form_name                     =>p_rec.form_name
200  ,p_freeze_status_cd              =>p_rec.freeze_status_cd
201  ,p_future_action_cd              =>p_rec.future_action_cd
202  ,p_member_cd                     =>p_rec.member_cd
203  ,p_name                          =>p_rec.name
204  ,p_short_name                    =>p_rec.short_name
205  ,p_post_style_cd                 =>p_rec.post_style_cd
206  ,p_post_txn_function             =>p_rec.post_txn_function
207  ,p_route_validated_txn_flag      =>p_rec.route_validated_txn_flag
208  ,p_prevent_approver_skip         =>p_rec.prevent_approver_skip
209  ,p_workflow_enable_flag      =>p_rec.workflow_enable_flag
210  ,p_enable_flag      =>p_rec.enable_flag
211  ,p_timeout_days                  =>p_rec.timeout_days
212  ,p_object_version_number         =>p_rec.object_version_number
213  ,p_consolidated_table_route_id   =>p_rec.consolidated_table_route_id
214  ,p_business_group_id             => p_rec.business_group_id
215  ,p_setup_type_cd                 => p_rec.setup_type_cd
216  ,p_master_table_route_id   =>p_rec.master_table_route_id
217  ,p_effective_date                =>p_effective_date
218  ,p_custom_wf_process_name_o      =>pqh_tct_shd.g_old_rec.custom_wf_process_name
219  ,p_custom_workflow_name_o        =>pqh_tct_shd.g_old_rec.custom_workflow_name
220  ,p_form_name_o                   =>pqh_tct_shd.g_old_rec.form_name
221  ,p_freeze_status_cd_o            =>pqh_tct_shd.g_old_rec.freeze_status_cd
222  ,p_future_action_cd_o            =>pqh_tct_shd.g_old_rec.future_action_cd
223  ,p_member_cd_o                   =>pqh_tct_shd.g_old_rec.member_cd
224  ,p_name_o                        =>pqh_tct_shd.g_old_rec.name
225  ,p_short_name_o                  =>pqh_tct_shd.g_old_rec.short_name
226  ,p_post_style_cd_o               =>pqh_tct_shd.g_old_rec.post_style_cd
227  ,p_post_txn_function_o           =>pqh_tct_shd.g_old_rec.post_txn_function
228  ,p_route_validated_txn_flag_o    =>pqh_tct_shd.g_old_rec.route_validated_txn_flag
229  ,p_prevent_approver_skip_o       =>pqh_tct_shd.g_old_rec.prevent_approver_skip
230  ,p_workflow_enable_flag_o    =>pqh_tct_shd.g_old_rec.workflow_enable_flag
231  ,p_enable_flag_o    =>pqh_tct_shd.g_old_rec.enable_flag
232  ,p_timeout_days_o                =>pqh_tct_shd.g_old_rec.timeout_days
233  ,p_object_version_number_o       =>pqh_tct_shd.g_old_rec.object_version_number
234  ,p_consolidated_table_route_i_o =>pqh_tct_shd.g_old_rec.consolidated_table_route_id
235  ,p_business_group_id_o             => pqh_tct_shd.g_old_rec.business_group_id
236  ,p_setup_type_cd_o                 => pqh_tct_shd.g_old_rec.setup_type_cd
237  ,p_master_table_route_i_o =>pqh_tct_shd.g_old_rec.master_table_route_id
238       );
239     --
240   exception
241     --
242     when hr_api.cannot_find_prog_unit then
243       --
244       hr_api.cannot_find_prog_unit_error
245         (p_module_name => 'pqh_transaction_categories'
246         ,p_hook_type   => 'AU');
247       --
248   end;
249   --
250   -- End of API User Hook for post_update.
251   --
252   --
253   hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End post_update;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |-----------------------------< convert_defs >-----------------------------|
258 -- ----------------------------------------------------------------------------
259 -- {Start Of Comments}
260 --
261 -- Description:
262 --   The Convert_Defs procedure has one very important function:
263 --   It must return the record structure for the row with all system defaulted
264 --   values converted into its corresponding parameter value for update. When
265 --   we attempt to update a row through the Upd process , certain
266 --   parameters can be defaulted which enables flexibility in the calling of
267 --   the upd process (e.g. only attributes which need to be updated need to be
268 --   specified). For the upd process to determine which attributes
269 --   have NOT been specified we need to check if the parameter has a reserved
270 --   system default value. Therefore, for all parameters which have a
271 --   corresponding reserved system default mechanism specified we need to
272 --   check if a system default is being used. If a system default is being
273 --   used then we convert the defaulted value into its corresponding attribute
274 --   value held in the g_old_rec data structure.
275 --
276 -- Prerequisites:
277 --   This private function can only be called from the upd process.
278 --
279 -- In Parameters:
280 --   A Pl/Sql record structre.
281 --
282 -- Post Success:
283 --   The record structure will be returned with all system defaulted parameter
284 --   values converted into its current row attribute value.
285 --
286 -- Post Failure:
287 --   No direct error handling is required within this function. Any possible
288 --   errors within this procedure will be a PL/SQL value error due to conversion
289 --   of datatypes or data lengths.
290 --
291 -- Developer Implementation Notes:
292 --   None.
293 --
294 -- Access Status:
295 --   Internal Row Handler Use Only.
296 --
297 -- {End Of Comments}
298 -- ----------------------------------------------------------------------------
299 Procedure convert_defs(p_rec in out nocopy pqh_tct_shd.g_rec_type) is
300 --
301   l_proc  varchar2(72) := g_package||'convert_defs';
302 --
303 Begin
304   --
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- We must now examine each argument value in the
308   -- p_rec plsql record structure
309   -- to see if a system default is being used. If a system default
310   -- is being used then we must set to the 'current' argument value.
311   --
312   If (p_rec.custom_wf_process_name = hr_api.g_varchar2) then
313     p_rec.custom_wf_process_name :=
314     pqh_tct_shd.g_old_rec.custom_wf_process_name;
315   End If;
316   If (p_rec.custom_workflow_name = hr_api.g_varchar2) then
317     p_rec.custom_workflow_name :=
318     pqh_tct_shd.g_old_rec.custom_workflow_name;
319   End If;
320   If (p_rec.form_name = hr_api.g_varchar2) then
321     p_rec.form_name :=
322     pqh_tct_shd.g_old_rec.form_name;
323   End If;
324   If (p_rec.freeze_status_cd = hr_api.g_varchar2) then
325     p_rec.freeze_status_cd :=
326     pqh_tct_shd.g_old_rec.freeze_status_cd;
327   End If;
328   If (p_rec.future_action_cd = hr_api.g_varchar2) then
329     p_rec.future_action_cd :=
330     pqh_tct_shd.g_old_rec.future_action_cd;
331   End If;
332   If (p_rec.member_cd = hr_api.g_varchar2) then
333     p_rec.member_cd :=
334     pqh_tct_shd.g_old_rec.member_cd;
335   End If;
336   If (p_rec.name = hr_api.g_varchar2) then
337     p_rec.name :=
338     pqh_tct_shd.g_old_rec.name;
339   End If;
340   If (p_rec.short_name = hr_api.g_varchar2) then
341     p_rec.short_name :=
342     pqh_tct_shd.g_old_rec.short_name;
343   End If;
344   If (p_rec.post_style_cd = hr_api.g_varchar2) then
345     p_rec.post_style_cd :=
346     pqh_tct_shd.g_old_rec.post_style_cd;
347   End If;
348   If (p_rec.post_txn_function = hr_api.g_varchar2) then
349     p_rec.post_txn_function :=
350     pqh_tct_shd.g_old_rec.post_txn_function;
351   End If;
352   If (p_rec.route_validated_txn_flag = hr_api.g_varchar2) then
353     p_rec.route_validated_txn_flag :=
354     pqh_tct_shd.g_old_rec.route_validated_txn_flag;
355   End If;
356   If (p_rec.prevent_approver_skip = hr_api.g_varchar2) then
357     p_rec.prevent_approver_skip :=
358     pqh_tct_shd.g_old_rec.prevent_approver_skip;
359   End If;
360   If (p_rec.workflow_enable_flag = hr_api.g_varchar2) then
361     p_rec.workflow_enable_flag :=
362     pqh_tct_shd.g_old_rec.workflow_enable_flag;
363   End If;
364   If (p_rec.enable_flag = hr_api.g_varchar2) then
365     p_rec.enable_flag :=
366     pqh_tct_shd.g_old_rec.enable_flag;
367   End If;
368   If (p_rec.timeout_days = hr_api.g_number) then
369     p_rec.timeout_days :=
370     pqh_tct_shd.g_old_rec.timeout_days;
371   End If;
372   If (p_rec.consolidated_table_route_id = hr_api.g_number) then
373     p_rec.consolidated_table_route_id :=
374     pqh_tct_shd.g_old_rec.consolidated_table_route_id;
375   End If;
376   If (p_rec.business_group_id = hr_api.g_number) then
377     p_rec.business_group_id :=
378     pqh_tct_shd.g_old_rec.business_group_id;
379   End If;
380   If (p_rec.setup_type_cd = hr_api.g_varchar2) then
381     p_rec.setup_type_cd :=
382     pqh_tct_shd.g_old_rec.setup_type_cd;
383   End If;
384   If (p_rec.master_table_route_id = hr_api.g_number) then
385     p_rec.master_table_route_id :=
386     pqh_tct_shd.g_old_rec.master_table_route_id;
387   End If;
388   --
389   hr_utility.set_location(' Leaving:'||l_proc, 10);
390 --
391 End convert_defs;
392 --
393 -- ----------------------------------------------------------------------------
394 -- |---------------------------------< upd >----------------------------------|
395 -- ----------------------------------------------------------------------------
396 Procedure upd
397   (
398   p_effective_date in date,
399   p_rec        in out nocopy pqh_tct_shd.g_rec_type
400   ) is
401 --
402   l_proc  varchar2(72) := g_package||'upd';
403 --
404 Begin
405   hr_utility.set_location('Entering:'||l_proc, 5);
406   --
407   -- We must lock the row which we need to update.
408   --
409   pqh_tct_shd.lck
410 	(
411 	p_rec.transaction_category_id,
412 	p_rec.object_version_number
413 	);
414   --
415   -- 1. During an update system defaults are used to determine if
416   --    arguments have been defaulted or not. We must therefore
417   --    derive the full record structure values to be updated.
418   --
419   -- 2. Call the supporting update validate operations.
420   --
421   convert_defs(p_rec);
422   pqh_tct_bus.update_validate(p_rec
423   ,p_effective_date);
424   --
425   -- Call the supporting pre-update operation
426   --
427   pre_update(p_rec);
428   --
429   -- Update the row.
430   --
431   update_dml(p_rec);
432   --
433   -- Call the supporting post-update operation
434   --
435   post_update(
436 p_effective_date,p_rec);
437 End upd;
438 --
439 -- ----------------------------------------------------------------------------
440 -- |---------------------------------< upd >----------------------------------|
441 -- ----------------------------------------------------------------------------
442 Procedure upd
443   (
444   p_effective_date in date,
445   p_transaction_category_id      in number,
446   p_custom_wf_process_name       in varchar2         default hr_api.g_varchar2,
447   p_custom_workflow_name         in varchar2         default hr_api.g_varchar2,
448   p_form_name                    in varchar2         default hr_api.g_varchar2,
449   p_freeze_status_cd             in varchar2         default hr_api.g_varchar2,
450   p_future_action_cd             in varchar2         default hr_api.g_varchar2,
451   p_member_cd                    in varchar2         default hr_api.g_varchar2,
452   p_name                         in varchar2         default hr_api.g_varchar2,
453   p_short_name                   in varchar2         default hr_api.g_varchar2,
454   p_post_style_cd                in varchar2         default hr_api.g_varchar2,
455   p_post_txn_function            in varchar2         default hr_api.g_varchar2,
456   p_route_validated_txn_flag     in varchar2         default hr_api.g_varchar2,
457   p_prevent_approver_skip        in varchar2         default hr_api.g_varchar2,
458   p_workflow_enable_flag     in varchar2         default hr_api.g_varchar2,
459   p_enable_flag     in varchar2         default hr_api.g_varchar2,
460   p_timeout_days                 in number           default hr_api.g_number,
461   p_object_version_number        in out nocopy number,
462   p_consolidated_table_route_id  in number           default hr_api.g_number ,
463   p_business_group_id            in number           default hr_api.g_number ,
464   p_setup_type_cd                in varchar2         default hr_api.g_varchar2,
465   p_master_table_route_id  in number           default hr_api.g_number
466   ) is
467 --
468   l_rec	  pqh_tct_shd.g_rec_type;
469   l_proc  varchar2(72) := g_package||'upd';
470 --
471 Begin
472   hr_utility.set_location('Entering:'||l_proc, 5);
473   --
474   -- Call conversion function to turn arguments into the
475   -- l_rec structure.
476   --
477   l_rec :=
478   pqh_tct_shd.convert_args
479   (
480   p_transaction_category_id,
481   p_custom_wf_process_name,
482   p_custom_workflow_name,
483   p_form_name,
484   p_freeze_status_cd,
485   p_future_action_cd,
486   p_member_cd,
487   p_name,
488   p_short_name,
489   p_post_style_cd,
490   p_post_txn_function,
491   p_route_validated_txn_flag,
492   p_prevent_approver_skip,
493   p_workflow_enable_flag,
494   p_enable_flag,
495   p_timeout_days,
496   p_object_version_number,
497   p_consolidated_table_route_id ,
498   p_business_group_id,
499   p_setup_type_cd,
500   p_master_table_route_id
501   );
502   --
503   -- Having converted the arguments into the
504   -- plsql record structure we call the corresponding record
505   -- business process.
506   --
507   upd(
508     p_effective_date,l_rec);
509   p_object_version_number := l_rec.object_version_number;
510   --
511   hr_utility.set_location(' Leaving:'||l_proc, 10);
512 End upd;
513 --
514 end pqh_tct_upd;