DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RFT_UPD

Source


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