반응형
MERGE INTO TB_ATTB T USING( SELECT A.REQ_NO , B.TEST_RST , 'Y' USE_YN , '0' INST_ID , SYSDATE INST_DS , '0' UPDT_ID , SYSDATE UPDT_DS FROM TB_MST A , TB_DTL B WHERE 1=1 AND A.REQ_NO = B.REQ_NO AND B.ITEM_CD IN ('S0B70', 'S0B710') AND A.REQ_DT BETWEEN '20130726' AND '20130825' ) S ON (S.REQ_NO = T.REQ_NO AND S.ATTB_ID = T.ATTB_ID) WHEN MATCHED THEN UPDATE SET T.ATTB_VAL = S.TEST_RST , T.USE_YN = S.USE_YN , T.UPDT_ID = S.UPDT_ID , T.UPDT_DS = S.UPDT_DS WHEN NOT MATCHED THEN INSERT( T.REQ_NO , T.ATTB_ID , T.ATTB_VAL , T.USE_YN , T.INST_ID , T.INST_DS , T.UPDT_ID , T.UPDT_DS ) VALUES( S.REQ_NO , S.ATTB_ID , S.TEST_RST , S.USE_YN , S.INST_ID , S.INST_DS , NULL , NULL ) ;
반응형
'Oracle' 카테고리의 다른 글
[Query] Oracle procedure, function select (0) | 2015.07.31 |
---|---|
[QUERY] 테이블에 있는 데이터 변수에 넣기 (0) | 2015.07.31 |
[Sample] Left outer join 비교 (0) | 2015.07.31 |
[Sample] Pivot, multi pivot (0) | 2015.07.31 |
[SQL Developer] 단축키 (0) | 2015.07.31 |
댓글