--触发器
set serveroutput on
create trigger tr after insert on emp --注意不加分号
declare a number;
begin
select count(*) into a from emp;
dbms_output.put_line(a);
end;
--记录日志
create or replace trigger tr1 after insert or update or delete on t_book
begin
if inserting then
insert into t_book_log values(seqbook.nextval,user,'insert',sysdate);
elsif updating then
insert into t_book_log values(seqbook.nextval,user,'update',sysdate);
else
insert into t_book_log values(seqbook.nextval,user,'delete',sysdate);
end if;
end;
--行触发器
--对某一行的数据进行操作
create trigger rowtr after delete on t_book for each row
begin
update t_booktype set booknum=booknum-1 where booktypeid=:old.booktypeid;
end;