0

I have two database A, B.

A record of A will move to B after being processed.

the below is simple procedure.

get A-record from A -> process A-record for B-record -> write B-record into B.

In above process, After writing record-B into B, the A-record in a A have to be removed.

And i Think for consistency, two action writing B-record into B and removing A-record from A have to be processed and committed at once.

Because, for example

After writing B-record but not removing record-A, the program shut down, So two database have no consistency.

So a record-A will be processed again.

And the other way, if i remove A-record first, and the program shut down before writing B-record, the A-record will is lost.

How to do usually in this case ?

Nick.Mc
  • 18,304
  • 6
  • 61
  • 91
SangminKim
  • 8,358
  • 14
  • 69
  • 125
  • what kind of database? sql server? You're already halfway there - look up `commit` – Nick.Mc Mar 22 '15 at 08:49
  • Actually i am using SQLite, but the way to handle this kind of problem is database-specific? – SangminKim Mar 22 '15 at 10:40
  • What you're talking about is a 'transaction'. Looks like SQLLite has transactions, but it's not clear whether these can cross databases. http://www.tutorialspoint.com/sqlite/sqlite_transactions.htm. Why don't you try it and see? – Nick.Mc Mar 22 '15 at 10:47
  • Most databases support transactions, but the syntax is probably database specific. I have added the SQLLite tag for you. – Nick.Mc Mar 22 '15 at 10:47
  • Here a short sample on stackoverflow: http://stackoverflow.com/questions/17148885/begin-commit-fails-in-sqlite you would also need to include your delete in the transaction. A transaction is either wholly successful or wholly fails. – Nick.Mc Mar 22 '15 at 10:50

0 Answers0