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