이렇게 data가 있으면 update 없으면 insert를 하려고 합니다.
AND a.taskcode = b.taskcode
여기서 열명이 부적합하다고 나오는데요.
원인이 뭘까요?
이름을 제대로 입력했는데요. dea0101t 테이블에 taskcode라는 컬럼명이 있거든요.
음... workdate, resno, taskcode, pjtcd는 pk 입니다.
MERGE INTO dea0101t a
USING (
SELECT
'20101216' as workdate,
'8012311234567' as resno,
'BB100500' as taskcode,
'ZZZZZZZZ' as pjtcd
FROM dual
) b
ON (
a.workdate = b.workdate
AND a.resno = b.resno
AND a.taskcode = b.taskcode
AND a.pjtcd = b.pjtcd
)
WHEN MATCHED THEN
UPDATE SET
a.taskcode = 'BB100500',
a.pjtcd = 'ZZZZZZZZ',
a.taskcodegb = 'BB',
a.taskcode1 = '10',
a.taskcode2 = '05',
a.taskcode3 = '',
a.inputmh = '100',
a.inputdate = sysdate,
a.inputresno = '8012311234567'
WHEN NOT MATCHED THEN
INSERT (
workdate,
resno,
taskcode,
pjtcd,
taskcodegb,
taskcode1,
taskcode2,
taskcode3,
inputmh,
inputdate,
inputresno,
timestamp
) VALUES (
'20101216',
'8012311234567',
'BB100500',
'ZZZZZZZZ',
'BB',
'10',
'05',
'',
'100',
sysdate,
'8012311234567',
sysdate
)