How can i make this trigger update my table DATA if there is no row to update. Until i insert data in other table lets called ABC, this table uses a after insert trigger to insert information into DATA table , but the problem here is that it is firstly inserted information into Prod_Has_Ma table (its just how the system works).So this is the trigger that Prod_Has_Ma has but it wont update any information into DATA table how can i fix this problem. Is there a way to update information in a table after the corresponding row is created?

I'll aprecciate any type of help, thanks.

create trigger ai_P_has_M
before insert on Prod_has_Ma

for each row 


update DATA



SELECT Nombre_Maquina
from Maquina
where Cod_Maquina=new.Cod_Maquina1

(SELECT Seccion 
from Maquina 
where Cod_Maquina=new.Cod_Maquina1),

id_empresa = 
(SELECT id_empresa 
from Maquina
where Cod_Maquina=new.Cod_Maquina1

where Cod_Produccion = new.Cod_Produccion2;


  • Unclear. If you mean that you modify one table, it fires a trigger on this table, which modifies second table, and you want to create a trigger on second table which will modify data in third table - it is impossible. There is no cascade trigger firing, table modification made by trigger do not fire triggers. If the logic is so complex, use stored procedure instead of triggers for data modifying (from the beginning of whole process which is the most earlier data modifying in that chain). – Akina Mar 21 at 4:38
  • Triggers and Foreign keys have a limited set of uses. Recommend you write a Stored Procedure to do what you need, then get rid of the Trigger and disallow actions directly on the table in question. – Rick James Mar 24 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.