DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_OSV_UPD

Source


1 Package Body per_osv_upd as
2 /* $Header: peosvrhi.pkb 120.0 2005/05/31 12:37:30 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_osv_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_osv_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   per_osv_shd.g_api_dml := true;  -- Set the api dml status
67   --
68   -- Update the per_org_structure_versions Row
69   --
70   update per_org_structure_versions
71     set
72      org_structure_version_id        = p_rec.org_structure_version_id
73     ,business_group_id               = p_rec.business_group_id
74     ,organization_structure_id       = p_rec.organization_structure_id
75     ,date_from                       = p_rec.date_from
76     ,version_number                  = p_rec.version_number
77     ,copy_structure_version_id       = p_rec.copy_structure_version_id
78     ,date_to                         = p_rec.date_to
79     ,request_id                      = p_rec.request_id
80     ,program_application_id          = p_rec.program_application_id
81     ,program_id                      = p_rec.program_id
82     ,program_update_date             = p_rec.program_update_date
83     ,object_version_number           = p_rec.object_version_number
84     ,topnode_pos_ctrl_enabled_flag   = p_rec.topnode_pos_ctrl_enabled_flag
85     where org_structure_version_id = p_rec.org_structure_version_id;
86   --
87   per_osv_shd.g_api_dml := false;   -- Unset the api dml status
88   --
89   hr_utility.set_location(' Leaving:'||l_proc, 10);
90 --
91 Exception
92   When hr_api.check_integrity_violated Then
93     -- A check constraint has been violated
94     per_osv_shd.g_api_dml := false;   -- Unset the api dml status
95     per_osv_shd.constraint_error
96       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97   When hr_api.parent_integrity_violated Then
98     -- Parent integrity has been violated
99     per_osv_shd.g_api_dml := false;   -- Unset the api dml status
100     per_osv_shd.constraint_error
101       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102   When hr_api.unique_integrity_violated Then
103     -- Unique integrity has been violated
104     per_osv_shd.g_api_dml := false;   -- Unset the api dml status
105     per_osv_shd.constraint_error
106       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107   When Others Then
108     per_osv_shd.g_api_dml := false;   -- Unset the api dml status
109     Raise;
110 End update_dml;
111 --
112 -- ----------------------------------------------------------------------------
113 -- |------------------------------< pre_update >------------------------------|
114 -- ----------------------------------------------------------------------------
115 -- {Start Of Comments}
116 --
117 -- Description:
118 --   This private procedure contains any processing which is required before
119 --   the update dml.
120 --
121 -- Prerequisites:
122 --   This is an internal procedure which is called from the upd procedure.
123 --
124 -- In Parameters:
125 --   A Pl/Sql record structure.
126 --
127 -- Post Success:
128 --   Processing continues.
129 --
130 -- Post Failure:
131 --   If an error has occurred, an error message and exception wil be raised
132 --   but not handled.
133 --
134 -- Developer Implementation Notes:
135 --   Any pre-processing required before the update dml is issued should be
136 --   coded within this procedure. It is important to note that any 3rd party
137 --   maintenance should be reviewed before placing in this procedure.
138 --
139 -- Access Status:
140 --   Internal Row Handler Use Only.
141 --
142 -- {End Of Comments}
143 -- ----------------------------------------------------------------------------
144 Procedure pre_update
145   (p_rec in per_osv_shd.g_rec_type
146   ) is
147 --
148   l_proc  varchar2(72) := g_package||'pre_update';
149 --
150 Begin
151   hr_utility.set_location('Entering:'||l_proc, 5);
152   --
153   hr_utility.set_location(' Leaving:'||l_proc, 10);
154 End pre_update;
155 --
156 -- ----------------------------------------------------------------------------
157 -- |-----------------------------< post_update >------------------------------|
158 -- ----------------------------------------------------------------------------
159 -- {Start Of Comments}
160 --
161 -- Description:
162 --   This private procedure contains any processing which is required after
163 --   the update dml.
164 --
165 -- Prerequisites:
166 --   This is an internal procedure which is called from the upd procedure.
167 --
168 -- In Parameters:
169 --   A Pl/Sql record structure.
170 --
171 -- Post Success:
172 --   Processing continues.
173 --
174 -- Post Failure:
175 --   If an error has occurred, an error message and exception will be raised
176 --   but not handled.
177 --
178 -- Developer Implementation Notes:
179 --   Any post-processing required after the update dml is issued should be
180 --   coded within this procedure. It is important to note that any 3rd party
181 --   maintenance should be reviewed before placing in this procedure.
182 --
183 -- Access Status:
184 --   Internal Row Handler Use Only.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure post_update
189   (p_effective_date               in date
190   ,p_rec                          in per_osv_shd.g_rec_type
191   ) is
192 --
193   l_proc  varchar2(72) := g_package||'post_update';
194 --
195 Begin
196   hr_utility.set_location('Entering:'||l_proc, 5);
197   begin
198     --
199     per_osv_rku.after_update
200       (p_effective_date              => p_effective_date
201       ,p_org_structure_version_id
202       => p_rec.org_structure_version_id
203       ,p_business_group_id
204       => p_rec.business_group_id
205       ,p_organization_structure_id
206       => p_rec.organization_structure_id
207       ,p_date_from
208       => p_rec.date_from
209       ,p_version_number
210       => p_rec.version_number
211       ,p_copy_structure_version_id
212       => p_rec.copy_structure_version_id
213       ,p_date_to
214       => p_rec.date_to
215       ,p_request_id
216       => p_rec.request_id
217       ,p_program_application_id
218       => p_rec.program_application_id
219       ,p_program_id
220       => p_rec.program_id
221       ,p_program_update_date
222       => p_rec.program_update_date
223       ,p_object_version_number
224       => p_rec.object_version_number
225       ,p_topnode_pos_ctrl_enabled_fla
226       => p_rec.topnode_pos_ctrl_enabled_flag
227       ,p_business_group_id_o
228       => per_osv_shd.g_old_rec.business_group_id
229       ,p_organization_structure_id_o
230       => per_osv_shd.g_old_rec.organization_structure_id
231       ,p_date_from_o
232       => per_osv_shd.g_old_rec.date_from
233       ,p_version_number_o
234       => per_osv_shd.g_old_rec.version_number
235       ,p_copy_structure_version_id_o
236       => per_osv_shd.g_old_rec.copy_structure_version_id
237       ,p_date_to_o
238       => per_osv_shd.g_old_rec.date_to
239       ,p_request_id_o
240       => per_osv_shd.g_old_rec.request_id
241       ,p_program_application_id_o
242       => per_osv_shd.g_old_rec.program_application_id
243       ,p_program_id_o
244       => per_osv_shd.g_old_rec.program_id
245       ,p_program_update_date_o
246       => per_osv_shd.g_old_rec.program_update_date
247       ,p_object_version_number_o
248       => per_osv_shd.g_old_rec.object_version_number
249       ,p_topnode_pos_ctrl_enabled_f_o
250       => per_osv_shd.g_old_rec.topnode_pos_ctrl_enabled_flag
251       );
252     --
253   exception
254     --
255     when hr_api.cannot_find_prog_unit then
256       --
257       hr_api.cannot_find_prog_unit_error
258         (p_module_name => 'PER_ORG_STRUCTURE_VERSIONS'
259         ,p_hook_type   => 'AU');
260       --
261   end;
262   --
263   hr_utility.set_location(' Leaving:'||l_proc, 10);
264 End post_update;
265 --
266 -- ----------------------------------------------------------------------------
267 -- |-----------------------------< convert_defs >-----------------------------|
268 -- ----------------------------------------------------------------------------
269 -- {Start Of Comments}
270 --
271 -- Description:
272 --   The Convert_Defs procedure has one very important function:
273 --   It must return the record structure for the row with all system defaulted
274 --   values converted into its corresponding parameter value for update. When
275 --   we attempt to update a row through the Upd process , certain
276 --   parameters can be defaulted which enables flexibility in the calling of
277 --   the upd process (e.g. only attributes which need to be updated need to be
278 --   specified). For the upd process to determine which attributes
279 --   have NOT been specified we need to check if the parameter has a reserved
280 --   system default value. Therefore, for all parameters which have a
281 --   corresponding reserved system default mechanism specified we need to
282 --   check if a system default is being used. If a system default is being
283 --   used then we convert the defaulted value into its corresponding attribute
284 --   value held in the g_old_rec data structure.
285 --
286 -- Prerequisites:
287 --   This private function can only be called from the upd process.
288 --
289 -- In Parameters:
290 --   A Pl/Sql record structure.
291 --
292 -- Post Success:
293 --   The record structure will be returned with all system defaulted parameter
294 --   values converted into its current row attribute value.
295 --
296 -- Post Failure:
297 --   No direct error handling is required within this function. Any possible
298 --   errors within this procedure will be a PL/SQL value error due to
299 --   conversion of datatypes or data lengths.
300 --
301 -- Developer Implementation Notes:
302 --   None.
303 --
304 -- Access Status:
305 --   Internal Row Handler Use Only.
306 --
307 -- {End Of Comments}
308 -- ----------------------------------------------------------------------------
309 Procedure convert_defs
310   (p_rec in out nocopy per_osv_shd.g_rec_type
311   ) is
312 --
313 Begin
314   --
315   -- We must now examine each argument value in the
316   -- p_rec plsql record structure
317   -- to see if a system default is being used. If a system default
318   -- is being used then we must set to the 'current' argument value.
319   --
320   If (p_rec.business_group_id = hr_api.g_number) then
321     p_rec.business_group_id :=
322     per_osv_shd.g_old_rec.business_group_id;
323   End If;
324   If (p_rec.organization_structure_id = hr_api.g_number) then
325     p_rec.organization_structure_id :=
326     per_osv_shd.g_old_rec.organization_structure_id;
327   End If;
328   If (p_rec.date_from = hr_api.g_date) then
329     p_rec.date_from :=
330     per_osv_shd.g_old_rec.date_from;
331   End If;
332   If (p_rec.version_number = hr_api.g_number) then
333     p_rec.version_number :=
334     per_osv_shd.g_old_rec.version_number;
335   End If;
336   If (p_rec.copy_structure_version_id = hr_api.g_number) then
337     p_rec.copy_structure_version_id :=
338     per_osv_shd.g_old_rec.copy_structure_version_id;
339   End If;
340   If (p_rec.date_to = hr_api.g_date) then
341     p_rec.date_to :=
342     per_osv_shd.g_old_rec.date_to;
343   End If;
344   If (p_rec.request_id = hr_api.g_number) then
345     p_rec.request_id :=
346     per_osv_shd.g_old_rec.request_id;
347   End If;
348   If (p_rec.program_application_id = hr_api.g_number) then
349     p_rec.program_application_id :=
350     per_osv_shd.g_old_rec.program_application_id;
351   End If;
352   If (p_rec.program_id = hr_api.g_number) then
353     p_rec.program_id :=
354     per_osv_shd.g_old_rec.program_id;
355   End If;
356   If (p_rec.program_update_date = hr_api.g_date) then
357     p_rec.program_update_date :=
358     per_osv_shd.g_old_rec.program_update_date;
359   End If;
360   If (p_rec.topnode_pos_ctrl_enabled_flag = hr_api.g_varchar2) then
361     p_rec.topnode_pos_ctrl_enabled_flag :=
362     per_osv_shd.g_old_rec.topnode_pos_ctrl_enabled_flag;
363   End If;
364   --
365 End convert_defs;
366 --
367 -- ----------------------------------------------------------------------------
368 -- |---------------------------------< upd >----------------------------------|
369 -- ----------------------------------------------------------------------------
370 Procedure upd
371   (p_effective_date               in date
372   ,p_rec                          in out nocopy per_osv_shd.g_rec_type
373   ,p_gap_warning                 out nocopy boolean
374 ) is
375 --
376   l_proc  varchar2(72) := g_package||'upd';
377 --
378 Begin
379   hr_utility.set_location('Entering:'||l_proc, 5);
380   --
381   -- We must lock the row which we need to update.
382   --
383   per_osv_shd.lck
384     (p_rec.org_structure_version_id
385     ,p_rec.object_version_number
386     );
387   --
388   -- 1. During an update system defaults are used to determine if
389   --    arguments have been defaulted or not. We must therefore
390   --    derive the full record structure values to be updated.
391   --
392   -- 2. Call the supporting update validate operations.
393   --
394   convert_defs(p_rec);
395   per_osv_bus.update_validate
396      (p_effective_date
397      ,p_rec
398      ,p_gap_warning
399      );
400   --
401   -- Call the supporting pre-update operation
402   --
403   per_osv_upd.pre_update(p_rec);
404   --
405   -- Update the row.
406   --
407   per_osv_upd.update_dml(p_rec);
408   --
409   -- Call the supporting post-update operation
410   --
411   per_osv_upd.post_update
412      (p_effective_date
413      ,p_rec
414      );
415 End upd;
416 --
417 -- ----------------------------------------------------------------------------
418 -- |---------------------------------< upd >----------------------------------|
419 -- ----------------------------------------------------------------------------
420 Procedure upd
421   (p_effective_date               in     date
422   ,p_org_structure_version_id     in     number
423   ,p_object_version_number        in out nocopy number
424   ,p_organization_structure_id    in     number    default hr_api.g_number
425   ,p_date_from                    in     date      default hr_api.g_date
426   ,p_version_number               in     number    default hr_api.g_number
427   ,p_copy_structure_version_id    in     number    default hr_api.g_number
428   ,p_date_to                      in     date      default hr_api.g_date
429   ,p_request_id                   in     number    default hr_api.g_number
430   ,p_program_application_id       in     number    default hr_api.g_number
431   ,p_program_id                   in     number    default hr_api.g_number
432   ,p_program_update_date          in     date      default hr_api.g_date
433   ,p_topnode_pos_ctrl_enabled_fla in     varchar2  default hr_api.g_varchar2
434   ,p_gap_warning                 out nocopy     boolean) is
435 --
436   l_rec   per_osv_shd.g_rec_type;
437   l_proc  varchar2(72) := g_package||'upd';
438 --
439 Begin
440   hr_utility.set_location('Entering:'||l_proc, 5);
441   --
442   -- Call conversion function to turn arguments into the
443   -- l_rec structure.
444   --
445   l_rec :=
446   per_osv_shd.convert_args
447   (p_org_structure_version_id
448   ,hr_api.g_number
449   ,p_organization_structure_id
450   ,p_date_from
451   ,p_version_number
452   ,p_copy_structure_version_id
453   ,p_date_to
454   ,p_request_id
455   ,p_program_application_id
456   ,p_program_id
457   ,p_program_update_date
458   ,p_object_version_number
459   ,p_topnode_pos_ctrl_enabled_fla
460   );
461   --
462   -- Having converted the arguments into the
463   -- plsql record structure we call the corresponding record
464   -- business process.
465   --
466   per_osv_upd.upd
467      (p_effective_date
468      ,l_rec
469      ,p_gap_warning);
470 
471   p_object_version_number := l_rec.object_version_number;
472   --
473   hr_utility.set_location(' Leaving:'||l_proc, 10);
474 End upd;
475 --
476 end per_osv_upd;