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