-3
I know the situation doesn’t make much sense, but the important thing for me is to understand how to "copy and paste" from one table to another according to one condition.
The tables are as follows::
Products | Products |
---|---|
ID | ID |
Name | Name |
V_total | V_total |
V_ISS | V_ISS |
V_aliquot | V_aliquot |
Creation date | Creation date |
Validation date |
All of the Products Table_temp will be inserted in the Products table. What changes is only the Data_validation field.
This is the validation: V_ISS = (V_total * V_aliquota) / 100
If V_ISS is equal to (V_total * V_aliquota) / 100, Copy the date of the Data_creation field of the source table and repeat in the Data_validation field of the target table.
If V_ISS is different from (V_total * V_aliquota) / 100, leave the Data_validation field as NULL.
I tried to do this validation using CASE WHEN but I could not. I only know how to do the direct Insert. Who can help me, thanks so much !!
"is to understand how to "copy and paste" from one table to another" first select from the table from where you want to copy back the data you want, then put isse select together with an Insert:
insert into produtos (campos) select campos from Produtos_temp where sua condição
– Ricardo Pontual
Explain the problem better, is it a point solution or will it work like this in production ? When is this insertion ? In theory a TRIGGER could do the validation and insertion but the subject still seems to me "gaseous".
– Motta