I have Table Cont and Table Sap.
I need to compare columns fecha and doc_number row by row, if both match, i need to insert date, doc_number, atributo1 and atributo2 into Table C and change status in Table Cont to M. If no match, the status should be N and that record is not inserted in table C.
Table Cont
+------------+------------+------------+
| fecha | doc_number | status |
+------------+------------+------------+
| 02/02/2007 | 00001 | A |
| 02/02/2007 | 00002 | A |
| 02/02/2007 | 00003 | A |
+------------+------------+------------+
Table Sap
+------------+------------+-----------+-----------+
| date | doc_number | atributo1 | atributo2 |
+------------+------------+-----------+-----------+
| 02/02/2007 | 00003 | Factura | Comp |
| 02/02/2007 | 00001 | Factura | Comp |
+------------+------------+-----------+-----------+