728x90
- target: Mybatis SelectKey 사용
- method:
Mybatis의 <insert/update/delete> 구문 안에 <selectKey>를 사용하여, 구문 시작 전/후에 사용
<!-- insert/update/delete 구문 -->
<insert id="insertBbs" parameterType="Map">
INSERT INTO BBS (
SEQ
, NTT_SJ
, NTT_CN
)
VALUES (
#{SEQ_VAL}
, #{NTT_SJ}
, #{NTT_CN}
)
<selectKey resultType="long" keyProperty="SEQ_VAL" order="BEFORE">
SELECT NVL(MAX(SEQ), 0) + 1 AS SEQ_VAL
FROM BBS
</selectKey>
</insert>
- source:
https://yn971106.tistory.com/108
[Oracle]SelectKey_사용하기 (feat. SEQUENCE)
구조 : Oracle DB framework: Mybatis 목적 : SEQUENCE 로 증가되는 PK 를 가진 테이블의 INSERT 후 증가된 PK 가져오기 이유 : 글 작성 table 과 fileupload table 은 별도로 구성되어 있고, 파일 업로드시 게시글 table
yn971106.tistory.com
728x90
'Dev > Spring.SpringBoot' 카테고리의 다른 글
[Mybatis] Oracle CLOB 데이터 조회 (0) | 2023.10.31 |
---|---|
[SpringBoot] [Inflearn - 무료] 스프링부트 시큐리티 & JWT 강의 (Section 3) (0) | 2023.02.28 |
[SpringBoot] [Inflearn - 무료] 스프링부트 시큐리티 & JWT 강의 (Section 2) (0) | 2023.02.22 |
[SpringBoot] [Inflearn - 무료] 스프링부트 시큐리티 & JWT 강의 (Section 1) (0) | 2023.02.17 |
[SpringBoot] [Inflearn - 무료] 스프링부트 시큐리티 & JWT 강의 (Section 0) (0) | 2023.02.08 |