Create MySQL trigger with input condition

0
Hello, I am doing a credit card system and I created a column with the types of card using ENUM ('bronze', 'silver', 'gold'), now I want to create a trigger so that when the user enters with the type, the trigger automatically drops the limit, and credit conditions in their respective columns. What I've tried so far was this:

CREATE DEFINER = CURRENT_USER TRIGGER 
'sistemacc'.'cartaodecredito_AFTER_INSERT' AFTER INSERT ON 'cartaodecredito' 
FOR EACH ROW
BEGIN
IF NEW.tipo = 'bronze' THEN 
    SET NEW.limite = 1000 AND NEW.condicoes='até 2x';
ELSEIF NEW.tipo = 'prata' THEN
    SET NEW.limite = 5000 AND NEW.condicoes ='até 8x';
ELSEIF NEW.tipo = 'ouro' THEN
    SET NEW.limite = 10000 AND NEW.condicoes = 'até 12x';
END if;
END

And the error that mysql returns is this:

  

Error 1362: Updating of NEW row is not allowed in after trigger SQL Statement:

    
asked by anonymous 29.11.2018 / 16:07

0 answers