mercredi 22 juillet 2015

Do sqlite triggers work on the whole db or only the changed rows

I need to convert sqlite triggers into mysql triggers. I've converted the following sqlite trigger

create trigger arpinsert after insert on arp
begin
    update arp set timeout = datetime('now', '60 seconds') where rowid = new.rowid and new.mac != '00:00:00:00:00:00';
    update arp set timeout = datetime('now')               where rowid = new.rowid and new.mac  = '00:00:00:00:00:00';
end;

into the following mysql trigger

delimiter //
create
    trigger arpBeforeInsert
    before insert
    on arp for each row
        begin
            if new.mac != '00:00:00:00:00:00' then
                set new.timeout = date_add(now(), interval 60 second);
            else
                set new.timeout = now();
            end if;
        end;//
delimiter ;

I know that the mysql trigger only triggers over the effected rows. Is the same true for the sqlite trigger? If I removed the where rowid = new.rowid would the sqlite trigger update over the whole table?

Aucun commentaire:

Enregistrer un commentaire