DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_CMR_UPD

Source


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