其实你也知道不难,最好自己多学学,多练练
So,我把表名换掉了,但是其他的没变,你改改表名,也当学习吧。
那个触发器里命名的变量可以不要,多写的。
create or replace trigger TRI_CUSTOMER
before insert on customer
REFERENCING OLD AS "OLD" NEW AS "NEW"
for each row
declare
v_age customer.age % type;
begin
SELECT Floor(months_between(SYSDATE, :new.bir_date)/12) INTO :new.age FROM DUAL ;
end TRI_CUSTOMER;
CREATE OR REPLACE TRIGGER person_insert
AFTER INSERT
ON person
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
UCONT NUMBER;
BEGIN
SELECT COUNT(1) INTO UCONT FROM person WHERE id=:new.id OR name=:new.name OR bir_date=:new.bir_date;
if (QCOUNT>0)
then
Insert into person (age) Values (10);
end if;
end;