ForeverSmiYngEcologyKit/更新最新编号sql.sql

17 lines
484 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

UPDATE uf_GCLXXX
SET gcbhz =
'[GC-' ||
SUBSTR('{?djrq}', 1, 4) ||
'/' ||
(
SELECT
-- 提取当前年份下的最大序号若没有则从1开始
NVL(MAX(TO_NUMBER(REGEXP_SUBSTR(gcbhz, '\d+', 1, 2))), 0) + 1
FROM uf_gcxx
WHERE
-- 提取年份部分进行匹配
REGEXP_SUBSTR(gcbhz, '\d{4}', 1, 1) = SUBSTR('{?djrq}', 1, 4)
) ||
']' from uf_GCLXXX
WHERE
xglc = '{?requestid}';