CREATE OR REPLACE FUNCTION bdlly.fn_Reg_ywdjh(fn_rq date) RETURN varchar2 IS v_char varchar2(200); v_max varchar2(100); BEGIN --查询出最大的业务登记号-- SELECT max(ywdjh) INTO v_max FROM [email protected]"bdlly2V_LINK.REGRESS.RDBMS.DEV.US.ORACLE.COM" WHERE TO_CHAR(rq,‘YYYY-MM-DD‘)=TO_CHAR(fn_rq,‘YYYY-MM-DD‘); --如果最大值为空,则生成yyyymmdd0001,如果不为空,则按最大值加1 IF v_max IS NULL THEN v_char := to_char(fn_rq,‘yyyymmdd‘)||‘0001‘; ELSE v_char := to_char((to_number(v_max) + 1)); END IF; commit; RETURN v_char; END fn_Reg_ywdjh; /
时间: 2024-10-17 05:57:15