DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_CMM_UPD

Source


1 Package Body irc_cmm_upd as
2 /* $Header: ircmmrhi.pkb 120.2 2008/04/14 14:50:29 amikukum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_cmm_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_cmm_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_messages Row
69   --
70   update irc_comm_messages
71     set
72      communication_message_id        = p_rec.communication_message_id
73     ,parent_id                       = p_rec.parent_id
74     ,communication_topic_id          = p_rec.communication_topic_id
75     ,message_subject                 = p_rec.message_subject
76     ,message_body                    = p_rec.message_body
77     ,message_post_date               = p_rec.message_post_date
78     ,sender_type                     = p_rec.sender_type
79     ,sender_id                       = p_rec.sender_id
80     ,document_type                   = p_rec.document_type
81     ,document_id                     = p_rec.document_id
82     ,deleted_flag                    = p_rec.deleted_flag
83     ,object_version_number           = p_rec.object_version_number
84     where communication_message_id = p_rec.communication_message_id;
85   --
86   --
87   --
88   hr_utility.set_location(' Leaving:'||l_proc, 10);
89 --
90 Exception
91   When hr_api.check_integrity_violated Then
92     -- A check constraint has been violated
93     --
94     irc_cmm_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When hr_api.parent_integrity_violated Then
97     -- Parent integrity has been violated
98     --
99     irc_cmm_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When hr_api.unique_integrity_violated Then
102     -- Unique integrity has been violated
103     --
104     irc_cmm_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When Others Then
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_cmm_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_effective_date               in date
189   ,p_rec                          in irc_cmm_shd.g_rec_type
190   ) is
191 --
192   l_proc  varchar2(72) := g_package||'post_update';
193 --
194 Begin
195   hr_utility.set_location('Entering:'||l_proc, 5);
196   begin
197     --
198     irc_cmm_rku.after_update
199       (p_effective_date              => p_effective_date
200       ,p_communication_message_id
201       => p_rec.communication_message_id
202       ,p_parent_id
203       => p_rec.parent_id
204       ,p_communication_topic_id
205       => p_rec.communication_topic_id
206       ,p_message_subject
207       => p_rec.message_subject
208       ,p_message_body
209       => p_rec.message_body
210       ,p_message_post_date
211       => p_rec.message_post_date
212       ,p_sender_type
213       => p_rec.sender_type
214       ,p_sender_id
215       => p_rec.sender_id
216       ,p_document_type
217       => p_rec.document_type
218       ,p_document_id
219       => p_rec.document_id
220       ,p_deleted_flag
221       => p_rec.deleted_flag
222       ,p_object_version_number
223       => p_rec.object_version_number
224       ,p_parent_id_o
225       => irc_cmm_shd.g_old_rec.parent_id
226       ,p_communication_topic_id_o
227       => irc_cmm_shd.g_old_rec.communication_topic_id
228       ,p_message_subject_o
229       => irc_cmm_shd.g_old_rec.message_subject
230       ,p_message_body_o
231       => irc_cmm_shd.g_old_rec.message_body
232       ,p_message_post_date_o
233       => irc_cmm_shd.g_old_rec.message_post_date
234       ,p_sender_type_o
235       => irc_cmm_shd.g_old_rec.sender_type
236       ,p_sender_id_o
237       => irc_cmm_shd.g_old_rec.sender_id
238       ,p_document_type_o
239       => irc_cmm_shd.g_old_rec.document_type
240       ,p_document_id_o
241       => irc_cmm_shd.g_old_rec.document_id
242       ,p_deleted_flag_o
243       => irc_cmm_shd.g_old_rec.deleted_flag
244       ,p_object_version_number_o
245       => irc_cmm_shd.g_old_rec.object_version_number
246       );
247     --
248   exception
249     --
250     when hr_api.cannot_find_prog_unit then
251       --
252       hr_api.cannot_find_prog_unit_error
253         (p_module_name => 'IRC_COMM_MESSAGES'
254         ,p_hook_type   => 'AU');
255       --
256   end;
257   --
258   hr_utility.set_location(' Leaving:'||l_proc, 10);
259 End post_update;
260 --
261 -- ----------------------------------------------------------------------------
262 -- |-----------------------------< convert_defs >-----------------------------|
263 -- ----------------------------------------------------------------------------
264 -- {Start Of Comments}
265 --
266 -- Description:
267 --   The Convert_Defs procedure has one very important function:
268 --   It must return the record structure for the row with all system defaulted
269 --   values converted into its corresponding parameter value for update. When
270 --   we attempt to update a row through the Upd process , certain
271 --   parameters can be defaulted which enables flexibility in the calling of
272 --   the upd process (e.g. only attributes which need to be updated need to be
273 --   specified). For the upd process to determine which attributes
274 --   have NOT been specified we need to check if the parameter has a reserved
275 --   system default value. Therefore, for all parameters which have a
276 --   corresponding reserved system default mechanism specified we need to
277 --   check if a system default is being used. If a system default is being
278 --   used then we convert the defaulted value into its corresponding attribute
279 --   value held in the g_old_rec data structure.
280 --
281 -- Prerequisites:
282 --   This private function can only be called from the upd process.
283 --
284 -- In Parameters:
285 --   A Pl/Sql record structure.
286 --
287 -- Post Success:
288 --   The record structure will be returned with all system defaulted parameter
289 --   values converted into its current row attribute value.
290 --
291 -- Post Failure:
292 --   No direct error handling is required within this function. Any possible
293 --   errors within this procedure will be a PL/SQL value error due to
294 --   conversion of datatypes or data lengths.
295 --
296 -- Developer Implementation Notes:
297 --   None.
298 --
299 -- Access Status:
300 --   Internal Row Handler Use Only.
301 --
302 -- {End Of Comments}
303 -- ----------------------------------------------------------------------------
304 Procedure convert_defs
305   (p_rec in out nocopy irc_cmm_shd.g_rec_type
306   ) is
307 --
308 Begin
309   --
310   -- We must now examine each argument value in the
311   -- p_rec plsql record structure
312   -- to see if a system default is being used. If a system default
313   -- is being used then we must set to the 'current' argument value.
314   --
315   If (p_rec.parent_id = hr_api.g_number) then
316     p_rec.parent_id :=
317     irc_cmm_shd.g_old_rec.parent_id;
318   End If;
319   If (p_rec.communication_topic_id = hr_api.g_number) then
320     p_rec.communication_topic_id :=
321     irc_cmm_shd.g_old_rec.communication_topic_id;
322   End If;
323   If (p_rec.message_subject = hr_api.g_varchar2) then
324     p_rec.message_subject :=
325     irc_cmm_shd.g_old_rec.message_subject;
326   End If;
327   If (p_rec.message_body = hr_api.g_varchar2) then
328     p_rec.message_body :=
329     irc_cmm_shd.g_old_rec.message_body;
330   End If;
331   If (p_rec.message_post_date = hr_api.g_date) then
332     p_rec.message_post_date :=
333     irc_cmm_shd.g_old_rec.message_post_date;
334   End If;
335   If (p_rec.sender_type = hr_api.g_varchar2) then
336     p_rec.sender_type :=
337     irc_cmm_shd.g_old_rec.sender_type;
338   End If;
339   If (p_rec.sender_id = hr_api.g_number) then
340     p_rec.sender_id :=
341     irc_cmm_shd.g_old_rec.sender_id;
342   End If;
343   If (p_rec.document_type = hr_api.g_varchar2) then
344     p_rec.document_type :=
345     irc_cmm_shd.g_old_rec.document_type;
346   End If;
347   If (p_rec.document_id = hr_api.g_number) then
348     p_rec.document_id :=
349     irc_cmm_shd.g_old_rec.document_id;
350   End If;
351   If (p_rec.deleted_flag = hr_api.g_varchar2) then
352     p_rec.deleted_flag :=
353     irc_cmm_shd.g_old_rec.deleted_flag;
354   End If;
355   --
356 End convert_defs;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------------< upd >----------------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure upd
362   (p_effective_date               in date
363   ,p_rec                          in out nocopy irc_cmm_shd.g_rec_type
364   ) is
365 --
366   l_proc  varchar2(72) := g_package||'upd';
367 --
368 Begin
369   hr_utility.set_location('Entering:'||l_proc, 5);
370   --
371   -- We must lock the row which we need to update.
372   --
373   irc_cmm_shd.lck
374     (p_rec.communication_message_id
375     ,p_rec.object_version_number
376     );
377   --
378   -- 1. During an update system defaults are used to determine if
379   --    arguments have been defaulted or not. We must therefore
380   --    derive the full record structure values to be updated.
381   --
382   -- 2. Call the supporting update validate operations.
383   --
384   convert_defs(p_rec);
385   irc_cmm_bus.update_validate
386      (p_effective_date
387      ,p_rec
388      );
389   --
390   -- Call to raise any errors on multi-message list
391   hr_multi_message.end_validation_set;
392   --
393   -- Call the supporting pre-update operation
394   --
395   irc_cmm_upd.pre_update(p_rec);
396   --
397   -- Update the row.
398   --
399   irc_cmm_upd.update_dml(p_rec);
400   --
401   -- Call the supporting post-update operation
402   --
403   irc_cmm_upd.post_update
404      (p_effective_date
405      ,p_rec
406      );
407   --
408   -- Call to raise any errors on multi-message list
409   hr_multi_message.end_validation_set;
410 End upd;
411 --
412 -- ----------------------------------------------------------------------------
413 -- |---------------------------------< upd >----------------------------------|
414 -- ----------------------------------------------------------------------------
415 Procedure upd
416   (p_effective_date               in     date
417   ,p_communication_message_id     in     number
418   ,p_object_version_number        in out nocopy number
419   ,p_communication_topic_id       in     number    default hr_api.g_number
420   ,p_message_subject              in     varchar2  default hr_api.g_varchar2
421   ,p_message_post_date            in     date      default hr_api.g_date
422   ,p_sender_type                  in     varchar2  default hr_api.g_varchar2
423   ,p_sender_id                    in     number    default hr_api.g_number
424   ,p_parent_id                    in     number    default hr_api.g_number
425   ,p_message_body                 in     varchar2  default hr_api.g_varchar2
426   ,p_document_type                in     varchar2  default hr_api.g_varchar2
427   ,p_document_id                  in     number    default hr_api.g_number
428   ,p_deleted_flag                 in     varchar2  default hr_api.g_varchar2
429   ) is
430 --
431   l_rec   irc_cmm_shd.g_rec_type;
432   l_proc  varchar2(72) := g_package||'upd';
433 --
434 Begin
435   hr_utility.set_location('Entering:'||l_proc, 5);
436   --
437   -- Call conversion function to turn arguments into the
438   -- l_rec structure.
439   --
440   l_rec :=
441   irc_cmm_shd.convert_args
442   (p_communication_message_id
443   ,p_parent_id
444   ,p_communication_topic_id
445   ,p_message_subject
446   ,p_message_body
447   ,p_message_post_date
448   ,p_sender_type
449   ,p_sender_id
450   ,p_document_type
451   ,p_document_id
452   ,p_deleted_flag
453   ,p_object_version_number
454   );
455   --
456   -- Having converted the arguments into the
457   -- plsql record structure we call the corresponding record
458   -- business process.
459   --
460   irc_cmm_upd.upd
461      (p_effective_date
462      ,l_rec
463      );
464   p_object_version_number := l_rec.object_version_number;
465   --
466   hr_utility.set_location(' Leaving:'||l_proc, 10);
467 End upd;
468 --
469 end irc_cmm_upd;