MySQL Does not execute well trigger

1

I have a "trigger before insert" in a table in MySQL, which calculates a time accumulated in the last column of the table through a stored procedure that compares the record that is being inserted with the previous record chronologically ordered and the same kind.

The fact is that when I insert individually from a console in this way:

insert into personas (Nombre,Zona,Fecha_Hora) 
  Values ('Usuario','Zona 1','2018-05-15 07:50:00');
commit;

The trigger runs well and completes the data as it corresponds to changing the Date_Hour.

The problem is that when I perform massive insert the trigger behaves as if the first record was always being inserted and does not calculate the accumulated times.

Any ideas that I may be missing or that I might be doing wrong?

    
asked by Juan 10.09.2018 в 22:39
source

1 answer

1

the FOR EACH ROW should solve that and there does not seem to be a way to create a trigger without those 3 words recervadas look at this structure to insert in an audit table:

CREATE TRIGGER 'tr_prim' BEFORE INSERT ON 'primera' FOR EACH ROW INSERT 
INTO auditoria(id,conf) values(null,"si")
    
answered by 10.09.2018 в 23:32