CREATE OR REPLACE --创建存储过程
procedure pro_autoNo(
v_no out number
)
as
BEGIN
select max(字段)+1 into v_no from 表名
where to_char(sysdate,'yyyyMMdd') = substr(字段,1,8);
if v_no is null THEN
v_no:=to_char(sysdate,'yyyyMMdd')||'0001';
end if;
end;
--调用
declare
v_no number;
begin
pro_autoNo(v_no);
dbms_output.put_line('编号:'||v_no);
end;