代码如下:
-
create or replace trigger sortperson
before insert on sortperson
for each row
declare
-- local variables here
temp integer;
begin
select max(id) into temp from sortperson;
if (temp is not null) then
select temp + 1 into :new.id from dual;
elsif (temp is null) then
select 1 into :new.id from dual;
end if;end sortperson;
-
说明只需要更改触发器名称 和表名即可。