Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: tushar
  Where is tushar?
 Panaji
 India
 tushar
 To: Stewart Chew
  Where is Stewart Chew?
 
 Malaysia
 Stewart Chew
 Tags
Subject: RE: Insert & Update records
Thread ID: 145129 Message ID: 145708 # Views: 23 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Tuesday, September 18, 2007 11:44:22 AM         
   


> >
> > 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



COMPLETE THREAD
Insert & Update records Posted by Stewart Chew @ 9/13/2007 8:47:55 AM
RE: Insert & Update records Posted by tushar @ 9/13/2007 10:12:55 AM
RE: Insert & Update records Posted by Stewart Chew @ 9/13/2007 11:33:53 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/13/2007 12:40:19 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/18/2007 3:54:33 AM
RE: Insert & Update records Posted by tushar @ 9/18/2007 11:44:22 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/18/2007 2:12:41 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/19/2007 2:39:21 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/19/2007 2:55:43 PM
RE: Insert & Update records Posted by Stewart Chew @ 9/20/2007 4:18:16 AM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 1:45:31 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:05:02 PM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 2:14:16 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:26:32 PM
RE: Insert & Update records Posted by Ken Murphy @ 9/20/2007 2:43:10 PM
RE: Insert & Update records Posted by Cetin Basoz @ 9/20/2007 2:00:53 PM