DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CEF_UPD

Source


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