orcale设置自增列

时间:2014-05-01 13:32:20   收藏:0   阅读:335

create sequence SEQ_ERRORID
minvalue 1
maxvalue 99999999
start with 1000
increment by 1
nocache
order;

create or replace trigger tri_ERRORINFO_ERRORID --触发器名称
before insert on REPORT_ERRORINFO_PDF --Test是表名
for each row
declare
nextid number;
begin
IF :new.ERRORID IS NULL or :new.ERRORID=0 THEN --id是列名
select SEQ_ERRORID.nextval --S_Test正是刚才创建的序列
into nextid
from sys.dual;
:new.ERRORID:=nextid;
end if;
end tri_ERRORINFO_ERRORID;

DROP TRIGGER tri_ERRORINFO_ERRORID

drop sequence SEQ_ERRORID

orcale设置自增列,码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!