728x90
반응형
<insert id="bdInsert" parameterType="param">
<selectKey resultType="bd" keyProperty="param.bdCd,param.bdNo" order="BEFORE" keyColumn="bdCd,bdNo">
SELECT
(SELECT
CONCAT(
'BD'
, DATE_FORMAT(NOW(), '%Y%m')
, LPAD(
CAST((
CAST(
SUBSTR(
IFNULL( MAX(BD_CD)
,CONCAT(
'BD'
,DATE_FORMAT(NOW()
, '%Y%m')
,'00000'
)
),9,5) AS SIGNED
) + 1
) AS CHAR)
,5
,'0'
))
FROM
${dbId}.T_BD
WHERE
TENANT_CD = #{tenantCd}
AND SUBSTRING(BD_CD,1,8) = CONCAT('BD',DATE_FORMAT(NOW(), '%Y%m'))) AS BD_CD
, (SELECT
<choose>
<when test="param.notiYn == true">
IFNULL( MIN(0), 0 )
</when>
<otherwise>
IFNULL( MAX(BD_NO)+1, 1)
</otherwise>
</choose>
FROM ${dbId}.T_BD
WHERE
TENANT_CD = #{tenantCd}
AND BC_CD = #{param.bcCd}
AND NOTI_YN = FALSE
AND USE_YN = TRUE )AS BD_NO
LIMIT 1
</selectKey>
INSERT INTO ${dbId}.T_BD(
TENANT_CD
, BD_CD
, BC_CD
, BD_NO
, BD_TITLE
, BD_BODY
, BD_TP
, USER_CD
, DEPT_CD
, PWD_YN
, BD_PWD
, NOTI_YN
, POP_YN
, POP_SDT
, POP_EDT
, INS_USER_CD
, UPD_USER_CD
) VALUES (
#{tenantCd}
, #{param.bdCd}
, #{param.bcCd}
, #{param.bdNo}
, #{param.bdTitle}
, #{param.bdBody}
, #{param.bdTp}
, #{param.userCd}
, #{param.deptCd}
, #{param.pwdYn}
, #{param.bdPwd}
, #{param.notiYn}
, #{param.popYn}
, #{param.popSdt}
, #{param.popEdt}
, #{param.insUserCd}
, #{param.updUserCd}
)
</insert>
728x90
반응형
'My Travle Map' 카테고리의 다른 글
[SPRINGBOOT][Intellij] 프로젝트 생성하기 (0) | 2023.09.06 |
---|---|
echarts - map (0) | 2023.09.05 |
아이콘 다운로드 (0) | 2023.09.04 |
로고2 (0) | 2023.09.01 |
로고 (0) | 2023.08.30 |