v_sql := 'SELECT TO_CHAR(SYSDATE,''YYYYMMDD'') FROM DUAL';
EXECUTE IMMEDIATE v_sql INTO v_date_no;
v_old_num := to_number(substr(v_old_no, 12, 3));
v_new_num := lpad(to_char(v_old_num+1), 3, '0');
IF v_old_no IS NULL OR substr(v_old_no, 3, 8) <> v_date_no THEN
v_new_no := v_prefix || v_date_no || '-' || '001';
ELSE
v_new_no := v_prefix || v_date_no || '-' || v_new_num;
END IF;
RETURN v_new_no;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM);
END fn_no_make;
新闻热点
疑难解答