>Hi,
> I am wrting application that allow user to top-up account using SMART CARD. When user top-up their account, the top-up amount and the Balance will be recorded and updated into database. Beside, the Balance after top-up need to be updated too into SMART CARD.
>I am worrying about some issues while updating database and SMART CARD.
>
>1. Which should I update first, database or SMART CARD in order to be easier managed if either one of them failed to update? Please explain.
>
>2. Use table buffering or not? I was planning to use table buffering because it can be REVERTED if failed to update SMART CARD (in case any technical problem), and use TABLEUPDATE() if successed. But if TABLEUPDATE() failed after updated SMART CARD, there will be more complicated to recover the value from SMART CARD.
>
>3. Does TABLEUPDATE() fail frequently from the technical side of view (e.g. SYSTEM ERROR, DATABASE CORRUPTED) instead of issues of uniquesness of index and so on?
>
I am sure that it happens sometimes, but I never see it, because these kinds of failures don't get recorded. IOW, either TABLEUPDATE() never ran, or it failed and returned true anyway. All in all though, I wouldn't worry about it.
>4. How do Transaction being done if involving insert and update several tables in single operation?
TRANSACTIONs are what you want to do. YOur situation is exactly what they were built for. With simple buffering, if you update your database and the card fails to update, you have no way to roll your changes back, because you have already committed them. With a transaction, you can check to make sure that all operations are successful and if any one of them fails, ROLLBACK the changes.
Erik Moore
Clientelligence