Board index » delphi » Transactions...

Transactions...

This may be a dumb question, but I am going to continue anyway :)  Is there
any benefit in creating unique transaction instances for every query or use
a common transaction instance for all queries?  What is the difference?
Which is better and why?  Thanks in advance!

-Tom

 

Re:Transactions...


Quote
Tom wrote in message <3ac8d1fc$1_1@dnews>...
>This may be a dumb question, but I am going to continue anyway :)  Is
there
>any benefit in creating unique transaction instances for every query or
use
>a common transaction instance for all queries?  What is the difference?
>Which is better and why?  Thanks in advance!

Unless you are executing SQL statements in multiple threads, then you
probably only need a single TIBTransaction component. With multiple
threads, each thread needs its own Transaction, Database, and dataset
components.

There can be scenarios where you would want more than one, for instance
you have small transactions you want to be able to roll back on errors
without rolling back a larger transaction that's also in progress. But
this kind of scenario is fairly rare. The important thing is IB does
support parallel transactions and so this kind of thing is possible if
you need it.

--
Wayne Niddery (WinWright Inc.)
RADBooks - http://members.home.net/wniddery/RADBooks/delphibooks.html
"At the apex of every great tragedy of mankind there stands the figure
of an incorruptible altruist" - Ayn Rand

Re:Transactions...


Thanks Wayne!

"Wayne Niddery (TeamB)" <winwri...@chaffhome.com> wrote in message
news:3ac8e02e$1_2@dnews...

Quote
> Tom wrote in message <3ac8d1fc$1_1@dnews>...
> >This may be a dumb question, but I am going to continue anyway :)  Is
> there
> >any benefit in creating unique transaction instances for every query or
> use
> >a common transaction instance for all queries?  What is the difference?
> >Which is better and why?  Thanks in advance!

> Unless you are executing SQL statements in multiple threads, then you
> probably only need a single TIBTransaction component. With multiple
> threads, each thread needs its own Transaction, Database, and dataset
> components.

> There can be scenarios where you would want more than one, for instance
> you have small transactions you want to be able to roll back on errors
> without rolling back a larger transaction that's also in progress. But
> this kind of scenario is fairly rare. The important thing is IB does
> support parallel transactions and so this kind of thing is possible if
> you need it.

> --
> Wayne Niddery (WinWright Inc.)
> RADBooks - http://members.home.net/wniddery/RADBooks/delphibooks.html
> "At the apex of every great tragedy of mankind there stands the figure
> of an incorruptible altruist" - Ayn Rand

Re:Transactions...


A good example of using two transactions is creating a table on the fly,
then populating it with data. You can't insert data without first committing
the creation of the table. But you'd still have the original transaction to
rollback the insertion of the data.

Jeff Crump

Other Threads