# Oracle MERGE INTO
- 데이터의 존재여부를 파악해 입력, 수정처리를 한번해할 수 있는 구문입니다.
```sql
MERGE INTO TBL_MAST A
USING DUAL
ON (
A.PMT_YY = :PMT_YY
AND A.O_CD = :O_CD
AND A.DEPT_CD = :DEPT_CD
)
WHEN MATCHED THEN
UPDATE
SET
O_NM = :O_NM
, SOSOK= :SOSOK
, EVL_RNK= :EVL_RNK
, ELR_PMT_RAT= :ELR_PMT_RAT
, SCR_PMT_RAT= :SCR_PMT_RAT
, ITR_PMT_RAT= :ITR_PMT_RAT
, OCD_PMT_RAT= :OCD_PMT_RAT
, RES_PMT_RAT= :RES_PMT_RAT
, UP_NM = :USER_ID
, UP_DAT = TO_CHAR(SYSDATE,'YYYYMMDD')
WHEN NOT MATCHED THEN
INSERT
(
PMT_YY
, O_CD
, DEPT_CD
, O_NM
, SOSOK
, EVL_RNK
, ELR_PMT_RAT
, SCR_PMT_RAT
, ITR_PMT_RAT
, OCD_PMT_RAT
, RES_PMT_RAT
, INP_NM
, INP_DAT
)
VALUES(
:PMT_YY
, :O_CD
, :DEPT_CD
, :O_NM
, :SOSOK
, :EVL_RNK
, :ELR_PMT_RAT
, :SCR_PMT_RAT
, :ITR_PMT_RAT
, :OCD_PMT_RAT
, :RES_PMT_RAT
, :USER_ID
, TO_CHAR(SYSDATE,'YYYYMMDD')
)
```
댓글