1

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

4
  • 1
    What are the data types for all the 6 columns? Commented Jan 5, 2016 at 1:36
  • 1
    Is the data for this column being inserted into the actual table i.e. tif_detallexml? Could you post the data values? Commented Jan 5, 2016 at 1:43
  • @vmachan yeah, everything is working on tif_detallexml Commented Jan 5, 2016 at 1:48
  • 1
    So tif_detallexml.duobleTotalImpuestosTrasladados maps to tbl_rif.iva_xml. And tif_detallexml.duobleTotalImpuestosTrasladados = 0 so what is the value being set/inserted into tbl_rif.iva_xml? Commented Jan 5, 2016 at 1:55

2 Answers 2

1

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());
Sign up to request clarification or add additional context in comments.

5 Comments

The type of both are "double" and yes "duobleTotalImpuestosTrasladados" is the correct name, I know that look different to the rest of the fields but it's correct.
could you also post the inserted data from the tif_detallexml table
Just to try, could you manually insert data in that table to verify what error is given?
I think at this point you should ask your question at dba
0

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.

1 Comment

This is exactly what I was getting at with the last part of my answer, to see if the values actually were sent or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.