DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_DST_UPD

Source


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