DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TTM_UPD

Source


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