I have this table:
create table alecrim(
id_alecrim int not null auto_increment,
sem_epi int not null,
p1 smallint,
p2 smallint,
p3 smallint,
p4 smallint,
p5 smallint,
p6 smallint,
p7 smallint,
p8 smallint,
p9 smallint,
totOvos int,
pend tinyint,
ext tinyint,
ano varchar(4),
primary key(id_alecrim)
) default charset = utf8;
And this trigger:
CREATE TRIGGER somaOvosIFS BEFORE UPDATE
ON alecrim
FOR EACH ROW
DELIMITER \
begin
SET NEW.totOvos = NEW.p1 + NEW.p2 + NEW.p3 + NEW.p4 + NEW.p5 + NEW.p6 + NEW.p7 + NEW.p8 + NEW.p9;
IF(old.pend > 0) THEN
NEW.pend = old.pend - 1;
END IF;
END \
The purpose of the trigger is to update the fields in question (so far it works) and if the pend field is greater than 0 it updates its value with the operation in question.
Does anyone help?