DBA Data[Home] [Help]

PACKAGE BODY: APPS.PSP_PSO_UPD

Source


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