DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TAT_UPD

Source


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