DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RST_UPD

Source


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