DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STC_UPD

Source


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