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}'