Hail Hydra
Hail Hydra

Reputation: 473

Issue with TRIGGER INSERT

I got this code of my trigger but it isn't working for some reason

    CREATE TRIGGER copia_detalle_xml AFTER INSERT ON tif_detallexml
FOR EACH ROW 
INSERT INTO tbl_rif (id, idDetalleXml, total_xml, subtotal_xml, iva_xml, fecha_operacion)
VALUES (new.idContador, new.idDetalleXml, new.doubleTotal, new.doubleSubtotal,new.duobleTotalImpuestosTrasladados, NOW());

I checked the name of this field many times and it's correct "new.duobleTotalImpuestosTrasladados"

It is inserting the data correctly in the table but not the field "duobleTotalImpuestosTrasladados", and I have no idea why, I hope you can help me to find the issue with my code.

INFO UPDATED

This is from "tbl_rif"

enter image description here

This is from tif_detallexml

enter image description here

where the field "iva_xml" is 0 it should be 13.79

Upvotes: 1

Views: 42

Answers (2)

Hail Hydra
Hail Hydra

Reputation: 473

I solved the problem, the problem was that I was working with code made by other person where I got all the info of the XML and I didn't see that there was a line where the field that I required was being updated not inserted, that is why the trigger "wasn't working", thank you all for you help and sorry.

Upvotes: 0

davejal
davejal

Reputation: 6133

Looking at the data inserted your iva_xml is a numeric type.

Check to see what value your sending to it, I don't think you're sending the right data format (numeric)

And don't forget the typo you have here, maybe you have the same typo in your code:

duobleTotalImpuestosTrasladados

should be???

doubleTotalImpuestosTrasladados

Just for testing

Could you try to define your trigger like this and see what's inserted in the table?

CREATE TRIGGER copia_detalle_xml AFTER INSERT ON tif_detallexml
FOR EACH ROW 
INSERT INTO tbl_rif (id, idDetalleXml, total_xml, subtotal_xml, iva_xml, fecha_operacion)
VALUES (new.idContador, new.idDetalleXml, new.doubleTotal, new.duobleTotalImpuestosTrasladados,new.doubleSubtotal, NOW());

Upvotes: 1

Related Questions