DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FTU_UPD

Source


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