1 Package Body pqp_aad_upd as
2 /* $Header: pqaadrhi.pkb 115.5 2003/02/17 22:13:35 tmehra ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqp_aad_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(p_rec in out nocopy pqp_aad_shd.g_rec_type) is
55 --
56 l_proc varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59 hr_utility.set_location('Entering:'||l_proc, 5);
60 --
61 -- Increment the object version
62 --
63 p_rec.object_version_number := p_rec.object_version_number + 1;
64 --
65 pqp_aad_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the pqp_analyzed_alien_data Row
68 --
69 update pqp_analyzed_alien_data
70 set
71 analyzed_data_id = p_rec.analyzed_data_id,
72 assignment_id = p_rec.assignment_id,
73 data_source = p_rec.data_source,
74 tax_year = p_rec.tax_year,
75 current_residency_status = p_rec.current_residency_status,
76 nra_to_ra_date = p_rec.nra_to_ra_date,
77 target_departure_date = p_rec.target_departure_date,
78 tax_residence_country_code = p_rec.tax_residence_country_code,
79 treaty_info_update_date = p_rec.treaty_info_update_date,
80 number_of_days_in_usa = p_rec.number_of_days_in_usa,
81 withldg_allow_eligible_flag = p_rec.withldg_allow_eligible_flag,
82 ra_effective_date = p_rec.ra_effective_date,
83 record_source = p_rec.record_source,
84 visa_type = p_rec.visa_type,
85 j_sub_type = p_rec.j_sub_type,
86 primary_activity = p_rec.primary_activity,
87 non_us_country_code = p_rec.non_us_country_code,
88 citizenship_country_code = p_rec.citizenship_country_code,
89 object_version_number = p_rec.object_version_number ,
90 date_8233_signed = p_rec.date_8233_signed,
91 date_w4_signed = p_rec.date_w4_signed
92 where analyzed_data_id = p_rec.analyzed_data_id;
93 --
94 pqp_aad_shd.g_api_dml := false; -- Unset the api dml status
95 --
96 hr_utility.set_location(' Leaving:'||l_proc, 10);
97 --
98 Exception
99 When hr_api.check_integrity_violated Then
100 -- A check constraint has been violated
101 pqp_aad_shd.g_api_dml := false; -- Unset the api dml status
102 pqp_aad_shd.constraint_error
103 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104 When hr_api.parent_integrity_violated Then
105 -- Parent integrity has been violated
106 pqp_aad_shd.g_api_dml := false; -- Unset the api dml status
107 pqp_aad_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When hr_api.unique_integrity_violated Then
110 -- Unique integrity has been violated
111 pqp_aad_shd.g_api_dml := false; -- Unset the api dml status
112 pqp_aad_shd.constraint_error
113 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
114 When Others Then
115 pqp_aad_shd.g_api_dml := false; -- Unset the api dml status
116 Raise;
117 End update_dml;
118 --
119 -- ----------------------------------------------------------------------------
120 -- |------------------------------< pre_update >------------------------------|
121 -- ----------------------------------------------------------------------------
122 -- {Start Of Comments}
123 --
124 -- Description:
125 -- This private procedure contains any processing which is required before
126 -- the update dml.
127 --
128 -- Prerequisites:
129 -- This is an internal procedure which is called from the upd procedure.
130 --
131 -- In Parameters:
132 -- A Pl/Sql record structre.
133 --
134 -- Post Success:
135 -- Processing continues.
136 --
137 -- Post Failure:
138 -- If an error has occurred, an error message and exception will be raised
139 -- but not handled.
140 --
141 -- Developer Implementation Notes:
142 -- Any pre-processing required before the update dml is issued should be
143 -- coded within this procedure. It is important to note that any 3rd party
144 -- maintenance should be reviewed before placing in this procedure.
145 --
146 -- Access Status:
147 -- Internal Row Handler Use Only.
148 --
149 -- {End Of Comments}
150 -- ----------------------------------------------------------------------------
151 Procedure pre_update(p_rec in pqp_aad_shd.g_rec_type) is
152 --
153 l_proc varchar2(72) := g_package||'pre_update';
154 --
155 Begin
156 hr_utility.set_location('Entering:'||l_proc, 5);
157 --
158 hr_utility.set_location(' Leaving:'||l_proc, 10);
159 End pre_update;
160 --
161 -- ----------------------------------------------------------------------------
162 -- |-----------------------------< post_update >------------------------------|
163 -- ----------------------------------------------------------------------------
164 -- {Start Of Comments}
165 --
166 -- Description:
167 -- This private procedure contains any processing which is required after the
168 -- update dml.
169 --
170 -- Prerequisites:
171 -- This is an internal procedure which is called from the upd procedure.
172 --
173 -- In Parameters:
174 -- A Pl/Sql record structre.
175 --
176 -- Post Success:
177 -- Processing continues.
178 --
179 -- Post Failure:
180 -- If an error has occurred, an error message and exception will be raised
181 -- but not handled.
182 --
183 -- Developer Implementation Notes:
184 -- Any post-processing required after the update dml is issued should be
185 -- coded within this procedure. It is important to note that any 3rd party
186 -- maintenance should be reviewed before placing in this procedure.
187 --
188 -- Access Status:
189 -- Internal Row Handler Use Only.
190 --
191 -- {End Of Comments}
192 -- ----------------------------------------------------------------------------
193 Procedure post_update(
194 p_effective_date in date,p_rec in pqp_aad_shd.g_rec_type) is
195 --
196 l_proc varchar2(72) := g_package||'post_update';
197 --
198 Begin
199 hr_utility.set_location('Entering:'||l_proc, 5);
200 --
201 --
202 -- Start of API User Hook for post_update.
203 --
204 begin
205 --
206 pqp_aad_rku.after_update
207 (
208 p_analyzed_data_id =>p_rec.analyzed_data_id
209 ,p_assignment_id =>p_rec.assignment_id
210 ,p_data_source =>p_rec.data_source
211 ,p_tax_year =>p_rec.tax_year
212 ,p_current_residency_status =>p_rec.current_residency_status
213 ,p_nra_to_ra_date =>p_rec.nra_to_ra_date
214 ,p_target_departure_date =>p_rec.target_departure_date
215 ,p_tax_residence_country_code =>p_rec.tax_residence_country_code
216 ,p_treaty_info_update_date =>p_rec.treaty_info_update_date
217 ,p_number_of_days_in_usa =>p_rec.number_of_days_in_usa
218 ,p_withldg_allow_eligible_flag =>p_rec.withldg_allow_eligible_flag
219 ,p_ra_effective_date =>p_rec.ra_effective_date
220 ,p_record_source =>p_rec.record_source
221 ,p_visa_type =>p_rec.visa_type
222 ,p_j_sub_type =>p_rec.j_sub_type
223 ,p_primary_activity =>p_rec.primary_activity
224 ,p_non_us_country_code =>p_rec.non_us_country_code
225 ,p_citizenship_country_code =>p_rec.citizenship_country_code
226 ,p_object_version_number =>p_rec.object_version_number
227 ,p_effective_date =>p_effective_date
228 ,p_date_8233_signed =>p_rec.date_8233_signed
229 ,p_date_w4_signed =>p_rec.date_w4_signed
230 ,p_assignment_id_o =>pqp_aad_shd.g_old_rec.assignment_id
231 ,p_data_source_o =>pqp_aad_shd.g_old_rec.data_source
232 ,p_tax_year_o =>pqp_aad_shd.g_old_rec.tax_year
233 ,p_current_residency_status_o =>pqp_aad_shd.g_old_rec.current_residency_status
234 ,p_nra_to_ra_date_o =>pqp_aad_shd.g_old_rec.nra_to_ra_date
235 ,p_target_departure_date_o =>pqp_aad_shd.g_old_rec.target_departure_date
236 ,p_tax_residence_country_code_o =>pqp_aad_shd.g_old_rec.tax_residence_country_code
237 ,p_treaty_info_update_date_o =>pqp_aad_shd.g_old_rec.treaty_info_update_date
238 ,p_number_of_days_in_usa_o =>pqp_aad_shd.g_old_rec.number_of_days_in_usa
239 ,p_withldg_allow_eligible_fla_o =>pqp_aad_shd.g_old_rec.withldg_allow_eligible_flag
240 ,p_ra_effective_date_o =>pqp_aad_shd.g_old_rec.ra_effective_date
241 ,p_record_source_o =>pqp_aad_shd.g_old_rec.record_source
242 ,p_visa_type_o =>pqp_aad_shd.g_old_rec.visa_type
243 ,p_j_sub_type_o =>pqp_aad_shd.g_old_rec.j_sub_type
244 ,p_primary_activity_o =>pqp_aad_shd.g_old_rec.primary_activity
245 ,p_non_us_country_code_o =>pqp_aad_shd.g_old_rec.non_us_country_code
246 ,p_citizenship_country_code_o =>pqp_aad_shd.g_old_rec.citizenship_country_code
247 ,p_object_version_number_o =>pqp_aad_shd.g_old_rec.object_version_number
248 ,p_date_8233_signed_o =>pqp_aad_shd.g_old_rec.date_8233_signed
249 ,p_date_w4_signed_o =>pqp_aad_shd.g_old_rec.date_w4_signed
250 );
251 --
252 exception
253 --
254 when hr_api.cannot_find_prog_unit then
255 --
256 hr_api.cannot_find_prog_unit_error
257 (p_module_name => 'PQP_ANALYZED_ALIEN_DATA'
258 ,p_hook_type => 'AU');
259 --
260 end;
261 --
262 -- End of API User Hook for post_update.
263 --
264 --
265 hr_utility.set_location(' Leaving:'||l_proc, 10);
266 End post_update;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |-----------------------------< convert_defs >-----------------------------|
270 -- ----------------------------------------------------------------------------
271 -- {Start Of Comments}
272 --
273 -- Description:
274 -- The Convert_Defs procedure has one very important function:
275 -- It must return the record structure for the row with all system defaulted
276 -- values converted into its corresponding parameter value for update. When
277 -- we attempt to update a row through the Upd process , certain
278 -- parameters can be defaulted which enables flexibility in the calling of
279 -- the upd process (e.g. only attributes which need to be updated need to be
280 -- specified). For the upd process to determine which attributes
281 -- have NOT been specified we need to check if the parameter has a reserved
282 -- system default value. Therefore, for all parameters which have a
283 -- corresponding reserved system default mechanism specified we need to
284 -- check if a system default is being used. If a system default is being
285 -- used then we convert the defaulted value into its corresponding attribute
286 -- value held in the g_old_rec data structure.
287 --
288 -- Prerequisites:
289 -- This private function can only be called from the upd process.
290 --
291 -- In Parameters:
292 -- A Pl/Sql record structre.
293 --
294 -- Post Success:
295 -- The record structure will be returned with all system defaulted parameter
296 -- values converted into its current row attribute value.
297 --
298 -- Post Failure:
299 -- No direct error handling is required within this function. Any possible
300 -- errors within this procedure will be a PL/SQL value error due to conversion
301 -- of datatypes or data lengths.
302 --
303 -- Developer Implementation Notes:
304 -- None.
305 --
306 -- Access Status:
307 -- Internal Row Handler Use Only.
308 --
309 -- {End Of Comments}
310 -- ----------------------------------------------------------------------------
311 Procedure convert_defs(p_rec in out nocopy pqp_aad_shd.g_rec_type) is
312 --
313 l_proc varchar2(72) := g_package||'convert_defs';
314 --
315 Begin
316 --
317 hr_utility.set_location('Entering:'||l_proc, 5);
318 --
319 -- We must now examine each argument value in the
320 -- p_rec plsql record structure
321 -- to see if a system default is being used. If a system default
322 -- is being used then we must set to the 'current' argument value.
323 --
324 If (p_rec.assignment_id = hr_api.g_number) then
325 p_rec.assignment_id :=
326 pqp_aad_shd.g_old_rec.assignment_id;
327 End If;
328 If (p_rec.data_source = hr_api.g_varchar2) then
329 p_rec.data_source :=
330 pqp_aad_shd.g_old_rec.data_source;
331 End If;
332 If (p_rec.tax_year = hr_api.g_number) then
333 p_rec.tax_year :=
334 pqp_aad_shd.g_old_rec.tax_year;
335 End If;
336 If (p_rec.current_residency_status = hr_api.g_varchar2) then
337 p_rec.current_residency_status :=
338 pqp_aad_shd.g_old_rec.current_residency_status;
339 End If;
340 If (p_rec.nra_to_ra_date = hr_api.g_date) then
341 p_rec.nra_to_ra_date :=
342 pqp_aad_shd.g_old_rec.nra_to_ra_date;
343 End If;
344 If (p_rec.target_departure_date = hr_api.g_date) then
345 p_rec.target_departure_date :=
346 pqp_aad_shd.g_old_rec.target_departure_date;
347 End If;
348 If (p_rec.tax_residence_country_code = hr_api.g_varchar2) then
349 p_rec.tax_residence_country_code :=
350 pqp_aad_shd.g_old_rec.tax_residence_country_code;
351 End If;
352 If (p_rec.treaty_info_update_date = hr_api.g_date) then
353 p_rec.treaty_info_update_date :=
354 pqp_aad_shd.g_old_rec.treaty_info_update_date;
355 End If;
356 If (p_rec.number_of_days_in_usa = hr_api.g_number) then
357 p_rec.number_of_days_in_usa :=
358 pqp_aad_shd.g_old_rec.number_of_days_in_usa;
359 End If;
360 If (p_rec.withldg_allow_eligible_flag = hr_api.g_varchar2) then
361 p_rec.withldg_allow_eligible_flag :=
362 pqp_aad_shd.g_old_rec.withldg_allow_eligible_flag;
363 End If;
364 If (p_rec.ra_effective_date = hr_api.g_date) then
365 p_rec.ra_effective_date :=
366 pqp_aad_shd.g_old_rec.ra_effective_date;
367 End If;
368 If (p_rec.record_source = hr_api.g_varchar2) then
369 p_rec.record_source :=
370 pqp_aad_shd.g_old_rec.record_source;
371 End If;
372 If (p_rec.visa_type = hr_api.g_varchar2) then
373 p_rec.visa_type :=
374 pqp_aad_shd.g_old_rec.visa_type;
375 End If;
376 If (p_rec.j_sub_type = hr_api.g_varchar2) then
377 p_rec.j_sub_type :=
378 pqp_aad_shd.g_old_rec.j_sub_type;
379 End If;
380 If (p_rec.primary_activity = hr_api.g_varchar2) then
381 p_rec.primary_activity :=
382 pqp_aad_shd.g_old_rec.primary_activity;
383 End If;
384 If (p_rec.non_us_country_code = hr_api.g_varchar2) then
385 p_rec.non_us_country_code :=
386 pqp_aad_shd.g_old_rec.non_us_country_code;
387 End If;
388 If (p_rec.citizenship_country_code = hr_api.g_varchar2) then
389 p_rec.citizenship_country_code :=
390 pqp_aad_shd.g_old_rec.citizenship_country_code;
391 End If;
392 If (p_rec.date_8233_signed = hr_api.g_date) then
393 p_rec.date_8233_signed :=
394 pqp_aad_shd.g_old_rec.date_8233_signed;
395 End If;
396 If (p_rec.date_w4_signed = hr_api.g_date) then
397 p_rec.date_w4_signed :=
398 pqp_aad_shd.g_old_rec.date_w4_signed;
399 End If;
400
401 --
402 hr_utility.set_location(' Leaving:'||l_proc, 10);
403 --
404 End convert_defs;
405 --
406 -- ----------------------------------------------------------------------------
407 -- |---------------------------------< upd >----------------------------------|
408 -- ----------------------------------------------------------------------------
409 Procedure upd
410 (
411 p_effective_date in date,
412 p_rec in out nocopy pqp_aad_shd.g_rec_type
413 ) is
414 --
415 l_proc varchar2(72) := g_package||'upd';
416 --
417 Begin
418 hr_utility.set_location('Entering:'||l_proc, 5);
419 --
420 -- We must lock the row which we need to update.
421 --
422 pqp_aad_shd.lck
423 (
424 p_rec.analyzed_data_id,
425 p_rec.object_version_number
426 );
427 --
428 -- 1. During an update system defaults are used to determine if
429 -- arguments have been defaulted or not. We must therefore
430 -- derive the full record structure values to be updated.
431 --
432 -- 2. Call the supporting update validate operations.
433 --
434 convert_defs(p_rec);
435 pqp_aad_bus.update_validate(p_rec
436 ,p_effective_date);
437 --
438 -- Call the supporting pre-update operation
439 --
440 pre_update(p_rec);
441 --
442 -- Update the row.
443 --
444 update_dml(p_rec);
445 --
446 -- Call the supporting post-update operation
447 --
448 post_update(
449 p_effective_date,p_rec);
450 End upd;
451 --
452 -- ----------------------------------------------------------------------------
453 -- |---------------------------------< upd >----------------------------------|
454 -- ----------------------------------------------------------------------------
455 Procedure upd
456 (
457 p_effective_date in date,
458 p_analyzed_data_id in number,
459 p_assignment_id in number default hr_api.g_number,
460 p_data_source in varchar2 default hr_api.g_varchar2,
461 p_tax_year in number default hr_api.g_number,
462 p_current_residency_status in varchar2 default hr_api.g_varchar2,
463 p_nra_to_ra_date in date default hr_api.g_date,
464 p_target_departure_date in date default hr_api.g_date,
465 p_tax_residence_country_code in varchar2 default hr_api.g_varchar2,
466 p_treaty_info_update_date in date default hr_api.g_date,
467 p_number_of_days_in_usa in number default hr_api.g_number,
468 p_withldg_allow_eligible_flag in varchar2 default hr_api.g_varchar2,
469 p_ra_effective_date in date default hr_api.g_date,
470 p_record_source in varchar2 default hr_api.g_varchar2,
471 p_visa_type in varchar2 default hr_api.g_varchar2,
472 p_j_sub_type in varchar2 default hr_api.g_varchar2,
473 p_primary_activity in varchar2 default hr_api.g_varchar2,
474 p_non_us_country_code in varchar2 default hr_api.g_varchar2,
475 p_citizenship_country_code in varchar2 default hr_api.g_varchar2,
476 p_object_version_number in out nocopy number ,
477 p_date_8233_signed in date default hr_api.g_date ,
478 p_date_w4_signed in date default hr_api.g_date
479 ) is
480 --
481 l_rec pqp_aad_shd.g_rec_type;
482 l_proc varchar2(72) := g_package||'upd';
483 --
484 Begin
485 hr_utility.set_location('Entering:'||l_proc, 5);
486 --
487 -- Call conversion function to turn arguments into the
488 -- l_rec structure.
489 --
490 l_rec :=
491 pqp_aad_shd.convert_args
492 (
493 p_analyzed_data_id,
494 p_assignment_id,
495 p_data_source,
496 p_tax_year,
497 p_current_residency_status,
498 p_nra_to_ra_date,
499 p_target_departure_date,
500 p_tax_residence_country_code,
501 p_treaty_info_update_date,
502 p_number_of_days_in_usa,
503 p_withldg_allow_eligible_flag,
504 p_ra_effective_date,
505 p_record_source,
506 p_visa_type,
507 p_j_sub_type,
508 p_primary_activity,
509 p_non_us_country_code,
510 p_citizenship_country_code,
511 p_object_version_number ,
512 p_date_8233_signed ,
513 p_date_w4_signed
514 );
515 --
516 -- Having converted the arguments into the
517 -- plsql record structure we call the corresponding record
518 -- business process.
519 --
520 upd(
521 p_effective_date,l_rec);
522 p_object_version_number := l_rec.object_version_number;
523 --
524 hr_utility.set_location(' Leaving:'||l_proc, 10);
525 End upd;
526 --
527 end pqp_aad_upd;