DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_SFT_UPD

Source


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