DBA Data[Home] [Help]

PACKAGE BODY: APPS.SSP_STP_UPD

Source


1 Package Body ssp_stp_upd as
2 /* $Header: spstprhi.pkb 115.3 99/10/13 01:54:40 porting ship  $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ssp_stp_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 -- Pre Conditions:
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 Table Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out ssp_stp_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   ssp_stp_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ssp_stoppages Row
68   --
69   update ssp_stoppages
70   set
71   stoppage_id                       = p_rec.stoppage_id,
72   object_version_number             = p_rec.object_version_number,
73   absence_attendance_id             = p_rec.absence_attendance_id,
74   maternity_id                      = p_rec.maternity_id,
75   reason_id                         = p_rec.reason_id,
76   user_entered                      = p_rec.user_entered,
77   override_stoppage                 = p_rec.override_stoppage,
78   employee_notified                 = p_rec.employee_notified,
79   withhold_from                     = p_rec.withhold_from,
80   withhold_to                       = p_rec.withhold_to
81   where stoppage_id = p_rec.stoppage_id;
82   --
83   ssp_stp_shd.g_api_dml := false;   -- Unset the api dml status
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     ssp_stp_shd.g_api_dml := false;   -- Unset the api dml status
91     ssp_stp_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     ssp_stp_shd.g_api_dml := false;   -- Unset the api dml status
96     ssp_stp_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     ssp_stp_shd.g_api_dml := false;   -- Unset the api dml status
101     ssp_stp_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When Others Then
104     ssp_stp_shd.g_api_dml := false;   -- Unset the api dml status
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 -- Pre Conditions:
118 --   This is an internal procedure which is called from the upd procedure.
119 --
120 -- In Parameters:
121 --   A Pl/Sql record structre.
122 --
123 -- Post Success:
124 --   Processing continues.
125 --
126 -- Post Failure:
127 --   If an error has occurred, an error message and exception will 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 Table Handler Use Only.
137 --
138 -- {End Of Comments}
139 -- ----------------------------------------------------------------------------
140 Procedure pre_update(p_rec in ssp_stp_shd.g_rec_type) 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 the
157 --   update dml.
158 --
159 -- Pre Conditions:
160 --   This is an internal procedure which is called from the upd procedure.
161 --
162 -- In Parameters:
163 --   A Pl/Sql record structre.
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 Table Handler Use Only.
179 --
180 -- {End Of Comments}
181 -- ----------------------------------------------------------------------------
182 Procedure post_update(p_rec in ssp_stp_shd.g_rec_type) is
183 --
184   l_proc  varchar2(72) := g_package||'post_update';
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   hr_utility.set_location(' Leaving:'||l_proc, 10);
190 End post_update;
191 --
192 -- ----------------------------------------------------------------------------
193 -- |-----------------------------< convert_defs >-----------------------------|
194 -- ----------------------------------------------------------------------------
195 -- {Start Of Comments}
196 --
197 -- Description:
198 --   The Convert_Defs procedure has one very important function:
199 --   It must return the record structure for the row with all system defaulted
200 --   values converted into its corresponding parameter value for update. When
201 --   we attempt to update a row through the Upd process , certain
202 --   parameters can be defaulted which enables flexibility in the calling of
203 --   the upd process (e.g. only attributes which need to be updated need to be
204 --   specified). For the upd process to determine which attributes
205 --   have NOT been specified we need to check if the parameter has a reserved
206 --   system default value. Therefore, for all parameters which have a
207 --   corresponding reserved system default mechanism specified we need to
208 --   check if a system default is being used. If a system default is being
209 --   used then we convert the defaulted value into its corresponding attribute
210 --   value held in the g_old_rec data structure.
211 --
212 -- Pre Conditions:
213 --   This private function can only be called from the upd process.
214 --
215 -- In Parameters:
216 --   A Pl/Sql record structre.
217 --
218 -- Post Success:
219 --   The record structure will be returned with all system defaulted parameter
220 --   values converted into its current row attribute value.
221 --
222 -- Post Failure:
223 --   No direct error handling is required within this function. Any possible
224 --   errors within this procedure will be a PL/SQL value error due to conversion
225 
226 --   of datatypes or data lengths.
227 --
228 -- Developer Implementation Notes:
229 --   None.
230 --
231 -- Access Status:
232 --   Internal Table Handler Use Only.
233 --
234 -- {End Of Comments}
235 -- ----------------------------------------------------------------------------
236 Procedure convert_defs(p_rec in out ssp_stp_shd.g_rec_type) is
237 --
238   l_proc  varchar2(72) := g_package||'convert_defs';
239 --
240 Begin
241   --
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   -- We must now examine each argument value in the
245   -- p_rec plsql record structure
246   -- to see if a system default is being used. If a system default
247   -- is being used then we must set to the 'current' argument value.
248   --
249   If (p_rec.absence_attendance_id = hr_api.g_number) then
250     p_rec.absence_attendance_id :=
251     ssp_stp_shd.g_old_rec.absence_attendance_id;
252   End If;
253   If (p_rec.maternity_id = hr_api.g_number) then
254     p_rec.maternity_id :=
255     ssp_stp_shd.g_old_rec.maternity_id;
256   End If;
257   If (p_rec.reason_id = hr_api.g_number) then
258     p_rec.reason_id :=
259     ssp_stp_shd.g_old_rec.reason_id;
260   End If;
261   If (p_rec.user_entered = hr_api.g_varchar2) then
262     p_rec.user_entered :=
263     ssp_stp_shd.g_old_rec.user_entered;
264   End If;
265   If (p_rec.override_stoppage = hr_api.g_varchar2) then
266     p_rec.override_stoppage :=
267     ssp_stp_shd.g_old_rec.override_stoppage;
268   End If;
269   If (p_rec.employee_notified = hr_api.g_varchar2) then
270     p_rec.employee_notified :=
271     ssp_stp_shd.g_old_rec.employee_notified;
272   End If;
273   If (p_rec.withhold_from = hr_api.g_date) then
274     p_rec.withhold_from :=
275     ssp_stp_shd.g_old_rec.withhold_from;
276   End If;
277   If (p_rec.withhold_to = hr_api.g_date) then
278     p_rec.withhold_to :=
279     ssp_stp_shd.g_old_rec.withhold_to;
280   End If;
281   --
282   hr_utility.set_location(' Leaving:'||l_proc, 10);
283 --
284 End convert_defs;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |---------------------------------< upd >----------------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure upd
290   (
291   p_rec        in out ssp_stp_shd.g_rec_type,
292   p_validate   in     boolean default false
293   ) is
294 --
295   l_proc  varchar2(72) := g_package||'upd';
296 --
297 Begin
298   hr_utility.set_location('Entering:'||l_proc, 5);
299   --
300   -- Determine if the business process is to be validated.
301   --
302   If p_validate then
303     --
304     -- Issue the savepoint.
305     --
306     SAVEPOINT upd_ssp_stp;
307   End If;
308   --
309   -- We must lock the row which we need to update.
310   --
311   ssp_stp_shd.lck
312 	(
313 	p_rec.stoppage_id,
314 	p_rec.object_version_number
315 	);
316   --
317   -- 1. During an update system defaults are used to determine if
318   --    arguments have been defaulted or not. We must therefore
319   --    derive the full record structure values to be updated.
320   --
321   -- 2. Call the supporting update validate operations.
322   --
323   convert_defs(p_rec);
324   ssp_stp_bus.update_validate(p_rec);
325   --
326   -- Call the supporting pre-update operation
327   --
328   pre_update(p_rec);
329   --
330   -- Update the row.
331   --
332   update_dml(p_rec);
333   --
334   -- Call the supporting post-update operation
335   --
336   post_update(p_rec);
337   --
338   -- If we are validating then raise the Validate_Enabled exception
339   --
340   If p_validate then
341     Raise HR_Api.Validate_Enabled;
342   End If;
343   --
344   hr_utility.set_location(' Leaving:'||l_proc, 10);
345 Exception
346   When HR_Api.Validate_Enabled Then
347     --
348     -- As the Validate_Enabled exception has been raised
349     -- we must rollback to the savepoint
350     --
351     ROLLBACK TO upd_ssp_stp;
352 End upd;
353 --
354 -- ----------------------------------------------------------------------------
355 -- |---------------------------------< upd >----------------------------------|
356 -- ----------------------------------------------------------------------------
357 Procedure upd
358   (
359   p_stoppage_id                  in number,
360   p_object_version_number        in out number,
361   p_absence_attendance_id        in number           default hr_api.g_number,
362   p_maternity_id                 in number           default hr_api.g_number,
363   p_reason_id                    in number           default hr_api.g_number,
364   p_user_entered                 in varchar2         default hr_api.g_varchar2,
365   p_override_stoppage            in varchar2         default hr_api.g_varchar2,
366   p_employee_notified            in varchar2         default hr_api.g_varchar2,
367   p_withhold_from                in date             default hr_api.g_date,
368   p_withhold_to                  in date             default hr_api.g_date,
369   p_validate                     in boolean      default false
370   ) is
371 --
372   l_rec	  ssp_stp_shd.g_rec_type;
373   l_proc  varchar2(72) := g_package||'upd';
374 --
375 Begin
376   hr_utility.set_location('Entering:'||l_proc, 5);
377   --
378   -- Call conversion function to turn arguments into the
379   -- l_rec structure.
380   --
381   l_rec :=
382   ssp_stp_shd.convert_args
383   (
384   p_stoppage_id,
385   p_object_version_number,
386   p_absence_attendance_id,
387   p_maternity_id,
388   p_reason_id,
389   p_user_entered,
390   p_override_stoppage,
391   p_employee_notified,
392   p_withhold_from,
393   p_withhold_to
394   );
395   --
396   -- Having converted the arguments into the
397   -- plsql record structure we call the corresponding record
398   -- business process.
399   --
400   upd(l_rec, p_validate);
401   p_object_version_number := l_rec.object_version_number;
402   --
403   hr_utility.set_location(' Leaving:'||l_proc, 10);
404 End upd;
405 --
406 end ssp_stp_upd;