<!-- 중소벤치기업부 사업별 매핑 Merge 등록/수정 -->
<query id="SHYBCard.mergeMapping" isDynamic="true">
<statement><![CDATA[
/* SHYBCard.mergeMapping : 중소벤치기업부 사업별 매핑 Merge 등록 / 수정 */
MERGE INTO SHYB_RCMS_MAP_M A
USING ( SELECT :PMS_ID AS PMS_ID
, :BZ_CLAS_CD AS BZ_CLAS_CD
, :ITXP_CD AS ITXP_CD
, :H01_DOC AS H01_DOC
FROM DUAL ) B
ON ( A.PMS_ID = B.PMS_ID AND
A.BZ_CLAS_CD = B.BZ_CLAS_CD AND
A.ITXP_CD = B.ITXP_CD AND
A.H01_DOC = B.H01_DOC
)
WHEN MATCHED THEN
UPDATE
SET A.USE_YN = 'Y'
, A.UPD_ID = :GV_WORKER_ID
, A.UPD_DT = SYSDATE
WHEN NOT MATCHED THEN
INSERT ( PMS_ID, BZ_CLAS_CD, ITXP_CD, H01_DOC, PILSU_YN, SORT_SEQ, USE_YN, BIGO, REG_ID , REG_DT, UPD_ID, UPD_DT )
VALUES (:PMS_ID, :BZ_CLAS_CD, :ITXP_CD, :H01_DOC, :PILSU_YN, (SELECT NVL(MAX(SORT_SEQ),0) + 1
FROM SHYB_RCMS_MAP_M
WHERE PMS_ID = :PMS_ID
AND BZ_CLAS_CD = :BZ_CLAS_CD
AND ITXP_CD = :ITXP_CD),'Y', :BIGO, :GV_WORKER_ID, SYSDATE, :GV_WORKER_ID, SYSDATE )
]]></statement>
</query>
빨간 부분에서 중요한건 -> merge insert구문에서 value에 쿼리를 넣었다는것. 값을 넣어야 하기 떄문에 value에 넣은게 맞겠지??
생각 잘해라!
'DBMS > Oracle' 카테고리의 다른 글
mybatis 동적 쿼리 choose 등 사용 주의사항 (1) | 2018.07.13 |
---|---|
mybits 에러 (0) | 2018.07.13 |
Merge Into 사용방법 (0) | 2017.11.23 |
데이터 변형 (0) | 2017.10.17 |
LAPD,RAPD 사용법 (0) | 2017.10.17 |