본문 바로가기
Server/Oracle

<selectKey>사용 쿼리

by 뒹굴거리는프로도 2018. 2. 21.
반응형
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
29
30
31
32
<insert id="lusotdpotDAO.insertLusotdpot_D">
        <selectKey resultClass="int" keyProperty="lght_seq">
            SELECT NVL(MAX(LGHT_SEQ),0)+1 AS LGHT_SEQ  FROM LUSTNOUTRDLGHTDETAIL
            WHERE LGHT_NO = #lght_no#
        </selectKey>
        <![CDATA[
            INSERT INTO LUSTNOUTRDLGHTDETAIL
            (
              LGHT_NO,
              LGHT_SEQ,
              LGHT_KND_DETAIL_CODE,
              SOT_KND_CODE,
              LGHT_CNT,
              CNSMP_PWRER,
              LGHT_COLOR,
              FLICKER_AT,
              LGHT_MTHD_CODE
            )
            VALUES
            (
             #lght_no#,
             #lght_seq#,
             #lght_knd_detail_code#,
             #sot_knd_code#,
             #lght_cnt#,
             #cnsmp_pwper#,
             #lght_color#,
             #flicker_at#,
             #lght_mthd_code#
            );
        ]]>
</insert>
cs


PK1인 LGHT_NO와, PK2인 LGHT_SEQ가 합쳐 UNIQUE KEY.

현재 테이블 2개 각각의 VO를 만들어 파라미터로 넣어줘야하는 수정 작업이 필요하다.

반응형