42: -- anwest 24-Jan-05 Bug# 4035243 Variable declaration and logging altered
43: -- for unhandled exception noted in peer review
44: -- jbaber 19-Jan-06 Included igs_he_st_spa_all.exclude flag for HE305
45: -- jchin 27-Jan-06 Bug 3484372 output full grade name instead of grade val
46: -- jchakrab 21-Feb-06 Modified for R12 performance enhs - replaced literal SQL with fnd_dsql
47: -- anwest 24-Mar-06 Bug# 5121695 - Modified for impact from R12 SWS changes.
48: -- Replaced IGS_GET_DYNAMIC_SQL(p_pid_group,l_status) with
49: -- GET_DYNAMIC_SQL(p_person_id_grp, l_prs_grp_status, l_group_type)
50: -- and implemented new associated logic.
336: IF p_end_date IS NOT NULL THEN
337: l_end_date := TO_DATE(SUBSTR(p_end_date,1,11),'YYYY/MM/DD');
338: END IF;
339:
340: --initialize fnd_dsql data-structures
341: fnd_dsql.init;
342:
343: -- basic SQL statement for selecting records to be processed
344: -- modified for bug 4035243
337: l_end_date := TO_DATE(SUBSTR(p_end_date,1,11),'YYYY/MM/DD');
338: END IF;
339:
340: --initialize fnd_dsql data-structures
341: fnd_dsql.init;
342:
343: -- basic SQL statement for selecting records to be processed
344: -- modified for bug 4035243
345: fnd_dsql.add_text('SELECT ihss.student_qual_aim , iespa.commencement_dt, ihss.date_qual_on_entry_calc,');
341: fnd_dsql.init;
342:
343: -- basic SQL statement for selecting records to be processed
344: -- modified for bug 4035243
345: fnd_dsql.add_text('SELECT ihss.student_qual_aim , iespa.commencement_dt, ihss.date_qual_on_entry_calc,');
346: fnd_dsql.add_text('ihss.person_id, ihss.course_cd, ihss.version_number ');
347: fnd_dsql.add_text('FROM igs_he_st_spa ihss, igs_en_stdnt_ps_att iespa ');
348: fnd_dsql.add_text('WHERE ihss.person_id = iespa.person_id AND ihss.course_cd = iespa.course_cd ');
349: fnd_dsql.add_text('AND hesa_return_id IS NULL AND hesa_submission_name IS NULL AND hesa_return_name IS NULL ');
342:
343: -- basic SQL statement for selecting records to be processed
344: -- modified for bug 4035243
345: fnd_dsql.add_text('SELECT ihss.student_qual_aim , iespa.commencement_dt, ihss.date_qual_on_entry_calc,');
346: fnd_dsql.add_text('ihss.person_id, ihss.course_cd, ihss.version_number ');
347: fnd_dsql.add_text('FROM igs_he_st_spa ihss, igs_en_stdnt_ps_att iespa ');
348: fnd_dsql.add_text('WHERE ihss.person_id = iespa.person_id AND ihss.course_cd = iespa.course_cd ');
349: fnd_dsql.add_text('AND hesa_return_id IS NULL AND hesa_submission_name IS NULL AND hesa_return_name IS NULL ');
350: fnd_dsql.add_text('AND EXISTS (SELECT person_id from igs_uc_qual_dets where person_id = ihss.person_id) ');
343: -- basic SQL statement for selecting records to be processed
344: -- modified for bug 4035243
345: fnd_dsql.add_text('SELECT ihss.student_qual_aim , iespa.commencement_dt, ihss.date_qual_on_entry_calc,');
346: fnd_dsql.add_text('ihss.person_id, ihss.course_cd, ihss.version_number ');
347: fnd_dsql.add_text('FROM igs_he_st_spa ihss, igs_en_stdnt_ps_att iespa ');
348: fnd_dsql.add_text('WHERE ihss.person_id = iespa.person_id AND ihss.course_cd = iespa.course_cd ');
349: fnd_dsql.add_text('AND hesa_return_id IS NULL AND hesa_submission_name IS NULL AND hesa_return_name IS NULL ');
350: fnd_dsql.add_text('AND EXISTS (SELECT person_id from igs_uc_qual_dets where person_id = ihss.person_id) ');
351:
344: -- modified for bug 4035243
345: fnd_dsql.add_text('SELECT ihss.student_qual_aim , iespa.commencement_dt, ihss.date_qual_on_entry_calc,');
346: fnd_dsql.add_text('ihss.person_id, ihss.course_cd, ihss.version_number ');
347: fnd_dsql.add_text('FROM igs_he_st_spa ihss, igs_en_stdnt_ps_att iespa ');
348: fnd_dsql.add_text('WHERE ihss.person_id = iespa.person_id AND ihss.course_cd = iespa.course_cd ');
349: fnd_dsql.add_text('AND hesa_return_id IS NULL AND hesa_submission_name IS NULL AND hesa_return_name IS NULL ');
350: fnd_dsql.add_text('AND EXISTS (SELECT person_id from igs_uc_qual_dets where person_id = ihss.person_id) ');
351:
352: -- if person id is not null append the following filtering criteria
345: fnd_dsql.add_text('SELECT ihss.student_qual_aim , iespa.commencement_dt, ihss.date_qual_on_entry_calc,');
346: fnd_dsql.add_text('ihss.person_id, ihss.course_cd, ihss.version_number ');
347: fnd_dsql.add_text('FROM igs_he_st_spa ihss, igs_en_stdnt_ps_att iespa ');
348: fnd_dsql.add_text('WHERE ihss.person_id = iespa.person_id AND ihss.course_cd = iespa.course_cd ');
349: fnd_dsql.add_text('AND hesa_return_id IS NULL AND hesa_submission_name IS NULL AND hesa_return_name IS NULL ');
350: fnd_dsql.add_text('AND EXISTS (SELECT person_id from igs_uc_qual_dets where person_id = ihss.person_id) ');
351:
352: -- if person id is not null append the following filtering criteria
353: IF p_person_identifier IS NOT NULL THEN
346: fnd_dsql.add_text('ihss.person_id, ihss.course_cd, ihss.version_number ');
347: fnd_dsql.add_text('FROM igs_he_st_spa ihss, igs_en_stdnt_ps_att iespa ');
348: fnd_dsql.add_text('WHERE ihss.person_id = iespa.person_id AND ihss.course_cd = iespa.course_cd ');
349: fnd_dsql.add_text('AND hesa_return_id IS NULL AND hesa_submission_name IS NULL AND hesa_return_name IS NULL ');
350: fnd_dsql.add_text('AND EXISTS (SELECT person_id from igs_uc_qual_dets where person_id = ihss.person_id) ');
351:
352: -- if person id is not null append the following filtering criteria
353: IF p_person_identifier IS NOT NULL THEN
354: fnd_dsql.add_text(' AND ihss.person_id = ');
350: fnd_dsql.add_text('AND EXISTS (SELECT person_id from igs_uc_qual_dets where person_id = ihss.person_id) ');
351:
352: -- if person id is not null append the following filtering criteria
353: IF p_person_identifier IS NOT NULL THEN
354: fnd_dsql.add_text(' AND ihss.person_id = ');
355: fnd_dsql.add_bind(p_person_identifier);
356: END IF;
357:
358: -- if Course is not null append the following filtering criteria
351:
352: -- if person id is not null append the following filtering criteria
353: IF p_person_identifier IS NOT NULL THEN
354: fnd_dsql.add_text(' AND ihss.person_id = ');
355: fnd_dsql.add_bind(p_person_identifier);
356: END IF;
357:
358: -- if Course is not null append the following filtering criteria
359: IF p_course_code IS NOT NULL THEN
356: END IF;
357:
358: -- if Course is not null append the following filtering criteria
359: IF p_course_code IS NOT NULL THEN
360: fnd_dsql.add_text(' AND ihss.course_cd = ');
361: fnd_dsql.add_bind(p_course_code);
362: END IF;
363:
364: -- if Program Type is not null append the following filtering criteria
357:
358: -- if Course is not null append the following filtering criteria
359: IF p_course_code IS NOT NULL THEN
360: fnd_dsql.add_text(' AND ihss.course_cd = ');
361: fnd_dsql.add_bind(p_course_code);
362: END IF;
363:
364: -- if Program Type is not null append the following filtering criteria
365: IF p_program_type IS NOT NULL THEN
362: END IF;
363:
364: -- if Program Type is not null append the following filtering criteria
365: IF p_program_type IS NOT NULL THEN
366: fnd_dsql.add_text(' AND (ihss.course_cd, ihss.version_number) IN ');
367: fnd_dsql.add_text(' (SELECT psv.course_cd, psv.version_number FROM igs_ps_ver psv WHERE psv.course_type = ');
368: fnd_dsql.add_bind(p_program_type);
369: fnd_dsql.add_text(')');
370: END IF;
363:
364: -- if Program Type is not null append the following filtering criteria
365: IF p_program_type IS NOT NULL THEN
366: fnd_dsql.add_text(' AND (ihss.course_cd, ihss.version_number) IN ');
367: fnd_dsql.add_text(' (SELECT psv.course_cd, psv.version_number FROM igs_ps_ver psv WHERE psv.course_type = ');
368: fnd_dsql.add_bind(p_program_type);
369: fnd_dsql.add_text(')');
370: END IF;
371:
364: -- if Program Type is not null append the following filtering criteria
365: IF p_program_type IS NOT NULL THEN
366: fnd_dsql.add_text(' AND (ihss.course_cd, ihss.version_number) IN ');
367: fnd_dsql.add_text(' (SELECT psv.course_cd, psv.version_number FROM igs_ps_ver psv WHERE psv.course_type = ');
368: fnd_dsql.add_bind(p_program_type);
369: fnd_dsql.add_text(')');
370: END IF;
371:
372: -- if End date is not null append the following filtering criteria
365: IF p_program_type IS NOT NULL THEN
366: fnd_dsql.add_text(' AND (ihss.course_cd, ihss.version_number) IN ');
367: fnd_dsql.add_text(' (SELECT psv.course_cd, psv.version_number FROM igs_ps_ver psv WHERE psv.course_type = ');
368: fnd_dsql.add_bind(p_program_type);
369: fnd_dsql.add_text(')');
370: END IF;
371:
372: -- if End date is not null append the following filtering criteria
373: IF l_end_date IS NOT NULL THEN
370: END IF;
371:
372: -- if End date is not null append the following filtering criteria
373: IF l_end_date IS NOT NULL THEN
374: fnd_dsql.add_text(' AND (iespa.commencement_dt IS NULL OR iespa.commencement_dt <= ');
375: fnd_dsql.add_bind(l_end_date);
376: fnd_dsql.add_text(')');
377: END IF;
378:
371:
372: -- if End date is not null append the following filtering criteria
373: IF l_end_date IS NOT NULL THEN
374: fnd_dsql.add_text(' AND (iespa.commencement_dt IS NULL OR iespa.commencement_dt <= ');
375: fnd_dsql.add_bind(l_end_date);
376: fnd_dsql.add_text(')');
377: END IF;
378:
379: -- if start date is not null append the following filtering criteria
372: -- if End date is not null append the following filtering criteria
373: IF l_end_date IS NOT NULL THEN
374: fnd_dsql.add_text(' AND (iespa.commencement_dt IS NULL OR iespa.commencement_dt <= ');
375: fnd_dsql.add_bind(l_end_date);
376: fnd_dsql.add_text(')');
377: END IF;
378:
379: -- if start date is not null append the following filtering criteria
380: IF l_start_date IS NOT NULL THEN
377: END IF;
378:
379: -- if start date is not null append the following filtering criteria
380: IF l_start_date IS NOT NULL THEN
381: fnd_dsql.add_text(' AND (iespa.discontinued_dt IS NULL OR iespa.discontinued_dt >= ');
382: fnd_dsql.add_bind(l_start_date);
383: fnd_dsql.add_text(')');
384: fnd_dsql.add_text(' AND (iespa.course_rqrmnts_complete_dt IS NULL OR iespa.course_rqrmnts_complete_dt >= ');
385: fnd_dsql.add_bind(l_start_date);
378:
379: -- if start date is not null append the following filtering criteria
380: IF l_start_date IS NOT NULL THEN
381: fnd_dsql.add_text(' AND (iespa.discontinued_dt IS NULL OR iespa.discontinued_dt >= ');
382: fnd_dsql.add_bind(l_start_date);
383: fnd_dsql.add_text(')');
384: fnd_dsql.add_text(' AND (iespa.course_rqrmnts_complete_dt IS NULL OR iespa.course_rqrmnts_complete_dt >= ');
385: fnd_dsql.add_bind(l_start_date);
386: fnd_dsql.add_text(')');
379: -- if start date is not null append the following filtering criteria
380: IF l_start_date IS NOT NULL THEN
381: fnd_dsql.add_text(' AND (iespa.discontinued_dt IS NULL OR iespa.discontinued_dt >= ');
382: fnd_dsql.add_bind(l_start_date);
383: fnd_dsql.add_text(')');
384: fnd_dsql.add_text(' AND (iespa.course_rqrmnts_complete_dt IS NULL OR iespa.course_rqrmnts_complete_dt >= ');
385: fnd_dsql.add_bind(l_start_date);
386: fnd_dsql.add_text(')');
387: END IF;
380: IF l_start_date IS NOT NULL THEN
381: fnd_dsql.add_text(' AND (iespa.discontinued_dt IS NULL OR iespa.discontinued_dt >= ');
382: fnd_dsql.add_bind(l_start_date);
383: fnd_dsql.add_text(')');
384: fnd_dsql.add_text(' AND (iespa.course_rqrmnts_complete_dt IS NULL OR iespa.course_rqrmnts_complete_dt >= ');
385: fnd_dsql.add_bind(l_start_date);
386: fnd_dsql.add_text(')');
387: END IF;
388:
381: fnd_dsql.add_text(' AND (iespa.discontinued_dt IS NULL OR iespa.discontinued_dt >= ');
382: fnd_dsql.add_bind(l_start_date);
383: fnd_dsql.add_text(')');
384: fnd_dsql.add_text(' AND (iespa.course_rqrmnts_complete_dt IS NULL OR iespa.course_rqrmnts_complete_dt >= ');
385: fnd_dsql.add_bind(l_start_date);
386: fnd_dsql.add_text(')');
387: END IF;
388:
389: -- Person ID Group filtering. If person ID group is not NULL then append the sql returned to the above sql stmnt.
382: fnd_dsql.add_bind(l_start_date);
383: fnd_dsql.add_text(')');
384: fnd_dsql.add_text(' AND (iespa.course_rqrmnts_complete_dt IS NULL OR iespa.course_rqrmnts_complete_dt >= ');
385: fnd_dsql.add_bind(l_start_date);
386: fnd_dsql.add_text(')');
387: END IF;
388:
389: -- Person ID Group filtering. If person ID group is not NULL then append the sql returned to the above sql stmnt.
390: -- ANWEST Bug #5121695 Changed IGS_GET_DYNAMIC_SQL(p_pid_group,l_status) to
408: l_prs_grp_sql := SUBSTR(l_prs_grp_sql, 1, INSTR(UPPER(l_prs_grp_sql), ':P_GROUPID') - 1);
409: END IF;
410:
411: -- concatenate the incoming sql stmt to the basic sql to get the complete SQL stmt
412: fnd_dsql.add_text(' AND ihss.person_id IN (');
413: fnd_dsql.add_text(l_prs_grp_sql);
414: IF l_group_type = 'STATIC' THEN
415: fnd_dsql.add_bind(p_person_id_grp);
416: END IF;
409: END IF;
410:
411: -- concatenate the incoming sql stmt to the basic sql to get the complete SQL stmt
412: fnd_dsql.add_text(' AND ihss.person_id IN (');
413: fnd_dsql.add_text(l_prs_grp_sql);
414: IF l_group_type = 'STATIC' THEN
415: fnd_dsql.add_bind(p_person_id_grp);
416: END IF;
417: fnd_dsql.add_text(')');
411: -- concatenate the incoming sql stmt to the basic sql to get the complete SQL stmt
412: fnd_dsql.add_text(' AND ihss.person_id IN (');
413: fnd_dsql.add_text(l_prs_grp_sql);
414: IF l_group_type = 'STATIC' THEN
415: fnd_dsql.add_bind(p_person_id_grp);
416: END IF;
417: fnd_dsql.add_text(')');
418: l_prs_grp_sql := NULL; -- initializing to NULL as this variable no more required for processing.
419:
413: fnd_dsql.add_text(l_prs_grp_sql);
414: IF l_group_type = 'STATIC' THEN
415: fnd_dsql.add_bind(p_person_id_grp);
416: END IF;
417: fnd_dsql.add_text(')');
418: l_prs_grp_sql := NULL; -- initializing to NULL as this variable no more required for processing.
419:
420: END IF;
421:
419:
420: END IF;
421:
422: l_cursor_id := DBMS_SQL.OPEN_CURSOR;
423: fnd_dsql.set_cursor(l_cursor_id);
424:
425: l_Int_calc_sql := fnd_dsql.get_text(FALSE);
426: DBMS_SQL.PARSE(l_cursor_id, l_Int_calc_sql, DBMS_SQL.NATIVE);
427: fnd_dsql.do_binds;
421:
422: l_cursor_id := DBMS_SQL.OPEN_CURSOR;
423: fnd_dsql.set_cursor(l_cursor_id);
424:
425: l_Int_calc_sql := fnd_dsql.get_text(FALSE);
426: DBMS_SQL.PARSE(l_cursor_id, l_Int_calc_sql, DBMS_SQL.NATIVE);
427: fnd_dsql.do_binds;
428:
429: DBMS_SQL.DEFINE_COLUMN(l_cursor_id, 1,c_st_spa.student_qual_aim,30);
423: fnd_dsql.set_cursor(l_cursor_id);
424:
425: l_Int_calc_sql := fnd_dsql.get_text(FALSE);
426: DBMS_SQL.PARSE(l_cursor_id, l_Int_calc_sql, DBMS_SQL.NATIVE);
427: fnd_dsql.do_binds;
428:
429: DBMS_SQL.DEFINE_COLUMN(l_cursor_id, 1,c_st_spa.student_qual_aim,30);
430: DBMS_SQL.DEFINE_COLUMN(l_cursor_id, 2,c_st_spa.commencement_dt);
431: DBMS_SQL.DEFINE_COLUMN(l_cursor_id, 3,c_st_spa.date_qual_on_entry_calc);
920: -- anwest added for Bug #5121695
921: l_group_type VARCHAR2(10);
922:
923: BEGIN
924: fnd_dsql.init;
925:
926: -- basic sql stmt to get list of persons to be processed.
927: -- l_Int_calc_sql := 'SELECT DISTINCT person_id FROM igs_uc_qual_dets WHERE person_id = NVL(' || p_person_identifier || ', person_id) ';
928: fnd_dsql.add_text('SELECT DISTINCT person_id FROM igs_uc_qual_dets ');
924: fnd_dsql.init;
925:
926: -- basic sql stmt to get list of persons to be processed.
927: -- l_Int_calc_sql := 'SELECT DISTINCT person_id FROM igs_uc_qual_dets WHERE person_id = NVL(' || p_person_identifier || ', person_id) ';
928: fnd_dsql.add_text('SELECT DISTINCT person_id FROM igs_uc_qual_dets ');
929:
930: IF p_person_identifier IS NOT NULL OR p_person_id_grp IS NOT NULL THEN
931:
932: fnd_dsql.add_text(' WHERE ');
928: fnd_dsql.add_text('SELECT DISTINCT person_id FROM igs_uc_qual_dets ');
929:
930: IF p_person_identifier IS NOT NULL OR p_person_id_grp IS NOT NULL THEN
931:
932: fnd_dsql.add_text(' WHERE ');
933:
934: IF p_person_identifier IS NOT NULL THEN
935: fnd_dsql.add_text('person_id = ');
936: fnd_dsql.add_bind(p_person_identifier);
931:
932: fnd_dsql.add_text(' WHERE ');
933:
934: IF p_person_identifier IS NOT NULL THEN
935: fnd_dsql.add_text('person_id = ');
936: fnd_dsql.add_bind(p_person_identifier);
937: ELSE
938: fnd_dsql.add_text('1 = 1 ');
939: END IF;
932: fnd_dsql.add_text(' WHERE ');
933:
934: IF p_person_identifier IS NOT NULL THEN
935: fnd_dsql.add_text('person_id = ');
936: fnd_dsql.add_bind(p_person_identifier);
937: ELSE
938: fnd_dsql.add_text('1 = 1 ');
939: END IF;
940:
934: IF p_person_identifier IS NOT NULL THEN
935: fnd_dsql.add_text('person_id = ');
936: fnd_dsql.add_bind(p_person_identifier);
937: ELSE
938: fnd_dsql.add_text('1 = 1 ');
939: END IF;
940:
941: -- Person ID Group filtering
942: IF p_person_id_grp IS NOT NULL THEN
955: l_prs_grp_sql := SUBSTR(l_prs_grp_sql, 1, INSTR(UPPER(l_prs_grp_sql), ':P_GROUPID') - 1);
956: END IF;
957:
958: -- concatenate the incoming sql stmt to the basic sql to get the complete SQL stmt
959: fnd_dsql.add_text(' AND person_id IN (');
960: fnd_dsql.add_text(l_prs_grp_sql);
961: IF l_group_type = 'STATIC' THEN
962: fnd_dsql.add_bind(p_person_id_grp);
963: END IF;
956: END IF;
957:
958: -- concatenate the incoming sql stmt to the basic sql to get the complete SQL stmt
959: fnd_dsql.add_text(' AND person_id IN (');
960: fnd_dsql.add_text(l_prs_grp_sql);
961: IF l_group_type = 'STATIC' THEN
962: fnd_dsql.add_bind(p_person_id_grp);
963: END IF;
964: fnd_dsql.add_text(')');
958: -- concatenate the incoming sql stmt to the basic sql to get the complete SQL stmt
959: fnd_dsql.add_text(' AND person_id IN (');
960: fnd_dsql.add_text(l_prs_grp_sql);
961: IF l_group_type = 'STATIC' THEN
962: fnd_dsql.add_bind(p_person_id_grp);
963: END IF;
964: fnd_dsql.add_text(')');
965: l_prs_grp_sql := NULL; -- initializing to NULL as this variable no more required for processing.
966: END IF;
960: fnd_dsql.add_text(l_prs_grp_sql);
961: IF l_group_type = 'STATIC' THEN
962: fnd_dsql.add_bind(p_person_id_grp);
963: END IF;
964: fnd_dsql.add_text(')');
965: l_prs_grp_sql := NULL; -- initializing to NULL as this variable no more required for processing.
966: END IF;
967:
968: END IF; -- check for person id or person id group parameters
967:
968: END IF; -- check for person id or person id group parameters
969:
970: l_cursor_id := DBMS_SQL.OPEN_CURSOR;
971: fnd_dsql.set_cursor(l_cursor_id);
972:
973: l_Int_calc_sql := fnd_dsql.get_text(FALSE);
974: DBMS_SQL.PARSE(l_cursor_id, l_Int_calc_sql, DBMS_SQL.NATIVE);
975: fnd_dsql.do_binds;
969:
970: l_cursor_id := DBMS_SQL.OPEN_CURSOR;
971: fnd_dsql.set_cursor(l_cursor_id);
972:
973: l_Int_calc_sql := fnd_dsql.get_text(FALSE);
974: DBMS_SQL.PARSE(l_cursor_id, l_Int_calc_sql, DBMS_SQL.NATIVE);
975: fnd_dsql.do_binds;
976:
977: DBMS_SQL.DEFINE_COLUMN(l_cursor_id, 1, l_person_id);
971: fnd_dsql.set_cursor(l_cursor_id);
972:
973: l_Int_calc_sql := fnd_dsql.get_text(FALSE);
974: DBMS_SQL.PARSE(l_cursor_id, l_Int_calc_sql, DBMS_SQL.NATIVE);
975: fnd_dsql.do_binds;
976:
977: DBMS_SQL.DEFINE_COLUMN(l_cursor_id, 1, l_person_id);
978:
979: l_num_rows := DBMS_SQL.EXECUTE(l_cursor_id);