|
|
|
@ -3,31 +3,48 @@
|
|
|
|
|
<mapper namespace="numbering">
|
|
|
|
|
|
|
|
|
|
<sql id="key">
|
|
|
|
|
SELECT
|
|
|
|
|
LPAD(CAST(IFNULL(MAX(${TABLE_KEY}) + 1, 1) AS INT), ${pad}, '0')
|
|
|
|
|
AS NEW_ID
|
|
|
|
|
FROM ${TABLE_NAME}
|
|
|
|
|
SELECT LPAD(CAST(
|
|
|
|
|
CASE
|
|
|
|
|
WHEN (SELECT MAX(${TABLE_KEY}) + 1 FROM ${TABLE_NAME}) IS NULL OR
|
|
|
|
|
(SELECT MAX(${TABLE_KEY}) + 1 FROM ${TABLE_NAME}) = ''
|
|
|
|
|
THEN 1
|
|
|
|
|
ELSE (SELECT MAX(${TABLE_KEY}) + 1 FROM ${TABLE_NAME})
|
|
|
|
|
END
|
|
|
|
|
AS INT), ${pad}, '0')
|
|
|
|
|
AS NEW_ID
|
|
|
|
|
FROM DUAL
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<sql id="keyByYear">
|
|
|
|
|
SELECT
|
|
|
|
|
CONCAT(
|
|
|
|
|
<include refid="utility.currentYear" />
|
|
|
|
|
, LPAD(CAST(IFNULL(MAX(SUBSTRING(${TABLE_KEY}, 4+1)) + 1, 1) AS INT), ${pad}-4, '0')
|
|
|
|
|
) AS NEW_ID
|
|
|
|
|
FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(<include refid="utility.currentYear" />, '%')
|
|
|
|
|
SELECT CONCAT(<include refid="utility.currentYear" />, LPAD(CAST(
|
|
|
|
|
CASE
|
|
|
|
|
WHEN (SELECT MAX(SUBSTRING(${TABLE_KEY}, 4+1)) + 1 FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(<include refid="utility.currentYear" />, '%')) IS NULL OR
|
|
|
|
|
(SELECT MAX(SUBSTRING(${TABLE_KEY}, 4+1)) + 1 FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(<include refid="utility.currentYear" />, '%')) = ''
|
|
|
|
|
THEN 1
|
|
|
|
|
ELSE (SELECT MAX(SUBSTRING(${TABLE_KEY}, 4+1)) + 1 FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(<include refid="utility.currentYear" />, '%'))
|
|
|
|
|
END
|
|
|
|
|
AS INT), ${pad}-4, '0'))
|
|
|
|
|
AS NEW_ID
|
|
|
|
|
FROM DUAL
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<sql id="keyBySggAndYear">
|
|
|
|
|
SELECT
|
|
|
|
|
CONCAT(
|
|
|
|
|
${sggCd}
|
|
|
|
|
, <include refid="utility.currentYear" />
|
|
|
|
|
, LPAD(CAST(IFNULL(MAX(SUBSTRING(${TABLE_KEY}, 9+1)) + 1, 1) AS INT), ${pad}-9, '0')
|
|
|
|
|
) AS NEW_ID
|
|
|
|
|
FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(${sggCd}, <include refid="utility.currentYear" />, '%')
|
|
|
|
|
SELECT CONCAT(<include refid="utility.currentYear" />, LPAD(CAST(
|
|
|
|
|
CASE
|
|
|
|
|
WHEN (SELECT MAX(SUBSTRING(${TABLE_KEY}, 9+1)) + 1 FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(${sggCd}, <include refid="utility.currentYear" />, '%')) IS NULL OR
|
|
|
|
|
(SELECT MAX(SUBSTRING(${TABLE_KEY}, 9+1)) + 1 FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(${sggCd}, <include refid="utility.currentYear" />, '%')) = ''
|
|
|
|
|
THEN 1
|
|
|
|
|
ELSE (SELECT MAX(SUBSTRING(${TABLE_KEY}, 9+1)) + 1 FROM ${TABLE_NAME}
|
|
|
|
|
WHERE ${TABLE_KEY} LIKE CONCAT(${sggCd}, <include refid="utility.currentYear" />, '%'))
|
|
|
|
|
END
|
|
|
|
|
AS INT), ${pad}-9, '0'))
|
|
|
|
|
AS NEW_ID
|
|
|
|
|
FROM DUAL
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
</mapper>
|