Last post Dec 07, 2018 03:38 PM by mgebhard
Dec 07, 2018 09:35 AM|acmedeepak|LINK
I have a table Customers with columns CustomerID, CustomerName, Balance. Now, I need to send 500 money from CustomerA who has 8000 (balance) to CustomerB who has 6000. This is like a bank account transaction. Can anyone please help me with this scenario
where if the transaction fails, The amount should be with Customer A and success the amount should be credited with customer B.
So, If the transaction succeeds CustomerA should have 7500 and CustomerB should have 6500.
If the transaction fails, CustomerA should have 8000 and CustomerB should have 6000.
Can anyone give me an approach to this scenario? A stepwise approach on how to achieve this. I think "Transactions" is a good approach but no idea on how to work on it. Please help me with this?
Dec 07, 2018 03:38 PM|mgebhard|LINK
The common design approach uses standard accounting principles similar to your checking account bank statement.. Debit customer B and credit customer A by adding a debit record for Customer B and a credit record for customer A
Wrap these two INSERTs in a transaction. You can learn about transactions in the SQL docs.
See the C# transaction docs if you are invoking the transactions from code.