DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_PMM_UPD

Source


1 Package Body ota_pmm_upd as
2 /* $Header: otpmm01t.pkb 115.2 99/07/16 00:53:06 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ota_pmm_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 functions of this
17 --   procedure are as follows:
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 -- Pre Conditions:
28 --   This is an internal private procedure which must be called from the upd
29 --   procedure.
30 --
31 -- In Arguments:
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' arguments list should be modified if any of your
47 --   attributes are not updateable.
48 --
49 -- Access Status:
50 --   Internal Development Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out ota_pmm_shd.g_rec_type) is
55 --
56   l_proc  varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59   hr_utility.set_location('Entering:'||l_proc, 5);
60   --
61   -- Increment the object version
62   --
63   p_rec.object_version_number := p_rec.object_version_number + 1;
64   --
65   ota_pmm_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ota_program_memberships Row
68   --
69   update ota_program_memberships
70   set
71   program_membership_id             = p_rec.program_membership_id,
72   event_id                          = p_rec.event_id,
73   program_event_id                  = p_rec.program_event_id,
74   object_version_number             = p_rec.object_version_number,
75   comments                          = p_rec.comments,
76   group_name                        = p_rec.group_name,
77   required_flag                     = p_rec.required_flag,
78   role                              = p_rec.role,
79   sequence                          = p_rec.sequence,
80   pmm_information_category          = p_rec.pmm_information_category,
81   pmm_information1                  = p_rec.pmm_information1,
82   pmm_information2                  = p_rec.pmm_information2,
83   pmm_information3                  = p_rec.pmm_information3,
84   pmm_information4                  = p_rec.pmm_information4,
85   pmm_information5                  = p_rec.pmm_information5,
86   pmm_information6                  = p_rec.pmm_information6,
87   pmm_information7                  = p_rec.pmm_information7,
88   pmm_information8                  = p_rec.pmm_information8,
89   pmm_information9                  = p_rec.pmm_information9,
90   pmm_information10                 = p_rec.pmm_information10,
91   pmm_information11                 = p_rec.pmm_information11,
92   pmm_information12                 = p_rec.pmm_information12,
93   pmm_information13                 = p_rec.pmm_information13,
94   pmm_information14                 = p_rec.pmm_information14,
95   pmm_information15                 = p_rec.pmm_information15,
96   pmm_information16                 = p_rec.pmm_information16,
97   pmm_information17                 = p_rec.pmm_information17,
98   pmm_information18                 = p_rec.pmm_information18,
99   pmm_information19                 = p_rec.pmm_information19,
100   pmm_information20                 = p_rec.pmm_information20
101   where program_membership_id = p_rec.program_membership_id;
102   --
103   ota_pmm_shd.g_api_dml := false;   -- Unset the api dml status
104   --
105   hr_utility.set_location(' Leaving:'||l_proc, 10);
106 --
107 Exception
108   When hr_api.check_integrity_violated Then
109     -- A check constraint has been violated
110     ota_pmm_shd.g_api_dml := false;   -- Unset the api dml status
111     ota_pmm_shd.constraint_error
112       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113   When hr_api.parent_integrity_violated Then
114     -- Parent integrity has been violated
115     ota_pmm_shd.g_api_dml := false;   -- Unset the api dml status
116     ota_pmm_shd.constraint_error
117       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118   When hr_api.unique_integrity_violated Then
119     -- Unique integrity has been violated
120     ota_pmm_shd.g_api_dml := false;   -- Unset the api dml status
121     ota_pmm_shd.constraint_error
122       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
123   When Others Then
124     ota_pmm_shd.g_api_dml := false;   -- Unset the api dml status
125     Raise;
126 End update_dml;
127 --
128 -- ----------------------------------------------------------------------------
129 -- |------------------------------< pre_update >------------------------------|
130 -- ----------------------------------------------------------------------------
131 -- {Start Of Comments}
132 --
133 -- Description:
134 --   This private procedure contains any processing which is required before
135 --   the update dml.
136 --
137 -- Pre Conditions:
138 --   This is an internal procedure which is called from the upd procedure.
139 --
140 -- In Arguments:
141 --   A Pl/Sql record structre.
142 --
143 -- Post Success:
144 --   Processing continues.
145 --
146 -- Post Failure:
147 --   If an error has occurred, an error message and exception will be raised
148 --   but not handled.
149 --
150 -- Developer Implementation Notes:
151 --   Any pre-processing required before the update dml is issued should be
152 --   coded within this procedure. It is important to note that any 3rd party
153 --   maintenance should be reviewed before placing in this procedure.
154 --
155 -- Access Status:
156 --   Internal Development Use Only.
157 --
158 -- {End Of Comments}
159 -- ----------------------------------------------------------------------------
160 Procedure pre_update(p_rec in ota_pmm_shd.g_rec_type) is
161 --
162   l_proc  varchar2(72) := g_package||'pre_update';
163 --
164 Begin
165   hr_utility.set_location('Entering:'||l_proc, 5);
166   --
167   hr_utility.set_location(' Leaving:'||l_proc, 10);
168 End pre_update;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_update >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This private procedure contains any processing which is required after the
177 --   update dml.
178 --
179 -- Pre Conditions:
180 --   This is an internal procedure which is called from the upd procedure.
181 --
182 -- In Arguments:
183 --   A Pl/Sql record structre.
184 --
185 -- Post Success:
186 --   Processing continues.
187 --
188 -- Post Failure:
189 --   If an error has occurred, an error message and exception will be raised
190 --   but not handled.
191 --
192 -- Developer Implementation Notes:
193 --   Any post-processing required after the update dml is issued should be
194 --   coded within this procedure. It is important to note that any 3rd party
195 --   maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 --   Internal Development Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_update(p_rec in ota_pmm_shd.g_rec_type) is
203 --
204   l_proc  varchar2(72) := g_package||'post_update';
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   --
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End post_update;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |-----------------------------< convert_defs >-----------------------------|
214 -- ----------------------------------------------------------------------------
215 -- {Start Of Comments}
216 --
217 -- Description:
218 --   The Convert_Defs function has one very important function:
219 --   It must return the record structure for the row with all system defaulted
220 --   values converted into its corresponding argument value for update. When
221 --   we attempt to update a row through the Upd business process , certain
222 --   arguments can be defaulted which enables flexibility in the calling of
223 --   the upd process (e.g. only attributes which need to be updated need to be
224 --   specified). For the upd business process to determine which attributes
225 --   have NOT been specified we need to check if the argument has a reserved
226 --   system default value. Therefore, for all attributes which have a
227 --   corresponding reserved system default mechanism specified we need to
228 --   check if a system default is being used. If a system default is being
229 --   used then we convert the defaulted value into its corresponding attribute
230 --   value held in the g_old_rec data structure.
231 --
232 -- Pre Conditions:
233 --   This private function can only be called from the upd process.
234 --
235 -- In Arguments:
236 --   A Pl/Sql record structre.
237 --
238 -- Post Success:
239 --   The record structure will be returned with all system defaulted argument
240 --   values converted into its current row attribute value.
241 --
242 -- Post Failure:
243 --   No direct error handling is required within this function. Any possible
244 --   errors within this function will be a PL/SQL value error due to conversion
245 --   of datatypes or data lengths.
246 --
247 -- Developer Implementation Notes:
248 --   None.
249 --
250 -- Access Status:
251 --   Internal Development Use Only.
252 --
253 -- {End Of Comments}
254 -- ----------------------------------------------------------------------------
255 Function convert_defs(p_rec in out ota_pmm_shd.g_rec_type)
256          Return ota_pmm_shd.g_rec_type is
257 --
258   l_proc  varchar2(72) := g_package||'convert_defs';
259 --
260 Begin
261   --
262   hr_utility.set_location('Entering:'||l_proc, 5);
263   --
264   -- We must now examine each argument value in the
265   -- p_rec plsql record structure
266   -- to see if a system default is being used. If a system default
267   -- is being used then we must set to the 'current' argument value.
268   --
269   If (p_rec.event_id = hr_api.g_number) then
270     p_rec.event_id :=
271     ota_pmm_shd.g_old_rec.event_id;
272   End If;
273   If (p_rec.program_event_id = hr_api.g_number) then
274     p_rec.program_event_id :=
275     ota_pmm_shd.g_old_rec.program_event_id;
276   End If;
277   If (p_rec.comments = hr_api.g_varchar2) then
278     p_rec.comments :=
279     ota_pmm_shd.g_old_rec.comments;
280   End If;
281   If (p_rec.group_name = hr_api.g_varchar2) then
282     p_rec.group_name :=
283     ota_pmm_shd.g_old_rec.group_name;
284   End If;
285   If (p_rec.required_flag = hr_api.g_varchar2) then
286     p_rec.required_flag :=
287     ota_pmm_shd.g_old_rec.required_flag;
288   End If;
289   If (p_rec.role = hr_api.g_varchar2) then
290     p_rec.role :=
291     ota_pmm_shd.g_old_rec.role;
292   End If;
293   If (p_rec.sequence = hr_api.g_number) then
294     p_rec.sequence :=
295     ota_pmm_shd.g_old_rec.sequence;
296   End If;
297   If (p_rec.pmm_information_category = hr_api.g_varchar2) then
298     p_rec.pmm_information_category :=
299     ota_pmm_shd.g_old_rec.pmm_information_category;
300   End If;
301   If (p_rec.pmm_information1 = hr_api.g_varchar2) then
302     p_rec.pmm_information1 :=
303     ota_pmm_shd.g_old_rec.pmm_information1;
304   End If;
305   If (p_rec.pmm_information2 = hr_api.g_varchar2) then
306     p_rec.pmm_information2 :=
307     ota_pmm_shd.g_old_rec.pmm_information2;
308   End If;
309   If (p_rec.pmm_information3 = hr_api.g_varchar2) then
310     p_rec.pmm_information3 :=
311     ota_pmm_shd.g_old_rec.pmm_information3;
312   End If;
313   If (p_rec.pmm_information4 = hr_api.g_varchar2) then
314     p_rec.pmm_information4 :=
315     ota_pmm_shd.g_old_rec.pmm_information4;
316   End If;
317   If (p_rec.pmm_information5 = hr_api.g_varchar2) then
318     p_rec.pmm_information5 :=
319     ota_pmm_shd.g_old_rec.pmm_information5;
320   End If;
321   If (p_rec.pmm_information6 = hr_api.g_varchar2) then
322     p_rec.pmm_information6 :=
323     ota_pmm_shd.g_old_rec.pmm_information6;
324   End If;
325   If (p_rec.pmm_information7 = hr_api.g_varchar2) then
326     p_rec.pmm_information7 :=
327     ota_pmm_shd.g_old_rec.pmm_information7;
328   End If;
329   If (p_rec.pmm_information8 = hr_api.g_varchar2) then
330     p_rec.pmm_information8 :=
331     ota_pmm_shd.g_old_rec.pmm_information8;
332   End If;
333   If (p_rec.pmm_information9 = hr_api.g_varchar2) then
334     p_rec.pmm_information9 :=
335     ota_pmm_shd.g_old_rec.pmm_information9;
336   End If;
337   If (p_rec.pmm_information10 = hr_api.g_varchar2) then
338     p_rec.pmm_information10 :=
339     ota_pmm_shd.g_old_rec.pmm_information10;
340   End If;
341   If (p_rec.pmm_information11 = hr_api.g_varchar2) then
342     p_rec.pmm_information11 :=
343     ota_pmm_shd.g_old_rec.pmm_information11;
344   End If;
345   If (p_rec.pmm_information12 = hr_api.g_varchar2) then
346     p_rec.pmm_information12 :=
347     ota_pmm_shd.g_old_rec.pmm_information12;
348   End If;
349   If (p_rec.pmm_information13 = hr_api.g_varchar2) then
350     p_rec.pmm_information13 :=
351     ota_pmm_shd.g_old_rec.pmm_information13;
352   End If;
353   If (p_rec.pmm_information14 = hr_api.g_varchar2) then
354     p_rec.pmm_information14 :=
355     ota_pmm_shd.g_old_rec.pmm_information14;
356   End If;
357   If (p_rec.pmm_information15 = hr_api.g_varchar2) then
358     p_rec.pmm_information15 :=
359     ota_pmm_shd.g_old_rec.pmm_information15;
360   End If;
361   If (p_rec.pmm_information16 = hr_api.g_varchar2) then
362     p_rec.pmm_information16 :=
363     ota_pmm_shd.g_old_rec.pmm_information16;
364   End If;
365   If (p_rec.pmm_information17 = hr_api.g_varchar2) then
366     p_rec.pmm_information17 :=
367     ota_pmm_shd.g_old_rec.pmm_information17;
368   End If;
369   If (p_rec.pmm_information18 = hr_api.g_varchar2) then
370     p_rec.pmm_information18 :=
371     ota_pmm_shd.g_old_rec.pmm_information18;
372   End If;
373   If (p_rec.pmm_information19 = hr_api.g_varchar2) then
374     p_rec.pmm_information19 :=
375     ota_pmm_shd.g_old_rec.pmm_information19;
376   End If;
377   If (p_rec.pmm_information20 = hr_api.g_varchar2) then
378     p_rec.pmm_information20 :=
379     ota_pmm_shd.g_old_rec.pmm_information20;
380   End If;
381   --
382   -- Return the plsql record structure.
383   --
384   hr_utility.set_location(' Leaving:'||l_proc, 10);
385   Return(p_rec);
386 --
387 End convert_defs;
388 --
389 -- ----------------------------------------------------------------------------
390 -- |---------------------------------< upd >----------------------------------|
391 -- ----------------------------------------------------------------------------
392 Procedure upd
393   (
394   p_rec        in out ota_pmm_shd.g_rec_type,
395   p_validate   in     boolean default false
396   ) is
397 --
398   l_proc  varchar2(72) := g_package||'upd';
399 --
400 Begin
401   hr_utility.set_location('Entering:'||l_proc, 5);
402   --
403   -- Determine if the business process is to be validated.
404   --
405   If p_validate then
406     --
407     -- Issue the savepoint.
408     --
409     SAVEPOINT upd_ota_pmm;
410   End If;
411   --
412   -- We must lock the row which we need to update.
413   --
414   ota_pmm_shd.lck
415 	(
416 	p_rec.program_membership_id,
417 	p_rec.object_version_number
418 	);
419   --
420   -- 1. During an update system defaults are used to determine if
421   --    arguments have been defaulted or not. We must therefore
422   --    derive the full record structure values to be updated.
423   --
424   -- 2. Call the supporting update validate operations.
425   --
426   ota_pmm_bus.update_validate(convert_defs(p_rec));
427   --
428   -- Call the supporting pre-update operation
429   --
430   pre_update(p_rec);
431   --
432   -- Update the row.
433   --
434   update_dml(p_rec);
435   --
436   -- Call the supporting post-update operation
437   --
438   post_update(p_rec);
439   --
440   -- If we are validating then raise the Validate_Enabled exception
441   --
442   If p_validate then
443     Raise HR_Api.Validate_Enabled;
444   End If;
445   --
446   hr_utility.set_location(' Leaving:'||l_proc, 10);
447 Exception
448   When HR_Api.Validate_Enabled Then
449     --
450     -- As the Validate_Enabled exception has been raised
451     -- we must rollback to the savepoint
452     --
453     ROLLBACK TO upd_ota_pmm;
454 End upd;
455 --
456 -- ----------------------------------------------------------------------------
457 -- |---------------------------------< upd >----------------------------------|
458 -- ----------------------------------------------------------------------------
459 Procedure upd
460   (
461   p_program_membership_id        in number,
462   p_event_id                     in number           default hr_api.g_number,
463   p_program_event_id             in number           default hr_api.g_number,
464   p_object_version_number        in out number,
465   p_comments                     in varchar2         default hr_api.g_varchar2,
466   p_group_name                   in varchar2         default hr_api.g_varchar2,
467   p_required_flag                in varchar2         default hr_api.g_varchar2,
468   p_role                         in varchar2         default hr_api.g_varchar2,
469   p_sequence                     in number           default hr_api.g_number,
470   p_pmm_information_category     in varchar2         default hr_api.g_varchar2,
471   p_pmm_information1             in varchar2         default hr_api.g_varchar2,
472   p_pmm_information2             in varchar2         default hr_api.g_varchar2,
473   p_pmm_information3             in varchar2         default hr_api.g_varchar2,
474   p_pmm_information4             in varchar2         default hr_api.g_varchar2,
475   p_pmm_information5             in varchar2         default hr_api.g_varchar2,
476   p_pmm_information6             in varchar2         default hr_api.g_varchar2,
477   p_pmm_information7             in varchar2         default hr_api.g_varchar2,
478   p_pmm_information8             in varchar2         default hr_api.g_varchar2,
479   p_pmm_information9             in varchar2         default hr_api.g_varchar2,
480   p_pmm_information10            in varchar2         default hr_api.g_varchar2,
481   p_pmm_information11            in varchar2         default hr_api.g_varchar2,
482   p_pmm_information12            in varchar2         default hr_api.g_varchar2,
483   p_pmm_information13            in varchar2         default hr_api.g_varchar2,
484   p_pmm_information14            in varchar2         default hr_api.g_varchar2,
485   p_pmm_information15            in varchar2         default hr_api.g_varchar2,
486   p_pmm_information16            in varchar2         default hr_api.g_varchar2,
487   p_pmm_information17            in varchar2         default hr_api.g_varchar2,
488   p_pmm_information18            in varchar2         default hr_api.g_varchar2,
489   p_pmm_information19            in varchar2         default hr_api.g_varchar2,
490   p_pmm_information20            in varchar2         default hr_api.g_varchar2,
491   p_validate                     in boolean      default false
492   ) is
493 --
494   l_rec	  ota_pmm_shd.g_rec_type;
495   l_proc  varchar2(72) := g_package||'upd';
496 --
497 Begin
498   hr_utility.set_location('Entering:'||l_proc, 5);
499   --
500   -- Call conversion function to turn arguments into the
501   -- l_rec structure.
502   --
503   l_rec :=
504   ota_pmm_shd.convert_args
505   (
506   p_program_membership_id,
507   p_event_id,
508   p_program_event_id,
509   p_object_version_number,
510   p_comments,
511   p_group_name,
512   p_required_flag,
513   p_role,
514   p_sequence,
515   p_pmm_information_category,
516   p_pmm_information1,
517   p_pmm_information2,
518   p_pmm_information3,
519   p_pmm_information4,
520   p_pmm_information5,
521   p_pmm_information6,
522   p_pmm_information7,
523   p_pmm_information8,
524   p_pmm_information9,
525   p_pmm_information10,
526   p_pmm_information11,
527   p_pmm_information12,
528   p_pmm_information13,
529   p_pmm_information14,
530   p_pmm_information15,
531   p_pmm_information16,
532   p_pmm_information17,
533   p_pmm_information18,
534   p_pmm_information19,
535   p_pmm_information20
536   );
537   --
538   -- Having converted the arguments into the
539   -- plsql record structure we call the corresponding record
540   -- business process.
541   --
542   upd(l_rec, p_validate);
543   p_object_version_number := l_rec.object_version_number;
544   --
545   hr_utility.set_location(' Leaving:'||l_proc, 10);
546 End upd;
547 --
548 end ota_pmm_upd;