DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_IAS_UPD

Source


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