DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_ATT_UPD

Source


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