I was asked a question recently during an interview. Question is:
I have two different databases and I need to update tables on both databases. We want data consistency. I updated table in first database, then while updating second database I got an error. So what can I do in this situation?
I thought to take all in a transaction and if I got an exception I tought that I could rollback. But they said because of having 2 different databases, it is not possible to take them in same transaction. I am not sure if I understand correctly but I could not find other solution.
Now here what I am asking.
1) Is it possible to take two query for two different databases in a single transaction? As I read in some posts it is possible but I could not be sure after what they said.
2) If it is not possible to manage them in a transaction how can I rollback changes in the first database.