I would like to be able to update a field in the same table where the Trigger
is triggered, I have read that when the trigger
is triggered the table is blocked and can not be modified but it can be done in another way.
CREATE TRIGGER 'codigo_barras_update' AFTER UPDATE ON 'persona'
FOR EACH ROW
BEGIN
DECLARE codigoEAN VARCHAR(13);
Select CONCAT('1000',LEFT(NEW.nif, 8), '0') INTO codigoEAN;
UPDATE persona SET codigo_barras = codigoEAN WHERE nif = NEW.nif;
END;
What I want to do is update the barcode with the NIF
of the person, then as long as the NIF
is changed, the trigger
skips and generates the new bar code and stores it in the table person. The drawback is that the NIF
and the bar code is in the same table. Would there be a possibility of doing it or being able to do it in another way?