新增一条语句,其中一个字段是每个月自增。例如:SP+201311+xxx。后面三位是001,002,003等等。一直自增。到每个月重新开始,又会从001重新自增。
-- Create sequence
--自增序列
create sequence CHARSINCE_SEQU
minvalue 1
maxvalue 999
start with 1
increment by 1
cache 3;
--添加自增的字段
create or replace trigger GMKQ_SUPCLAIMIDENMAIN before
insert on GMKQ_SUPCLAIMIDENMAIN for each row
declare
v_no varchar2(10);
begin
select CHARSINCE_SEQU.nextval into v_no from dual;
if length(v_no)=1 then
v_no:='00'||v_no;
elsif length(v_no)=2 then
v_no:='0'||v_no;
end if;
select 'SP'||to_char(sysdate,'yyyymm')||v_no into :new.CHARGEORDERNUM from dual;
end;
Oracle 直接操作一个字符的自增
猜你喜欢
转载自liushuifeiyu.iteye.com/blog/1990633
今日推荐
周排行