ForeverSmiYngEcologyKit/更新最新编号sql.sql

36 lines
925 B
SQL
Raw Permalink 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}';
--不通过xh
UPDATE formtable_main_1576
SET jsxmbh =
'JSXMSQ-' ||
SUBSTR('{?sqrq}', 1, 4) ||
'-' ||
(
SELECT LPAD(
NVL(MAX(TO_NUMBER(REGEXP_SUBSTR(jsxmsqbh, '-(\d{4})$', 1, 1, NULL, 1))), 0) + 1,
4, '0'
)
FROM uf_gcxx
WHERE
REGEXP_SUBSTR(gcbhz, '-(\d{4})-', 1, 1, NULL, 1) = SUBSTR('{?sqrq}', 1, 4)
)
WHERE
requestid = '{?requestid}'