Transaction problem...new to using IBDAC

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
monkeymynd
Posts: 12
Joined: Thu 04 Dec 2008 23:08

Transaction problem...new to using IBDAC

Post by monkeymynd » Mon 01 Feb 2010 22:55

Hi All,

It appears as if IBCConnection automatically controls transactions. I'm wondering how to explicitly call a transaction in the following instance.

I have a point of sale module. When I enter the POS module, I open queries to allow users to pick items from the inventory, to select a list of active salespeople, etc. From what I've read here in the forums, simply opening a query will cause the IBCConnection to start a transaction.

My problem is that I need the data in those datasets to be active, but when I go to post the POS items to the database, I want to explicitly begin a transaction that I can rollback in case there is a problem. For instance, I need to post the items to my client_transactions table, possibly update client data if there is a client associated with the POS sale, write data to my receipt table, etc.

I need to wrap a transaction around these specific actions, only, in case something bombs out. At the moment, when I call the MyIBCConnection.StartTransaction before I get ready to post out the sale, it errors because there is already a transaction in progress due to the opening of the datasets.

Can anyone tell me the proper way to do this with IBDAC?

Thanks in advance for any responses.

upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Re: Transaction problem...new to using IBDAC

Post by upscene » Tue 02 Feb 2010 12:50

monkeymynd wrote:Hi All,

It appears as if IBCConnection automatically controls transactions. I'm wondering how to explicitly call a transaction in the following instance.

I have a point of sale module. When I enter the POS module, I open queries to allow users to pick items from the inventory, to select a list of active salespeople, etc. From what I've read here in the forums, simply opening a query will cause the IBCConnection to start a transaction.

My problem is that I need the data in those datasets to be active, but when I go to post the POS items to the database, I want to explicitly begin a transaction that I can rollback in case there is a problem. For instance, I need to post the items to my client_transactions table, possibly update client data if there is a client associated with the POS sale, write data to my receipt table, etc.

I need to wrap a transaction around these specific actions, only, in case something bombs out. At the moment, when I call the MyIBCConnection.StartTransaction before I get ready to post out the sale, it errors because there is already a transaction in progress due to the opening of the datasets.

Can anyone tell me the proper way to do this with IBDAC?

Thanks in advance for any responses.
Use additional TIBCTransaction components and attach your TIBCQuery/whatever component to that one instead.

monkeymynd
Posts: 12
Joined: Thu 04 Dec 2008 23:08

Post by monkeymynd » Thu 04 Feb 2010 14:59

Thank you...that worked perfectly.

amiller29au
Posts: 11
Joined: Fri 03 Dec 2010 00:45
Location: AU

Post by amiller29au » Fri 03 Dec 2010 00:49

Just converted it IBDac from IBObjects and I'm experiencing the same issue, the Transaction is Active with the TIBCQuery is opened.

What does this mean?

Use additional TIBCTransaction components and attach your TIBCQuery/whatever component to that one instead.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 06 Dec 2010 10:44

This is a peculiarity of the InterBase server. It requires a transaction to work with a dataset. If you close the transaction, the dataset will be also closed.

Post Reply