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