insert 하려고 하는데 좀 효율적으로 할려고 with 절을 사용했는데 오류가 나네요
안되면 다른 방법이 있을까요
예)
WITH TMP AS
(SELECT NVL(TO_NUMBER(MAX(SUBSTR(KN_NO, 3, 8))), 0) MAX_NO
FROM EA1400_MAP)
INSERT INTO EA1400_MAP (SHA, KN_NO)
SELECT SHA,
'KN' || TRIM(TO_CHAR(TMP.MAX_NO + ROWNUM, '00000000')) KN_NO
FROM TMP,
(SELECT SHA,
ROWNUM
FROM BZ1400_TYPE A
WHERE NOT EXISTS (SELECT 1 FROM EA1400_MAP B WHERE A.SHA = B.SHA)
)
많은 고수분들의 조언 부탁드립니다.
INSERT INTO EA1400_MAP( SHA , KN_NO ) WITH TMP AS (SELECT NVL(TO_NUMBER(MAX(SUBSTR(KN_NO, 3, 8))), 0) MAX_NO FROM EA1400_MAP) SELECT SHA , 'KN' || TRIM(TO_CHAR(TMP.MAX_NO + ROWNUM, '00000000')) KN_NO FROM TMP , ( SELECT SHA , ROWNUM FROM BZ1400_TYPE A WHERE NOT EXISTS (SELECT 1 FROM EA1400_MAP B WHERE A.SHA = B.SHA) )