create sequence S_USER;
/
create trigger tib_USER before insert on USER for each row declare integrity_error exception;
errno integer;
errmsg char(200);
dummy integer;
found boolean;
begin -- Column id uses sequence S_USER select S_USER.NEXTVAL INTO :new.objectid from dual;
-- Errors handling
exception
when integrity_error then
raise_application_error(errno,errmsg);
end;
/
有几个地方注意,先创建序列create sequence S_USER。 再创建触发器,创建触发器的时候: select S_USER.NEXTVAL INTO :new.objectid from dual; new.objectid,objectid就是自增字段
原文链接:https://www.f2er.com/oracle/206345.html