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