DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_MGB_UPD

Source


1 Package Body pay_mgb_upd as
2 /* $Header: pymgbrhi.pkb 120.0 2005/05/29 06:45:44 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_mgb_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 nocopy pay_mgb_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   --
62   pay_mgb_shd.g_api_dml := true;  -- Set the api dml status
63   --
64   -- Update the pay_magnetic_blocks Row
65   --
66   update pay_magnetic_blocks
67   set
68   magnetic_block_id                 = p_rec.magnetic_block_id,
69   block_name                        = p_rec.block_name,
70   main_block_flag                   = p_rec.main_block_flag,
71   report_format                     = p_rec.report_format,
72   cursor_name                       = p_rec.cursor_name,
73   no_column_returned                = p_rec.no_column_returned
74   where magnetic_block_id = p_rec.magnetic_block_id;
75   --
76   pay_mgb_shd.g_api_dml := false;   -- Unset the api dml status
77   --
78   hr_utility.set_location(' Leaving:'||l_proc, 10);
79 --
80 Exception
81   When hr_api.check_integrity_violated Then
82     -- A check constraint has been violated
83     pay_mgb_shd.g_api_dml := false;   -- Unset the api dml status
84     pay_mgb_shd.constraint_error
85       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86   When hr_api.parent_integrity_violated Then
87     -- Parent integrity has been violated
88     pay_mgb_shd.g_api_dml := false;   -- Unset the api dml status
89     pay_mgb_shd.constraint_error
90       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91   When hr_api.unique_integrity_violated Then
92     -- Unique integrity has been violated
93     pay_mgb_shd.g_api_dml := false;   -- Unset the api dml status
94     pay_mgb_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When Others Then
97     pay_mgb_shd.g_api_dml := false;   -- Unset the api dml status
98     Raise;
99 End update_dml;
100 --
101 -- ----------------------------------------------------------------------------
102 -- |------------------------------< pre_update >------------------------------|
103 -- ----------------------------------------------------------------------------
104 -- {Start Of Comments}
105 --
106 -- Description:
107 --   This private procedure contains any processing which is required before
108 --   the update dml.
109 --
110 -- Pre Conditions:
111 --   This is an internal procedure which is called from the upd procedure.
112 --
113 -- In Arguments:
114 --   A Pl/Sql record structre.
115 --
116 -- Post Success:
117 --   Processing continues.
118 --
119 -- Post Failure:
120 --   If an error has occurred, an error message and exception will be raised
121 --   but not handled.
122 --
123 -- Developer Implementation Notes:
124 --   Any pre-processing required before the update dml is issued should be
125 --   coded within this procedure. It is important to note that any 3rd party
126 --   maintenance should be reviewed before placing in this procedure.
127 --
128 -- Access Status:
129 --   Internal Development Use Only.
130 --
131 -- {End Of Comments}
132 -- ----------------------------------------------------------------------------
133 Procedure pre_update(p_rec in pay_mgb_shd.g_rec_type) is
134 --
135   l_proc  varchar2(72) := g_package||'pre_update';
136 --
137 Begin
138   hr_utility.set_location('Entering:'||l_proc, 5);
139   --
140   hr_utility.set_location(' Leaving:'||l_proc, 10);
141 End pre_update;
142 --
143 -- ----------------------------------------------------------------------------
144 -- |-----------------------------< post_update >------------------------------|
145 -- ----------------------------------------------------------------------------
146 -- {Start Of Comments}
147 --
148 -- Description:
149 --   This private procedure contains any processing which is required after the
150 --   update dml.
151 --
152 -- Pre Conditions:
153 --   This is an internal procedure which is called from the upd procedure.
154 --
155 -- In Arguments:
156 --   A Pl/Sql record structre.
157 --
158 -- Post Success:
159 --   Processing continues.
160 --
161 -- Post Failure:
162 --   If an error has occurred, an error message and exception will be raised
163 --   but not handled.
164 --
165 -- Developer Implementation Notes:
166 --   Any post-processing required after the update dml is issued should be
167 --   coded within this procedure. It is important to note that any 3rd party
168 --   maintenance should be reviewed before placing in this procedure.
169 --
170 -- Access Status:
171 --   Internal Development Use Only.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure post_update(p_rec in pay_mgb_shd.g_rec_type) is
176 --
177   l_proc  varchar2(72) := g_package||'post_update';
178 --
179 Begin
180   hr_utility.set_location('Entering:'||l_proc, 5);
181   --
182   hr_utility.set_location(' Leaving:'||l_proc, 10);
183 End post_update;
184 --
185 -- ----------------------------------------------------------------------------
186 -- |-----------------------------< convert_defs >-----------------------------|
187 -- ----------------------------------------------------------------------------
188 -- {Start Of Comments}
189 --
190 -- Description:
191 --   The Convert_Defs function has one very important function:
192 --   It must return the record structure for the row with all system defaulted
193 --   values converted into its corresponding argument value for update. When
194 --   we attempt to update a row through the Upd business process , certain
195 --   arguments can be defaulted which enables flexibility in the calling of
196 --   the upd process (e.g. only attributes which need to be updated need to be
197 --   specified). For the upd business process to determine which attributes
198 --   have NOT been specified we need to check if the argument has a reserved
199 --   system default value. Therefore, for all attributes which have a
200 --   corresponding reserved system default mechanism specified we need to
201 --   check if a system default is being used. If a system default is being
202 --   used then we convert the defaulted value into its corresponding attribute
203 --   value held in the g_old_rec data structure.
204 --
205 -- Pre Conditions:
206 --   This private function can only be called from the upd process.
207 --
208 -- In Arguments:
209 --   A Pl/Sql record structre.
210 --
211 -- Post Success:
212 --   The record structure will be returned with all system defaulted argument
213 --   values converted into its current row attribute value.
214 --
215 -- Post Failure:
216 --   No direct error handling is required within this function. Any possible
217 --   errors within this function will be a PL/SQL value error due to conversion
218 --   of datatypes or data lengths.
219 --
220 -- Developer Implementation Notes:
221 --   None.
222 --
223 -- Access Status:
224 --   Internal Development Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Function convert_defs(p_rec in out nocopy pay_mgb_shd.g_rec_type)
229          Return pay_mgb_shd.g_rec_type is
230 --
231   l_proc  varchar2(72) := g_package||'convert_defs';
232 --
233 Begin
234   --
235   hr_utility.set_location('Entering:'||l_proc, 5);
236   --
237   -- We must now examine each argument value in the
238   -- p_rec plsql record structure
239   -- to see if a system default is being used. If a system default
240   -- is being used then we must set to the 'current' argument value.
241   --
242   If (p_rec.block_name = hr_api.g_varchar2) then
243     p_rec.block_name :=
244     pay_mgb_shd.g_old_rec.block_name;
245   End If;
246   If (p_rec.main_block_flag = hr_api.g_varchar2) then
247     p_rec.main_block_flag :=
248     pay_mgb_shd.g_old_rec.main_block_flag;
249   End If;
250   If (p_rec.report_format = hr_api.g_varchar2) then
251     p_rec.report_format :=
252     pay_mgb_shd.g_old_rec.report_format;
253   End If;
254   If (p_rec.cursor_name = hr_api.g_varchar2) then
255     p_rec.cursor_name :=
256     pay_mgb_shd.g_old_rec.cursor_name;
257   End If;
258   If (p_rec.no_column_returned = hr_api.g_number) then
259     p_rec.no_column_returned :=
260     pay_mgb_shd.g_old_rec.no_column_returned;
261   End If;
262   --
263   -- Return the plsql record structure.
264   --
265   hr_utility.set_location(' Leaving:'||l_proc, 10);
266   Return(p_rec);
267 --
268 End convert_defs;
269 --
270 -- ----------------------------------------------------------------------------
271 -- |---------------------------------< upd >----------------------------------|
272 -- ----------------------------------------------------------------------------
273 Procedure upd
274   (
275   p_rec        in out nocopy pay_mgb_shd.g_rec_type,
276   p_validate   in     boolean default false
277   ) is
278 --
279   l_proc  varchar2(72) := g_package||'upd';
280 --
281 Begin
282   hr_utility.set_location('Entering:'||l_proc, 5);
283   --
284   -- Determine if the business process is to be validated.
285   --
286   If p_validate then
287     --
288     -- Issue the savepoint.
289     --
290     SAVEPOINT upd_pay_mgb;
291   End If;
292   --
293   -- We must lock the row which we need to update.
294   --
295   pay_mgb_shd.lck
296         (
297         p_rec.magnetic_block_id
298         );
299   --
300   -- 1. During an update system defaults are used to determine if
301   --    arguments have been defaulted or not. We must therefore
302   --    derive the full record structure values to be updated.
303   --
304   -- 2. Call the supporting update validate operations.
305   --
306   pay_mgb_bus.update_validate(convert_defs(p_rec));
307   --
308   -- Call the supporting pre-update operation
309   --
310   pre_update(p_rec);
311   --
312   -- Update the row.
313   --
314   update_dml(p_rec);
315   --
316   -- Call the supporting post-update operation
317   --
318   post_update(p_rec);
319   --
320   -- If we are validating then raise the Validate_Enabled exception
321   --
322   If p_validate then
323     Raise HR_Api.Validate_Enabled;
324   End If;
325   --
326   hr_utility.set_location(' Leaving:'||l_proc, 10);
327 Exception
328   When HR_Api.Validate_Enabled Then
329     --
330     -- As the Validate_Enabled exception has been raised
331     -- we must rollback to the savepoint
332     --
333     ROLLBACK TO upd_pay_mgb;
334 End upd;
335 --
336 -- ----------------------------------------------------------------------------
337 -- |---------------------------------< upd >----------------------------------|
338 -- ----------------------------------------------------------------------------
339 Procedure upd
340   (
341   p_magnetic_block_id            in number,
342   p_block_name                   in varchar2         default hr_api.g_varchar2,
343   p_main_block_flag              in varchar2         default hr_api.g_varchar2,
344   p_report_format                in varchar2         default hr_api.g_varchar2,
345   p_cursor_name                  in varchar2         default hr_api.g_varchar2,
346   p_no_column_returned           in number           default hr_api.g_number,
347   p_validate                     in boolean      default false
348   ) is
349 --
350   l_rec   pay_mgb_shd.g_rec_type;
351   l_proc  varchar2(72) := g_package||'upd';
352 --
353 Begin
354   hr_utility.set_location('Entering:'||l_proc, 5);
355   --
356   -- Call conversion function to turn arguments into the
357   -- l_rec structure.
358   --
359   l_rec :=
360   pay_mgb_shd.convert_args
361   (
362   p_magnetic_block_id,
363   p_block_name,
364   p_main_block_flag,
365   p_report_format,
366   p_cursor_name,
367   p_no_column_returned
368   );
369   --
370   -- Having converted the arguments into the
371   -- plsql record structure we call the corresponding record
372   -- business process.
373   --
374   upd(l_rec, p_validate);
375   --
376   --
377   hr_utility.set_location(' Leaving:'||l_proc, 10);
378 End upd;
379 --
380 end pay_mgb_upd;