> >
> > Stewart,
> >
> > In order to use transactions, you need buffering turned on. For more information on buffering, check my article here:
> >
> >
http://www.foxite.com/articles/read.aspx?id=75&document=moving-from-single-user-to-multiuser-in-vfp> >
> >
> > Ken
> > You shall know the truth - and the truth shall set you free. (John 8:33)
>
>
> Dear Ken,
>
> Can you help me to verify my coding, please refer to the attachment;
>
>
http://www.foxite.com/uploads/9845dff4-f0df-4f7a-b08f-5b0a475e761c.zip>
> i need your advise.
>
> Thanks.
>
> Regards,
>
> Stewart Chew
Stewart
Your code is most probably OK. You are updating multiple records and multiple tables at a time. What you can do is to set up buffering so that instead of saving each record one by one, the entire changes are saved at a go. First you have to allow multiple locks with SET MULTILOCKS ON.
Then with each of the tables you are updating you have to do
CURSORSETPROP('buffering',5,'YourTableName')
To send data from buffer to the disk, the command is
SuccessCode=TABLEUPDATE(.T.)
If SuccessCode is true your table has been updated.
From you code, I would conclude that you want either every table to be updated successfully , or nothing to be updated and an error to be returned. To do that you have to enclose everything inside a BEGIN TRANSACTION / END TRANSACTION
So
SET MULTILOCKS ON
CURSORSETPROP('Buffering',5,'TableName') && One by one for each table that is being updated
BEGIN TRANSACTION
Your Update Codes. The codes you have already uploaded here.
then for each table do
SELECT YourTable
if not TABLEUPDATE(.T.)
ROLLBACK && Rollback reverses every change in a transaction
Show Your Error Message
For each of your updated table
SELECT YourTable
TABLEREVERT(.T.)
Return
endif
If you come here then all the updates have been successful. So give command
END TRANSACTION
HTH
Regards
Tushar