对于下面的SQL脚本,我收到以下错误:
单行子查询返回多行
SELECT (a.student_id) AS StudentId,
'P19' AS UniversityId,
SUBSTR (a.degree_code, 1) AS TargetScientificDegreeId,
SUBSTR (a.degree_code, 1) AS GrantedScientificDegreeId,
DECODE (admission_major_no,
1, 'H01',
2, 'J01',
3, 'F05',
4, 'F05',
5, 'F05',
6, 'F05',
7, 'F05')
AS AdmissionCollegeId,
(SELECT SUBSTR (code, 1, 3)
FROM hi_faculties_map h
WHERE H.FACULTY_NO = a.faculty_no)
AS CurrentCollegeId,
(SELECT SUBSTR (code, 1, 4)
FROM sis_majors q,
sis_student_majors z,
sis_depts r,
hi_depts_map h
WHERE q.major_no = z.major_no
AND z.is_active = 1
AND q.faculty_no = r.faculty_no
AND q.dept_no = r.dept_no
AND r.dept_no = h.dept_no
AND r.faculty_no = h.faculty_no
AND z.student_id = a.student_id)
UniversityDepartmentId,
(SELECT SUBSTR (code, 1, 4)
FROM hi_majors_map w, sis_student_majors h
WHERE is_active = 1
AND H.STUDENT_ID = a.student_id
AND W.MAJOR_NO = H.MAJOR_NO)
AS UniversityMajorId,
(SELECT SUBSTR (code, 1, 4)
FROM hi_majors_map w, sis_student_majors h
WHERE is_active = 1
AND H.STUDENT_ID = a.student_id
AND W.MAJOR_NO = H.MAJOR_NO)
UniversityMinorId,
(SELECT TO_NUMBER (MAX (level_no))
FROM sis_study_levels x, sis_student_majors h
WHERE X.MAJOR_NO = h.MAJOR_NO
AND h.student_id = a.student_id
AND H.IS_ACTIVE = 1)
StudyProgramPeriod,
(SELECT SUBSTR (COUNT (semester_code), 1)
FROM sis_study_semesters
WHERE is_optional = 0)
StudyProgramPeriodUnitId,
(SELECT SUBSTR (MAX (to_hour), 1, 3)
FROM sis_study_levels x, sis_student_majors h
WHERE X.MAJOR_NO = h.MAJOR_NO
AND h.student_id = a.student_id
AND H.IS_ACTIVE = 1)
RequestedCreditHoursCount,
(SELECT SUBSTR (attempted_hrs, 1, 2)
FROM sis_academic_records q
WHERE Q.STUDENT_ID = a.student_id
AND q.semester IN (SELECT semester
FROM sis_degree_calendar y
WHERE Y.IS_CLOSED = 0
AND Y.IS_ACTIVATED = 1))
RegisteredCreditHoursCount,
(SELECT SUBSTR (SUM (x.crd_hrs), 1, 3)
FROM sis_student_courses z, sis_courses x
WHERE x.course_no = z.course_no
AND z.is_passed = 1
AND z.student_id = a.student_id)
PassedCreditHoursCount,
(SELECT NVL (sis_graduation_pkg.get_remain_hrs (student_id,
faculty_no,
MAJOR_NO,
NULL,
NULL,
NULL,
0),
0)
FROM SIS_ACADEMIC_RECORDS Q
WHERE Q.STUDENT_ID = a.student_id
AND Q.SEMESTER = (SELECT MAX (Q.SEMESTER)
FROM SIS_ACADEMIC_RECORDS Q
WHERE Q.STUDENT_ID = a.STUDENT_ID))
RemainingCreditHoursCount,
(SELECT SUBSTR (code, 1)
FROM hi_student_status_map h
WHERE H.status_code = a.status_code)
AS AcademicStatusId,
(SELECT SUBSTR (code, 1)
FROM hi_study_types_map h
WHERE H.study_code = a.study_code)
AS StudyTypeId,
(SELECT SUBSTR (code, 1)
FROM hi_rs_student_status_map h, sis_academic_records w
WHERE H.STATUS_CODE = W.STATUS_CODE
AND W.STUDENT_ID = a.student_id
AND w.SEMESTER = (SELECT MAX (w.SEMESTER)
FROM sis_academic_records w
WHERE w.student_id = a.student_id))
RegistrationStatusId,
(SELECT year
FROM sis_academic_records z,
sis_study_levels y,
sis_student_majors q
WHERE Z.MAJOR_NO = Y.MAJOR_NO
AND z.level_no = Y.LEVEL_NO
AND Z.STUDENT_ID = a.student_id
AND q.student_id = a.student_id
AND Q.IS_ACTIVE = 1
AND Q.MAJOR_NO = Y.MAJOR_NO
AND Z.STUDENT_ID = Q.STUDENT_ID
AND Z.MAJOR_NO = q.major_no
AND Z.PLAN_TYPE = Y.PLAN_TYPE
AND Q.PLAN_TYPE = Z.PLAN_TYPE
AND Q.PLAN_TYPE = Y.PLAN_TYPE
AND q.EDITION = Y.EDITION
AND z.SEMESTER = (SELECT MAX (z.SEMESTER)
FROM sis_academic_records z
WHERE z.student_id = a.student_id))
CurrentAcademicYearId,
gen_pkg.get_hijrah (a.join_date, 'yyyy') AdmissionHijriYear,
TO_CHAR (a.join_date, 'yyyy') AdmissionGregorianYear,
(SELECT TO_CHAR (start_date, 'yyyy')
FROM sis_academic_calendar w
WHERE semester IN (SELECT semester
FROM sis_degree_calendar
WHERE is_activated = 1 AND is_closed = 0)
AND A.DEGREE_CODE = w.degree_code
AND item_code = 3)
AS CurrentYear,
MOD (join_semester, 10) AttendenceSemesterTypeId,
(SELECT MOD (semester, 10)
FROM sis_degree_calendar
WHERE is_activated = 1 AND is_closed = 0)
CurrentSemesterTypeId,
sis_reg_pkg.get_student_level (
a.student_id,
sis_reg_pkg.add_semester (a.student_id, 0, -1))
CurrentLevel,
(SELECT grading_type
FROM SIS_GRADING_SYSTEMS
WHERE system_code = 1)
GPATypeId,
sis_reg_pkg.get_student_gpa (a.student_id, NULL, 1) GPA,
(SELECT code
FROM hi_evaluations_map l,
sis_academic_records y,
sis_gpa_grading c
WHERE L.EVALUATION_CODE = c.EVALUATION_CODE
AND y.semester IN (SELECT semester
FROM sis_degree_calendar z
WHERE Z.IS_ACTIVATED = 1
AND Z.IS_CLOSED = 0)
AND y.student_id = a.student_id
AND cum_gpa BETWEEN c.MIN_GPA AND c.MAX_GPA)
CurrentSemesterAssessmentId,
(SELECT '="' || SUBSTR (CODE, 1, 7) || '"' CODE
FROM HI_CAMPUSES_MAP J
WHERE J.CAMPUS_NO = A.CAMPUS_NO)
StudyLocationCityId,
(SELECT DECODE (Q.STUDY_CODE, 1, '0')
FROM sis_academic_records q
WHERE Q.STUDENT_ID = a.student_id
AND q.semester IN (SELECT semester
FROM sis_degree_calendar y
WHERE Y.IS_CLOSED = 0
AND Y.IS_ACTIVATED = 1))
AS WarningCount,
(SELECT code
FROM hi_evaluations_map l, sis_gpa_grading c
WHERE L.EVALUATION_CODE = c.EVALUATION_CODE
AND sis_reg_pkg.get_student_gpa (a.student_id, NULL, 1) BETWEEN c.MIN_GPA
AND c.MAX_GPA)
AccumulatedAssessmentId,
DECODE (A.REWARD_TYPE, 0, 'null')
AS IsRewardReceivedForCurSemester,
(SELECT h.code
FROM hi_countries_map h, sis_campuses r
WHERE H.COUNTRY_NO = R.COUNTRY_NO AND r.campus_no = a.campus_no)
CountryId,
(SELECT TO_CHAR ( (entry_date), 'yyyy')
FROM sis_semester_trans z
WHERE z.trans_code = 7
AND z.student_id = a.student_id
AND Z.TRANS_CODE = A.STATUS_CODE)
AS GradutionYear,
(SELECT TO_CHAR (entry_date, 'dd-mm-yyyy')
FROM sis_semester_trans z
WHERE z.trans_code = 7
AND z.student_id = a.student_id
AND Z.TRANS_CODE = A.STATUS_CODE)
AS GraduationDate,
(SELECT DECODE (status_code, 1, '1', 2, '1')
FROM sis_academic_records
WHERE attempted_hrs > 0
AND semester LIKE '%%3'
AND semester IN (SELECT semester
FROM sis_degree_calendar
WHERE is_activated = 1 AND is_closed = 0))
AS SummerSemesterRegistratiStatus,
(SELECT CASE
WHEN A.TRANSFER_UNIVERSITY IS NOT NULL THEN '1'
ELSE '2'
END
FROM sis_students z
WHERE z.student_id = a.student_id)
AS IsTransfered,
DECODE (A.BUILDING_CODE, NULL, 'null')
AS IsAccommodationInUniversity,
DECODE (A.ADMISSION_MAJOR_NO, NULL, 'null') AS IsMajorEducational,
(SELECT SUBSTR (
DECODE (major_no,
1, 3,
2, 3,
3, 3,
4, 3,
5, 2,
6, 2,
7, 3),
1)
FROM sis_student_majors x
WHERE x.student_id = a.student_id AND X.IS_ACTIVE = 1)
AS MajorTypeId,
TO_CHAR (join_date, 'dd-mm-yyyy') AS AcceptenceDate,
(SELECT TO_CHAR (entry_date, 'dd-mm-yyyy')
FROM sis_semester_trans z
WHERE z.trans_code IN (7, 6)
AND z.student_id = a.student_id
AND Z.TRANS_CODE = A.STATUS_CODE
AND z.SEMESTER = (SELECT MAX (w.SEMESTER)
FROM sis_academic_records w
WHERE w.student_id = a.student_id))
AS DisclaimerDate,
DECODE (A.SOCIAL_SECURITY, NULL, ' null')
AS disclaimerDecisionBarginNunber,
TO_CHAR (a.LAST_UPDATE_DATE, 'dd-mm-yyyy')
AS DateOfLastUpdateOnAcadmStatus
FROM sis_students a
WHERE a.study_code = 1
AND a.student_id = (SELECT MAX (student_id)
FROM sis_students x
WHERE X.NATIONAL_ID = A.NATIONAL_ID)
答案 0 :(得分:0)
简单地,此错误表明您的一个子查询有多个返回的行:
async function read(){
let data = await fs.readFile(<path>);
console.log(data); //You can use data everywhere within this scope
}
子查询返回了多于1行。您将需要全部调试它们。