[Home] [Help]
PACKAGE BODY: APPS.IGS_UC_COM_SCHSITES_PKG
Source
1 PACKAGE BODY igs_uc_com_schsites_pkg AS
2 /* $Header: IGSXI11B.pls 115.7 2003/06/11 10:34:08 smaddali noship $ */
3
4 l_rowid VARCHAR2(25);
5 old_references igs_uc_com_schsites%ROWTYPE;
6 new_references igs_uc_com_schsites%ROWTYPE;
7
8 PROCEDURE set_column_values (
9 p_action IN VARCHAR2,
10 x_rowid IN VARCHAR2,
11 x_school IN NUMBER ,
12 x_sitecode IN VARCHAR2,
13 x_address1 IN VARCHAR2,
14 x_address2 IN VARCHAR2,
15 x_address3 IN VARCHAR2,
16 x_address4 IN VARCHAR2,
17 x_postcode IN VARCHAR2,
18 x_mailsort IN VARCHAR2,
19 x_town_key IN VARCHAR2,
20 x_county_key IN VARCHAR2,
21 x_country_code IN VARCHAR2,
22 x_imported IN VARCHAR2,
23 x_creation_date IN DATE ,
24 x_created_by IN NUMBER ,
25 x_last_update_date IN DATE ,
26 x_last_updated_by IN NUMBER ,
27 x_last_update_login IN NUMBER
28 ) AS
29 /*
30 || Created By : rgopalan
31 || Created On : 01-OCT-2001
32 || Purpose : Initialises the Old and New references for the columns of the table.
33 || Known limitations, enhancements or remarks :
34 || Change History :
35 || Who When What
36 || smaddali 10-jun-03 obsoleting timestamp column for ucfd203 - multiple cycles build , bug#2669208
37 || (reverse chronological order - newest change first)
38 */
39
40 CURSOR cur_old_ref_values IS
41 SELECT *
42 FROM IGS_UC_COM_SCHSITES
43 WHERE rowid = x_rowid;
44
45 BEGIN
46
47 l_rowid := x_rowid;
48
49 -- Code for setting the Old and New Reference Values.
50 -- Populate Old Values.
51 OPEN cur_old_ref_values;
52 FETCH cur_old_ref_values INTO old_references;
53 IF ((cur_old_ref_values%NOTFOUND) AND (p_action NOT IN ('INSERT', 'VALIDATE_INSERT'))) THEN
54 CLOSE cur_old_ref_values;
55 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
56 igs_ge_msg_stack.add;
57 app_exception.raise_exception;
58 RETURN;
59 END IF;
60 CLOSE cur_old_ref_values;
61
62 -- Populate New Values.
63 new_references.school := x_school;
64 new_references.sitecode := x_sitecode;
65 new_references.address1 := x_address1;
66 new_references.address2 := x_address2;
67 new_references.address3 := x_address3;
68 new_references.address4 := x_address4;
69 new_references.postcode := x_postcode;
70 new_references.mailsort := x_mailsort;
71 new_references.town_key := x_town_key;
72 new_references.county_key := x_county_key;
73 new_references.country_code := x_country_code;
74 new_references.imported := x_imported;
75
76 IF (p_action = 'UPDATE') THEN
77 new_references.creation_date := old_references.creation_date;
78 new_references.created_by := old_references.created_by;
79 ELSE
80 new_references.creation_date := x_creation_date;
81 new_references.created_by := x_created_by;
82 END IF;
83
84 new_references.last_update_date := x_last_update_date;
85 new_references.last_updated_by := x_last_updated_by;
86 new_references.last_update_login := x_last_update_login;
87
88 END set_column_values;
89
90
91 PROCEDURE check_parent_existance AS
92 /*
93 || Created By : rgopalan
94 || Created On : 01-OCT-2001
95 || Purpose : Checks for the existance of Parent records.
96 || Known limitations, enhancements or remarks :
97 || Change History :
98 || Who When What
99 || (reverse chronological order - newest change first)
100 */
101 BEGIN
102
103 IF (((old_references.school = new_references.school)) OR
104 ((new_references.school IS NULL))) THEN
105 NULL;
106 ELSIF NOT igs_uc_com_sch_pkg.get_pk_for_validation (
107 new_references.school
108 ) THEN
109 fnd_message.set_name ('FND', 'FORM_RECORD_DELETED');
110 igs_ge_msg_stack.add;
111 app_exception.raise_exception;
112 END IF;
113
114 END check_parent_existance;
115
116
117 PROCEDURE check_child_existance IS
118 /*
119 || Created By : rgopalan
120 || Created On : 01-OCT-2001
121 || Purpose : Checks for the existance of Child records.
122 || Known limitations, enhancements or remarks :
123 || Change History :
124 || Who When What
125 || (reverse chronological order - newest change first)
126 */
127 BEGIN
128
129 igs_uc_com_scsicnts_pkg.get_fk_igs_uc_com_schsites (
130 old_references.school,
131 old_references.sitecode
132 );
133
134 END check_child_existance;
135
136
137 FUNCTION get_pk_for_validation (
138 x_school IN NUMBER,
139 x_sitecode IN VARCHAR2
140 ) RETURN BOOLEAN AS
141 /*
142 || Created By : rgopalan
143 || Created On : 01-OCT-2001
144 || Purpose : Validates the Primary Key of the table.
145 || Known limitations, enhancements or remarks :
146 || Change History :
147 || Who When What
148 || (reverse chronological order - newest change first)
149 */
150 CURSOR cur_rowid IS
151 SELECT rowid
152 FROM igs_uc_com_schsites
153 WHERE school = x_school
154 AND sitecode = x_sitecode ;
155
156 lv_rowid cur_rowid%RowType;
157
158 BEGIN
159
160 OPEN cur_rowid;
161 FETCH cur_rowid INTO lv_rowid;
162 IF (cur_rowid%FOUND) THEN
163 CLOSE cur_rowid;
164 RETURN(TRUE);
165 ELSE
166 CLOSE cur_rowid;
167 RETURN(FALSE);
168 END IF;
169
170 END get_pk_for_validation;
171
172
173 PROCEDURE get_fk_igs_uc_com_sch (
174 x_school IN NUMBER
175 ) AS
176 /*
177 || Created By : rgopalan
178 || Created On : 01-OCT-2001
179 || Purpose : Validates the Foreign Keys for the table.
180 || Known limitations, enhancements or remarks :
181 || Change History :
182 || Who When What
183 || (reverse chronological order - newest change first)
184 */
185 CURSOR cur_rowid IS
186 SELECT rowid
187 FROM igs_uc_com_schsites
188 WHERE ((school = x_school));
189
190 lv_rowid cur_rowid%RowType;
191
192 BEGIN
193
194 OPEN cur_rowid;
195 FETCH cur_rowid INTO lv_rowid;
196 IF (cur_rowid%FOUND) THEN
197 CLOSE cur_rowid;
198 fnd_message.set_name ('IGS', 'IGS_UC_UCCOSS_UCCOSH_FK');
199 igs_ge_msg_stack.add;
200 app_exception.raise_exception;
201 RETURN;
202 END IF;
203 CLOSE cur_rowid;
204
205 END get_fk_igs_uc_com_sch;
206
207
208 PROCEDURE before_dml (
209 p_action IN VARCHAR2,
210 x_rowid IN VARCHAR2,
211 x_school IN NUMBER ,
212 x_sitecode IN VARCHAR2,
213 x_address1 IN VARCHAR2,
214 x_address2 IN VARCHAR2,
215 x_address3 IN VARCHAR2,
216 x_address4 IN VARCHAR2,
217 x_postcode IN VARCHAR2,
218 x_mailsort IN VARCHAR2,
219 x_town_key IN VARCHAR2,
220 x_county_key IN VARCHAR2,
221 x_country_code IN VARCHAR2,
222 x_imported IN VARCHAR2,
223 x_creation_date IN DATE ,
224 x_created_by IN NUMBER ,
225 x_last_update_date IN DATE ,
226 x_last_updated_by IN NUMBER ,
227 x_last_update_login IN NUMBER
228 ) AS
229 /*
230 || Created By : rgopalan
231 || Created On : 01-OCT-2001
232 || Purpose : Initialises the columns, Checks Constraints, Calls the
233 || Trigger Handlers for the table, before any DML operation.
234 || Known limitations, enhancements or remarks :
235 || Change History :
236 || Who When What
237 || smaddali 10-jun-03 obsoleting timestamp column for ucfd203 - multiple cycles build , bug#2669208
238 || (reverse chronological order - newest change first)
239 */
240 BEGIN
241
242 set_column_values (
243 p_action,
244 x_rowid,
245 x_school,
246 x_sitecode,
247 x_address1,
248 x_address2,
249 x_address3,
250 x_address4,
251 x_postcode,
252 x_mailsort,
253 x_town_key,
254 x_county_key,
255 x_country_code,
256 x_imported,
257 x_creation_date,
258 x_created_by,
259 x_last_update_date,
260 x_last_updated_by,
261 x_last_update_login
262 );
263
264 IF (p_action = 'INSERT') THEN
265 -- Call all the procedures related to Before Insert.
266 IF ( get_pk_for_validation(
267 new_references.school,
268 new_references.sitecode
269 )
270 ) THEN
271 fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
272 igs_ge_msg_stack.add;
273 app_exception.raise_exception;
274 END IF;
275 check_parent_existance;
276 ELSIF (p_action = 'UPDATE') THEN
277 -- Call all the procedures related to Before Update.
278 check_parent_existance;
279 ELSIF (p_action = 'DELETE') THEN
280 -- Call all the procedures related to Before Delete.
281 check_child_existance;
282 ELSIF (p_action = 'VALIDATE_INSERT') THEN
283 -- Call all the procedures related to Before Insert.
284 IF ( get_pk_for_validation (
285 new_references.school,
286 new_references.sitecode
287 )
288 ) THEN
289 fnd_message.set_name('IGS','IGS_GE_RECORD_ALREADY_EXISTS');
290 igs_ge_msg_stack.add;
291 app_exception.raise_exception;
292 END IF;
293 ELSIF (p_action = 'VALIDATE_DELETE') THEN
294 check_child_existance;
295 END IF;
296
297 END before_dml;
298
299
300 PROCEDURE insert_row (
301 x_rowid IN OUT NOCOPY VARCHAR2,
302 x_school IN NUMBER,
303 x_sitecode IN VARCHAR2,
304 x_address1 IN VARCHAR2,
305 x_address2 IN VARCHAR2,
306 x_address3 IN VARCHAR2,
307 x_address4 IN VARCHAR2,
308 x_postcode IN VARCHAR2,
309 x_mailsort IN VARCHAR2,
310 x_town_key IN VARCHAR2,
311 x_county_key IN VARCHAR2,
312 x_country_code IN VARCHAR2,
313 x_imported IN VARCHAR2,
314 x_mode IN VARCHAR2
315 ) AS
316 /*
317 || Created By : rgopalan
318 || Created On : 01-OCT-2001
319 || Purpose : Handles the INSERT DML logic for the table.
320 || Known limitations, enhancements or remarks :
321 || Change History :
322 || Who When What
323 || smaddali 10-jun-03 obsoleting timestamp column for ucfd203 - multiple cycles build , bug#2669208
324 || (reverse chronological order - newest change first)
325 */
326 CURSOR c IS
327 SELECT rowid
328 FROM igs_uc_com_schsites
329 WHERE school = x_school
330 AND sitecode = x_sitecode;
331
332 x_last_update_date DATE;
333 x_last_updated_by NUMBER;
334 x_last_update_login NUMBER;
335
336 BEGIN
337
338 x_last_update_date := SYSDATE;
339 IF (x_mode = 'I') THEN
340 x_last_updated_by := 1;
341 x_last_update_login := 0;
342 ELSIF (x_mode = 'R') THEN
343 x_last_updated_by := fnd_global.user_id;
344 IF (x_last_updated_by IS NULL) THEN
345 x_last_updated_by := -1;
346 END IF;
347 x_last_update_login := fnd_global.login_id;
348 IF (x_last_update_login IS NULL) THEN
349 x_last_update_login := -1;
350 END IF;
351 ELSE
352 fnd_message.set_name ('FND', 'SYSTEM-INVALID ARGS');
353 igs_ge_msg_stack.add;
354 app_exception.raise_exception;
355 END IF;
356
357 before_dml(
358 p_action => 'INSERT',
359 x_rowid => x_rowid,
360 x_school => x_school,
361 x_sitecode => x_sitecode,
362 x_address1 => x_address1,
363 x_address2 => x_address2,
364 x_address3 => x_address3,
365 x_address4 => x_address4,
366 x_postcode => x_postcode,
367 x_mailsort => x_mailsort,
368 x_town_key => x_town_key,
369 x_county_key => x_county_key,
370 x_country_code => x_country_code,
371 x_imported => x_imported,
372 x_creation_date => x_last_update_date,
373 x_created_by => x_last_updated_by,
374 x_last_update_date => x_last_update_date,
375 x_last_updated_by => x_last_updated_by,
376 x_last_update_login => x_last_update_login
377 );
378
379 INSERT INTO igs_uc_com_schsites (
380 school,
381 sitecode,
382 address1,
383 address2,
384 address3,
385 address4,
386 postcode,
387 mailsort,
388 town_key,
389 county_key,
390 country_code,
391 imported,
392 creation_date,
393 created_by,
394 last_update_date,
395 last_updated_by,
396 last_update_login
397 ) VALUES (
398 new_references.school,
399 new_references.sitecode,
400 new_references.address1,
401 new_references.address2,
402 new_references.address3,
403 new_references.address4,
404 new_references.postcode,
405 new_references.mailsort,
406 new_references.town_key,
407 new_references.county_key,
408 new_references.country_code,
409 new_references.imported,
410 x_last_update_date,
411 x_last_updated_by,
412 x_last_update_date,
413 x_last_updated_by,
414 x_last_update_login
415 );
416
417 OPEN c;
418 FETCH c INTO x_rowid;
419 IF (c%NOTFOUND) THEN
420 CLOSE c;
421 RAISE NO_DATA_FOUND;
422 END IF;
423 CLOSE c;
424
425 END insert_row;
426
427
428 PROCEDURE lock_row (
429 x_rowid IN VARCHAR2,
430 x_school IN NUMBER,
431 x_sitecode IN VARCHAR2,
432 x_address1 IN VARCHAR2,
433 x_address2 IN VARCHAR2,
434 x_address3 IN VARCHAR2,
435 x_address4 IN VARCHAR2,
436 x_postcode IN VARCHAR2,
437 x_mailsort IN VARCHAR2,
438 x_town_key IN VARCHAR2,
439 x_county_key IN VARCHAR2,
440 x_country_code IN VARCHAR2,
441 x_imported IN VARCHAR2
442 ) AS
443 /*
444 || Created By : rgopalan
445 || Created On : 01-OCT-2001
446 || Purpose : Handles the LOCK mechanism for the table.
447 || Known limitations, enhancements or remarks :
448 || Change History :
449 || Who When What
450 || smaddali 10-jun-03 obsoleting timestamp column for ucfd203 - multiple cycles build , bug#2669208
451 || (reverse chronological order - newest change first)
452 */
453 CURSOR c1 IS
454 SELECT
455 address1,
456 address2,
457 address3,
458 address4,
459 postcode,
460 mailsort,
461 town_key,
462 county_key,
463 country_code,
464 imported
465 FROM igs_uc_com_schsites
466 WHERE rowid = x_rowid
467 FOR UPDATE NOWAIT;
468
469 tlinfo c1%ROWTYPE;
470
471 BEGIN
472
473 OPEN c1;
474 FETCH c1 INTO tlinfo;
475 IF (c1%notfound) THEN
476 fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
477 igs_ge_msg_stack.add;
478 CLOSE c1;
479 app_exception.raise_exception;
480 RETURN;
481 END IF;
482 CLOSE c1;
483
484 IF (
485 ((tlinfo.address1 = x_address1) OR ((tlinfo.address1 IS NULL) AND (X_address1 IS NULL)))
486 AND ((tlinfo.address2 = x_address2) OR ((tlinfo.address2 IS NULL) AND (X_address2 IS NULL)))
487 AND ((tlinfo.address3 = x_address3) OR ((tlinfo.address3 IS NULL) AND (X_address3 IS NULL)))
488 AND ((tlinfo.address4 = x_address4) OR ((tlinfo.address4 IS NULL) AND (X_address4 IS NULL)))
489 AND ((tlinfo.postcode = x_postcode) OR ((tlinfo.postcode IS NULL) AND (X_postcode IS NULL)))
490 AND ((tlinfo.mailsort = x_mailsort) OR ((tlinfo.mailsort IS NULL) AND (X_mailsort IS NULL)))
491 AND ((tlinfo.town_key = x_town_key) OR ((tlinfo.town_key IS NULL) AND (X_town_key IS NULL)))
492 AND ((tlinfo.county_key = x_county_key) OR ((tlinfo.county_key IS NULL) AND (X_county_key IS NULL)))
493 AND ((tlinfo.country_code = x_country_code) OR ((tlinfo.country_code IS NULL) AND (X_country_code IS NULL)))
494 AND (tlinfo.imported = x_imported)
495 ) THEN
496 NULL;
497 ELSE
498 fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
499 igs_ge_msg_stack.add;
500 app_exception.raise_exception;
501 END IF;
502
503 RETURN;
504
505 END lock_row;
506
507
508 PROCEDURE update_row (
509 x_rowid IN VARCHAR2,
510 x_school IN NUMBER,
511 x_sitecode IN VARCHAR2,
512 x_address1 IN VARCHAR2,
513 x_address2 IN VARCHAR2,
514 x_address3 IN VARCHAR2,
515 x_address4 IN VARCHAR2,
516 x_postcode IN VARCHAR2,
517 x_mailsort IN VARCHAR2,
518 x_town_key IN VARCHAR2,
519 x_county_key IN VARCHAR2,
520 x_country_code IN VARCHAR2,
521 x_imported IN VARCHAR2,
522 x_mode IN VARCHAR2
523 ) AS
524 /*
525 || Created By : rgopalan
526 || Created On : 01-OCT-2001
527 || Purpose : Handles the UPDATE DML logic for the table.
528 || Known limitations, enhancements or remarks :
529 || Change History :
530 || Who When What
531 || smaddali 10-jun-03 obsoleting timestamp column for ucfd203 - multiple cycles build , bug#2669208
532 || (reverse chronological order - newest change first)
533 */
534 x_last_update_date DATE ;
535 x_last_updated_by NUMBER;
536 x_last_update_login NUMBER;
537
538 BEGIN
539
540 x_last_update_date := SYSDATE;
541 IF (X_MODE = 'I') THEN
542 x_last_updated_by := 1;
543 x_last_update_login := 0;
544 ELSIF (x_mode = 'R') THEN
545 x_last_updated_by := fnd_global.user_id;
546 IF x_last_updated_by IS NULL THEN
547 x_last_updated_by := -1;
548 END IF;
549 x_last_update_login := fnd_global.login_id;
550 IF (x_last_update_login IS NULL) THEN
551 x_last_update_login := -1;
552 END IF;
553 ELSE
554 fnd_message.set_name( 'FND', 'SYSTEM-INVALID ARGS');
555 igs_ge_msg_stack.add;
556 app_exception.raise_exception;
557 END IF;
558
559 before_dml(
560 p_action => 'UPDATE',
561 x_rowid => x_rowid,
562 x_school => x_school,
563 x_sitecode => x_sitecode,
564 x_address1 => x_address1,
565 x_address2 => x_address2,
566 x_address3 => x_address3,
567 x_address4 => x_address4,
568 x_postcode => x_postcode,
569 x_mailsort => x_mailsort,
570 x_town_key => x_town_key,
571 x_county_key => x_county_key,
572 x_country_code => x_country_code,
573 x_imported => x_imported,
574 x_creation_date => x_last_update_date,
575 x_created_by => x_last_updated_by,
576 x_last_update_date => x_last_update_date,
577 x_last_updated_by => x_last_updated_by,
578 x_last_update_login => x_last_update_login
579 );
580
581 UPDATE igs_uc_com_schsites
582 SET
583 address1 = new_references.address1,
584 address2 = new_references.address2,
585 address3 = new_references.address3,
586 address4 = new_references.address4,
587 postcode = new_references.postcode,
588 mailsort = new_references.mailsort,
589 town_key = new_references.town_key,
590 county_key = new_references.county_key,
591 country_code = new_references.country_code,
592 imported = new_references.imported,
593 last_update_date = x_last_update_date,
594 last_updated_by = x_last_updated_by,
595 last_update_login = x_last_update_login
596 WHERE rowid = x_rowid;
597
598 IF (SQL%NOTFOUND) THEN
599 RAISE NO_DATA_FOUND;
600 END IF;
601
602 END update_row;
603
604
605 PROCEDURE add_row (
606 x_rowid IN OUT NOCOPY VARCHAR2,
607 x_school IN NUMBER,
608 x_sitecode IN VARCHAR2,
609 x_address1 IN VARCHAR2,
610 x_address2 IN VARCHAR2,
611 x_address3 IN VARCHAR2,
612 x_address4 IN VARCHAR2,
613 x_postcode IN VARCHAR2,
614 x_mailsort IN VARCHAR2,
615 x_town_key IN VARCHAR2,
616 x_county_key IN VARCHAR2,
617 x_country_code IN VARCHAR2,
618 x_imported IN VARCHAR2,
619 x_mode IN VARCHAR2
620 ) AS
621 /*
622 || Created By : rgopalan
623 || Created On : 01-OCT-2001
624 || Purpose : Adds a row if there is no existing row, otherwise updates existing row in the table.
625 || Known limitations, enhancements or remarks :
626 || Change History :
627 || Who When What
628 || smaddali 10-jun-03 obsoleting timestamp column for ucfd203 - multiple cycles build , bug#2669208
629 || (reverse chronological order - newest change first)
630 */
631 CURSOR c1 IS
632 SELECT rowid
633 FROM igs_uc_com_schsites
634 WHERE school = x_school
635 AND sitecode = x_sitecode;
636
637 BEGIN
638
639 OPEN c1;
640 FETCH c1 INTO x_rowid;
641 IF (c1%NOTFOUND) THEN
642 CLOSE c1;
643
644 insert_row (
645 x_rowid,
646 x_school,
647 x_sitecode,
648 x_address1,
649 x_address2,
650 x_address3,
651 x_address4,
652 x_postcode,
653 x_mailsort,
654 x_town_key,
655 x_county_key,
656 x_country_code,
657 x_imported,
658 x_mode
659 );
660 RETURN;
661 END IF;
662 CLOSE c1;
663
664 update_row (
665 x_rowid,
666 x_school,
667 x_sitecode,
668 x_address1,
669 x_address2,
670 x_address3,
671 x_address4,
672 x_postcode,
673 x_mailsort,
674 x_town_key,
675 x_county_key,
676 x_country_code,
677 x_imported,
678 x_mode
679 );
680
681 END add_row;
682
683
684 PROCEDURE delete_row (
685 x_rowid IN VARCHAR2
686 ) AS
687 /*
688 || Created By : rgopalan
689 || Created On : 01-OCT-2001
690 || Purpose : Handles the DELETE DML logic for the table.
691 || Known limitations, enhancements or remarks :
692 || Change History :
693 || Who When What
694 || (reverse chronological order - newest change first)
695 */
696 BEGIN
697
698 before_dml (
699 p_action => 'DELETE',
700 x_rowid => x_rowid
701 );
702
703 DELETE FROM igs_uc_com_schsites
704 WHERE rowid = x_rowid;
705
706 IF (SQL%NOTFOUND) THEN
707 RAISE NO_DATA_FOUND;
708 END IF;
709
710 END delete_row;
711
712
713 END igs_uc_com_schsites_pkg;