我有以下插入
INSERT INTO DFR_DIARY
(
SELECT ID_GEN_SEQUENCE.NEXTVAL,
A.TRANSACTION_REPORTING_UNIT_CD TRECON_RUC,
A.CYCLE_NUMBER_ID,
A.CYCLE_DATE CYCLE_STARTED_DT,
A.UNIT_DIARY_NUMBER_ID DIARY_NUMBER_ID,
'P' STATUS_CODE,
NULL MISSO_INPUT_ID,
A.UNIT_DIARY_DATE DIARY_DATE,
A.UNIT_DIARY_DATE OPENED_DATE,
A.UNIT_DIARY_DATE CERTIFIED_DATE,
COUNT(*) TRANS_ACCEPTED_QY,
0 TRANS_REJECTED_QY,
'DFR LOAD' CREATEDBY,
SYSDATE CREATEDDATE,
NULL,
NULL,
(SELECT ID FROM UDMIPS.DFR_CYCLE
WHERE TRECON_RUC = A.TRANSACTION_REPORTING_UNIT_CD AND
CYCLE_NUMBER_ID = A.CYCLE_NUMBER_ID AND
CYCLE_STARTED_DT = A.CYCLE_DATE) CYCLE_ID,
(SELECT ID FROM UDMIPS.DIARY
WHERE TRECON_RUC = A.TRANSACTION_REPORTING_UNIT_CD AND
DIARY_NUMBER = A.UNIT_DIARY_NUMBER_ID AND
DIARY_DATE = A.UNIT_DIARY_DATE) DIARY_ID
FROM UDMIPS.TEMP_TRANSACTION_RESEARCH A
WHERE
A.TRANSACTION_ERROR_CODE IS NULL AND
A.APPLICATION_SYSTEMS_SOURCE_CD = 'P' AND
A.TRANSACTION_SERIAL_NUMBER_ID IN
(SELECT TRANSACTION_SERIAL_ID FROM UDMIPS.DIARY_TRANSACTIONS)
GROUP BY A.CYCLE_NUMBER_ID,
A.CYCLE_DATE,
A.TRANSACTION_REPORTING_UNIT_CD,
A.UNIT_DIARY_NUMBER_ID ,
A.UNIT_DIARY_DATE
);
这行不通。我得到 ORA-2287 此处不允许的序列号。如果我对所有记录使用像 1 或 2 这样的随机数,我很好。我猜是因为分组失败了。我确实在其他插入中使用了相同的方法,但没有分组,这很好。有没有办法解决它。NEXTVAL 为记录生成primery Key。