2 deleted 16 characters in body
source | link

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 awyway to verify if the field of DATAupdate information in a table is null and insertafter the corresponding information to itrow is created?

I'll aprecciate any type of help, thanks.

DELIMITER 
//
create trigger ai_P_has_M
before insert on Prod_has_Ma

for each row 

BEGIN

update DATA

set 

Cod_Maquina1=new.Cod_Maquina1,

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

Seccion=
(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;

END; 

//
 DELIMITER ;

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 awy to verify if the field of DATA table is null and insert corresponding information to it?

I'll aprecciate any type of help, thanks.

DELIMITER 
//
create trigger ai_P_has_M
before insert on Prod_has_Ma

for each row 

BEGIN

update DATA

set 

Cod_Maquina1=new.Cod_Maquina1,

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

Seccion=
(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;

END; 

//
 DELIMITER ;

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.

DELIMITER 
//
create trigger ai_P_has_M
before insert on Prod_has_Ma

for each row 

BEGIN

update DATA

set 

Cod_Maquina1=new.Cod_Maquina1,

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

Seccion=
(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;

END; 

//
 DELIMITER ;
1
source | link

mysql trigger before insert

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 awy to verify if the field of DATA table is null and insert corresponding information to it?

I'll aprecciate any type of help, thanks.

DELIMITER 
//
create trigger ai_P_has_M
before insert on Prod_has_Ma

for each row 

BEGIN

update DATA

set 

Cod_Maquina1=new.Cod_Maquina1,

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

Seccion=
(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;

END; 

//
 DELIMITER ;