Hi,
I have a requirement where we need to add rows to multiple tables.
Say 1 row to Table A and 1 row to table B. The row in table B is dependent on the row table A - foreign key relation.
I have created the flow in the API express ( PUT) - to add row to Table A - take the data(id) added to Table A and add row to table B,
but getting this error "Cannot add or update a child row: a foreign key constraint fails "
Facing 2 problems.
- The row in Table A is getting added.. but probably not getting committed by the time row in Table B is getting added. So the insert to Table B fails.
- Also another thing is that after the error, if you see the tables - Table A has the row added and Table B is empty.. so the whole transaction is not getting rolled back on an error.
Is there concept of transactions and commit?
How can i resolve this in api express.
Thanks a lot
maithili