안녕하세요 아래 쿼리 문법 오류 좀 잡아 주세요...
MERGE INTO if_rem_result_h A USING ppsd_drum_prod B ON ( a.matnr = b.prod_no AND budat ='20120828' AND bf_type ='BF' AND b.prod_no = 'CFM0001-E16F')
WHEN MATCHED THEN
UPDATE
SET menge ='100'
WHEN NOT MATCHED THEN
INSERT
( matnr,
werks,
budat,
mesid,
verid,
mdv01,
alort,
menge,
erfme,
c_type,
bf_type,
CANCEL,
if_flag
)
VALUES(
'CFM0001-E16F' ,
b.werks,
TO_CHAR(SYSDATE,'yyyymmdd'),
(SELECT 'P' || LPAD(NVL(MAX(REPLACE(mesid,'P')),0)+1,9,0) FROM IF_REM_RESULT_H WHERE mesid LIKE 'P%') ,
b.verid,
b.mdv01,
b.alort,
'100',
b.base_unit,
'Y',
'BF',
'N',
'P'
)
b.컬럼들을 못찾는것 같습니다...
아래 문법 처럼 insert 할수 없나요??
INSERT INTO
<(column_list)>
SELECT
FROM
WHERE
MERGE INTO if_rem_result_h A USING ppsd_drum_prod B ON ( a.matnr = b.prod_no AND budat ='20120828' AND bf_type ='BF' AND b.prod_no = 'CFM0001-E16F') WHEN MATCHED THEN UPDATE SET menge ='100' WHEN NOT MATCHED THEN INSERT (matnr , werks , budat , mesid , verid , mdv01 , alort , menge , erfme , c_type , bf_type , CANCEL , if_flag ) SELECT 'CFM0001-E16F' , b.werks , TO_CHAR(SYSDATE,'yyyymmdd') , 'P' || LPAD(NVL(MAX(REPLACE(mesid,'P')),0)+1,9,0) , b.verid , b.mdv01 , b.alort , '100' , b.base_unit , 'Y' , 'BF' , 'N' , 'P' FROM IF_REM_RESULT_H WHERE mesid LIKE 'P%' ;
MERGE INTO if_rem_result_h A USING ppsd_drum_prod B ON ( a.matnr = b.prod_no AND budat ='20120828' AND bf_type ='BF' AND b.prod_no = 'CFM0001-E16F') WHEN MATCHED THEN UPDATE SET menge ='100' WHEN NOT MATCHED THEN INSERT (matnr , werks , budat , mesid , verid , mdv01 , alort , menge , erfme , c_type , bf_type , CANCEL , if_flag ) SELECT 'CFM0001-E16F' , b.werks , TO_CHAR(SYSDATE,'yyyymmdd') , (SELECT'P' || LPAD(NVL(MAX(REPLACE(mesid,'P')),0)+1,9,0) FROM IF_REM_RESULT_H WHERE mesid LIKE 'P%') , b.verid , b.mdv01 , b.alort , '100' , b.base_unit , 'Y' , 'BF' , 'N' , 'P' FROM DUAL ;