DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SLS_UPD

Source


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