mysql trigger if not update

0

I'm having a question when creating a trigger, I need it to be executed only if the field has not been updated: ProductIntegration, if any other field is updated it should be executed.

DELIMITER $$
CREATE
    TRIGGER 'cadastro'.'trgProdutos' AFTER UPDATE
    ON 'cadastro'.Produtos
   FOR EACH ROW BEGIN
     IF NOT UPDATE(integraProduto) THEN
    SET NEW.integraProduto=1;
     END IF;
    END$$
DELIMITER ;

error: Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE (integraProduct) THEN     SET NEW.integraProduct = 1;      END IF;

    
asked by anonymous 25.03.2015 / 14:15

1 answer

2

Resolved:

DELIMITER $

CREATE TRIGGER 'cadastro'.'trgProdutos' BEFORE UPDATE ON 'cadastro'.Produtos FOR EACH ROW 

BEGIN
   IF (new.integraProduto = old.integraProduto) THEN
      SET NEW.integraProduto=1;
   END IF;
END$

DELIMITER ;
    
26.03.2015 / 00:21