1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
CREATE TABLE TPlop (
id numeric(2) PRIMARY KEY,
fname varchar(20),
lname varchar(20),
ext numeric(3)
);
CREATE TABLE THistPlop (
datum datetime PRIMARY KEY,
id numeric(2),
fname varchar(20),
lname varchar(20),
ext numeric(3)
);
create trigger plopupd
on tplop
for update
as
begin
/* if ( update(fname) or update(lname) )*/
IF ( ((COLUMNS_UPDATED() & 2) > 0) or ((COLUMNS_UPDATED() & 4) > 0) )
begin
insert into THistPlop SELECT (current_timestamp), * FROM Inserted
end
end
insert into tplop values (9,'i','i',9)
insert into tplop values (10,'j','j',10)
insert into tplop values (11,'k','k',11)
/* Ne devrait pas faire d'ajout dans l'historique et pourtant oui :(*/
update tplop set fname='i', lname='i', ext=9 where id = 9 |
Partager