我需要在文件管理器上运行一个插入,但我的选择是返回文件夹的重复项,所以我试图做一个组,但我得到了:
ORA-02287:此处不允许的序列号
有没有办法解决这个问题或使我的选择语句更有效率?
INSERT INTO AMANDA.FOLDERFREEFORM(FREEFORMRSN, FREEFORMCODE, FOLDERRSN, C01, N01, N02, C02, C03, C04, D01, D02, D03, C05, C06)
SELECT AMANDA.FOLDERFREEFORMSEQ.NEXTVAL, 15030, F.FOLDERRSN, R.CATEGORY, R.REQUIRED, R.ELECTIVE, S.SCHOOL_NAME, C.CLASS_NAME, R.USED_FOR, R.DATE_USED, R.COURSE_DATE, RO.DATE_ROSTER_RECVD, R.CE_USED, I.INSTRUCTOR_NAME
FROM OREC_ROSTER_DTLS R
INNER JOIN AMANDA.FOLDER F ON F.CONVERSIONRSN = R.IND_SEQ_ID
INNER JOIN OREC_SCHOOLS S ON R.SCHOOL_NUMBER = S.SCHOOL_NUMBER
INNER JOIN OREC_COURSES C ON C.SCHOOL_NUMBER = S.SCHOOL_NUMBER
INNER JOIN OREC_ROSTERS RO ON R.ROSTER_NBR = RO.ROSTER_NBR
INNER JOIN OREC_INSTRUCTORS IS ON R.COURSE_INSTRUCTOR_NUMBER = IS.INSTRUCTOR_NUMBER
WHERE F.FOLDERTYPE = 'REAB'
Group by f.folderrsn;
答案 0 :(得分:0)
这是您的select
查询,没有序列:
SELECT 15030, F.FOLDERRSN, R.CATEGORY, R.REQUIRED, R.ELECTIVE,
S.SCHOOL_NAME, C.CLASS_NAME, R.USED_FOR, R.DATE_USED, R.COURSE_DATE,
RO.DATE_ROSTER_RECVD, R.CE_USED, I.INSTRUCTOR_NAME
FROM OREC_ROSTER_DTLS R
INNER JOIN AMANDA.FOLDER F ON F.CONVERSIONRSN = R.IND_SEQ_ID
INNER JOIN OREC_SCHOOLS S ON R.SCHOOL_NUMBER = S.SCHOOL_NUMBER
INNER JOIN OREC_COURSES C ON C.SCHOOL_NUMBER = S.SCHOOL_NUMBER
INNER JOIN OREC_ROSTERS RO ON R.ROSTER_NBR = RO.ROSTER_NBR
INNER JOIN OREC_INSTRUCTORS IS ON R.COURSE_INSTRUCTOR_NUMBER = IS.INSTRUCTOR_NUMBER
WHERE F.FOLDERTYPE = 'REAB'
Group by f.folderrsn;
这是不正确的,因为group by
只有一列,但select
有很多其他列。我不知道group by
的意图是什么。但是,如果您有一个有效的查询,则可以使用子查询添加序列:
select AMANDA.FOLDERFREEFORMSEQ.NEXTVAL, t.*
from (select . . .
from . . .
group by . . .
) t