>Hi,
> I am using BEGIN TRASACTION to update multiple table in a process as the following: (my tables are set buffering - 5)
>
>>INSERT INTO Topup (Trans_No, Card_ID, Topup_Amount, Topup_DateTime) ;
> VALUES (lcTrans_No, lcCard_ID,
>>BEGIN TRANSACTION
>>lnUpdated = TABLEUPDATE(.T.,.T.,'Topup', laError)
>>IF lnUpdated
>>SELECT Member
>>REPLACE Total_Sum WITH Total_Sum + lnTopup ;
> Balance WITH lcTotal
>>ELSE
>>ROLLBACK
>>= TABLEREVERT(.T.)
>>RETURN
>>ENDIF
>**Read and Process CommPort Data/****
>>IF ReadComm() = "Failed"
>>ROLLBACK
>>= TABLEREVERT(.T.)
>>RETURN
>>ELSE
>>END TRANSACTION
>>ENDIF
>
>My question are:
>1. If any of my process above failed, will the tabled REVERTED without error? I used to get error TABLEREVERT() is not supported for TRANSACTION. However, the example is help file do so too... Therefore I tried to write =TABLEREVERT(.T.) a few spaces in front of rollback as the following:
>>>>>>>>ROLLBACK
>>>>=TABLEREVER(.T.)
>It works OK alreadi, is it really OK for these code?
>
>2. If there is error that need the update process to be reverted by my procedure (e.g. readcomm failed), I failed to TABLEREVERT(.T.) it. I will get .F. if I update the same record again with ReadComm Successfully even. It caused by the uniqueness of primary key. But I have already issued TABLEREVERT()!!!
>
Why don't you end the transaction, and then revert?
>3. I got error "Data session #2 could not released without end transaction". What is the mistake? I will get this if I revert my table and quit.
THat's because your RETURN statement causes the routine to exit before the transaction is closed. A TABLEREVERT() is not the equivalent of an END TRANSACTION.
Erik Moore
Clientelligence