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