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