DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CET_UPD

Source


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