Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Transaction on Query
Thu, Sep 28 2006 3:45 PMPermanent Link

"Robert"
I have a query on which I need to iterate from beginning to end and do some
calculations, edit and post each record. I want to wrap the process in a
transaction.

On V4, how do I start a transaction so that only the query will be affected?
I don't want (if possible) to lock all the tables, since at this point the
tables are irrelevant, I have already extracted the data in the query
dataset.

Robert

Thu, Sep 28 2006 4:22 PMPermanent Link

"Jose Eduardo Helminsky"
Robert

I am assuming the ResultSet is Live because if it is canned you can´t start
a transaction in this case.

If you need to start a transaction covering one or more tables instead of
locking ALL tables, use this:

       TableList := TStringList.Create;
       try
          TableList.Add('YourTable');
          Database.StartTransaction(TableList);
       finally
          TableList.Free;
       end;

       try
           while not Query.Eof do begin
               // do what you want
               Query.Next;
           end;
           Database.Commit;
       except
           Database.RollBack;
       end;

Eduardo

Thu, Sep 28 2006 4:40 PMPermanent Link

"Robert"

"Jose Eduardo Helminsky" <contato@hpro.com.br> wrote in message
news:50DB1614-B536-4E31-BF4B-D4D81DF58EF9@news.elevatesoft.com...
> Robert
>
> I am assuming the ResultSet is Live because if it is canned you can´t
> start a transaction in this case.
>

Yes, it is canned. I was wondering if you could use a transaction just to
cache the disk updates and get some better speed. Obviously not.

Robert


Thu, Sep 28 2006 7:11 PMPermanent Link

Jeff Cook
"Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote on Thu, 28 Sep 2006 16:36:19 -0400

>Yes, it is canned. I was wondering if you could use a transaction just to
>cache the disk updates and get some better speed. Obviously not.
>
Robert


Can't you get the same effect by selecting the query into a memory table and operating on that?  DBISAM will hold as much as possible in memory and manage the writing of excess bits to disk.  When you have successfully completed the stuff you want to do, then start a transaction and do what you have to do on the actual tables.

Cheers

Jeff



--
Jeff Cook
Aspect Systems Ltd
Phone: +64-9-424 5388
Skype: jeffcooknz
www.aspect.co.nz



Sat, Sep 30 2006 7:44 AMPermanent Link

"Jose Eduardo Helminsky"
Robert

When a query is canned, the table created behind the scenes is opened
exclusively and the transaction will not help so much.

Eduardo

Image