DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RTM_UPD

Source


1 Package Body pqh_rtm_upd as
2 /* $Header: pqrtmrhi.pkb 120.2 2006/01/05 15:29:54 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_rtm_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 --   3) To update the specified row in the schema using the primary key in
21 --      the predicates.
22 --   4) To trap any constraint violations that may have occurred.
23 --   5) 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_rtm_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_role_templates Row
61   --
62   update pqh_role_templates
63   set
64   role_template_id                  = p_rec.role_template_id,
65   role_id                           = p_rec.role_id,
66   template_id                       = p_rec.template_id,
67   enable_flag                       = p_rec.enable_flag,
68   object_version_number             = p_rec.object_version_number
69   where role_template_id = p_rec.role_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_rtm_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_rtm_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_rtm_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_rtm_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(
166 p_effective_date in date,p_rec in pqh_rtm_shd.g_rec_type) is
167 --
168   l_proc  varchar2(72) := g_package||'post_update';
169 --
170 Begin
171   hr_utility.set_location('Entering:'||l_proc, 5);
172 --
173   --
174   -- Start of API User Hook for post_update.
175   --
176   begin
177     --
178     pqh_rtm_rku.after_update
179       (
180   p_role_template_id              =>p_rec.role_template_id
181  ,p_role_id                       =>p_rec.role_id
182  ,p_transaction_category_id       =>p_rec.transaction_category_id
183  ,p_template_id                   =>p_rec.template_id
184  ,p_enable_flag                   =>p_rec.enable_flag
185  ,p_object_version_number         =>p_rec.object_version_number
186  ,p_effective_date                =>p_effective_date
187  ,p_role_id_o                     =>pqh_rtm_shd.g_old_rec.role_id
188  ,p_transaction_category_id_o     =>pqh_rtm_shd.g_old_rec.transaction_category_id
189  ,p_template_id_o                 =>pqh_rtm_shd.g_old_rec.template_id
190  ,p_enable_flag_o                 =>pqh_rtm_shd.g_old_rec.enable_flag
191  ,p_object_version_number_o       =>pqh_rtm_shd.g_old_rec.object_version_number
192       );
193     --
194   exception
195     --
196     when hr_api.cannot_find_prog_unit then
197       --
198       hr_api.cannot_find_prog_unit_error
199         (p_module_name => 'pqh_role_templates'
200         ,p_hook_type   => 'AU');
201       --
202   end;
203   --
204   -- End of API User Hook for post_update.
205   --
206   --
207   hr_utility.set_location(' Leaving:'||l_proc, 10);
208 End post_update;
209 --
210 -- ----------------------------------------------------------------------------
211 -- |-----------------------------< convert_defs >-----------------------------|
212 -- ----------------------------------------------------------------------------
213 -- {Start Of Comments}
214 --
215 -- Description:
216 --   The Convert_Defs procedure has one very important function:
217 --   It must return the record structure for the row with all system defaulted
218 --   values converted into its corresponding parameter value for update. When
219 --   we attempt to update a row through the Upd process , certain
220 --   parameters can be defaulted which enables flexibility in the calling of
221 --   the upd process (e.g. only attributes which need to be updated need to be
222 --   specified). For the upd process to determine which attributes
223 --   have NOT been specified we need to check if the parameter has a reserved
224 --   system default value. Therefore, for all parameters which have a
225 --   corresponding reserved system default mechanism specified we need to
226 --   check if a system default is being used. If a system default is being
227 --   used then we convert the defaulted value into its corresponding attribute
228 --   value held in the g_old_rec data structure.
229 --
230 -- Prerequisites:
231 --   This private function can only be called from the upd process.
232 --
233 -- In Parameters:
234 --   A Pl/Sql record structre.
235 --
236 -- Post Success:
237 --   The record structure will be returned with all system defaulted parameter
238 --   values converted into its current row attribute value.
239 --
240 -- Post Failure:
241 --   No direct error handling is required within this function. Any possible
242 --   errors within this procedure will be a PL/SQL value error due to conversion
243 --   of datatypes or data lengths.
244 --
245 -- Developer Implementation Notes:
246 --   None.
247 --
248 -- Access Status:
249 --   Internal Row Handler Use Only.
250 --
251 -- {End Of Comments}
252 -- ----------------------------------------------------------------------------
253 Procedure convert_defs(p_rec in out nocopy pqh_rtm_shd.g_rec_type) is
254 --
255   l_proc  varchar2(72) := g_package||'convert_defs';
256 --
257 Begin
258   --
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   -- We must now examine each argument value in the
262   -- p_rec plsql record structure
263   -- to see if a system default is being used. If a system default
264   -- is being used then we must set to the 'current' argument value.
265   --
266   If (p_rec.role_id = hr_api.g_number) then
267     p_rec.role_id :=
268     pqh_rtm_shd.g_old_rec.role_id;
269   End If;
270   If (p_rec.transaction_category_id = hr_api.g_number) then
271     p_rec.transaction_category_id :=
272     pqh_rtm_shd.g_old_rec.transaction_category_id;
273   End If;
274   If (p_rec.template_id = hr_api.g_number) then
275     p_rec.template_id :=
276     pqh_rtm_shd.g_old_rec.template_id;
277   End If;
278   If (p_rec.enable_flag = hr_api.g_varchar2) then
279     p_rec.enable_flag :=
280     pqh_rtm_shd.g_old_rec.enable_flag;
281   End If;
282 
283   --
284   hr_utility.set_location(' Leaving:'||l_proc, 10);
285 --
286 End convert_defs;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |---------------------------------< upd >----------------------------------|
290 -- ----------------------------------------------------------------------------
291 Procedure upd
292   (
293   p_effective_date in date,
294   p_rec        in out nocopy pqh_rtm_shd.g_rec_type
295   ) is
296 --
297   l_proc  varchar2(72) := g_package||'upd';
298 --
299 Begin
300   hr_utility.set_location('Entering:'||l_proc, 5);
301   --
302   -- We must lock the row which we need to update.
303   --
304   pqh_rtm_shd.lck
305 	(
306 	p_rec.role_template_id,
307 	p_rec.object_version_number
308 	);
309   --
310   -- 1. During an update system defaults are used to determine if
311   --    arguments have been defaulted or not. We must therefore
312   --    derive the full record structure values to be updated.
313   --
314   -- 2. Call the supporting update validate operations.
315   --
316   convert_defs(p_rec);
317   pqh_rtm_bus.update_validate(p_rec
318   ,p_effective_date);
319   --
320   -- Call the supporting pre-update operation
321   --
322   pre_update(p_rec);
323   --
324   -- Update the row.
325   --
326   update_dml(p_rec);
327   --
328   -- Call the supporting post-update operation
329   --
330   post_update(
331 p_effective_date,p_rec);
332 End upd;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |---------------------------------< upd >----------------------------------|
336 -- ----------------------------------------------------------------------------
337 Procedure upd
338   (
339   p_effective_date in date,
340   p_role_template_id             in number,
341   p_role_id                      in number           default hr_api.g_number,
342   p_template_id                  in number           default hr_api.g_number,
343   p_enable_flag                  in varchar2         default hr_api.g_varchar2,
344   p_object_version_number        in out nocopy number
345   ) is
346 --
347   l_rec	  pqh_rtm_shd.g_rec_type;
348   l_proc  varchar2(72) := g_package||'upd';
349 --
350 Begin
351   hr_utility.set_location('Entering:'||l_proc, 5);
352   --
353   -- Call conversion function to turn arguments into the
354   -- l_rec structure.
355   --
356   l_rec :=
357   pqh_rtm_shd.convert_args
358   (
359   p_role_template_id,
360   p_role_id,
361   hr_api.g_number,
362   p_template_id,
363   p_enable_flag,
364   p_object_version_number
365   );
366   --
367   -- Having converted the arguments into the
368   -- plsql record structure we call the corresponding record
369   -- business process.
370   --
371   upd(
372     p_effective_date,l_rec);
373   p_object_version_number := l_rec.object_version_number;
374   --
375   hr_utility.set_location(' Leaving:'||l_proc, 10);
376 End upd;
377 --
378 end pqh_rtm_upd;