by Nathan

MERGE INTO 구문 본문

Programming/SQL

MERGE INTO 구문

넷쓴 2018. 8. 20. 10:13



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
MERGE INTO TB_ABCDE a
    USING ( SELECT   #{aaa}  AS AAA
                   , #{bbb}  AS BBB
              FROM DUAL
          ) indata  ON ( a.AAA = indata.AAA
                    AND  a.BBB = indata.BBB )
    WHEN NOT MATCHED THEN
         INSERT (   AAA
                  , BBB
                  , CCC
                  , DDD
                  , EEE
                  , REGDATE
                  , MODDATE )
         VALUES (   #{aaa}          
                  , #{bbb}
                  , #{ccc}
                  , #{ddd}
                  , #{eee}
                  , TO_CHAR(SYSTIMESTAMP,'yyyymmddhh24miss')
                  , TO_CHAR(SYSTIMESTAMP,'yyyymmddhh24miss') )
    WHEN MATCHED THEN
          UPDATE
             SET   BBB = #{bbb}
                  ,CCC = #{ccc}
                  ,DDD = #{ddd}
                  ,EEE = #{eee}
                  ,MODDATE = TO_CHAR(SYSTIMESTAMP,'yyyymmddhh24miss')
cs


'Programming > SQL' 카테고리의 다른 글

Oracle Create Table  (0) 2018.08.13
Comments