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
时间: 2024-11-15 17:15:26