Forum > Databases

Multiple transactions

(1/3) > >>

egsuh:
I'd like to use two transactions with the same Firebird Database.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---     fbAQ: TIBConnection;     trAQ: TSQLTransaction;     trRollback: TSQLTransaction;      qr1, qr2, qr3: TSQLQuery;  
fbAQ.Transaction is defined as trAQ.
qr1 and qr2's transaction is trAQ, while qr3.transaction = trRollback.

trAQ.stoExplicitStart is on.

When I try to open qr3 with trRollback, I get error saying "trying to implicitly start trAQ".  -- This does not happen at first try from opening the application. It happens at second try of opening qr3.

Is there something wrong with my approach?  I need two transactions, as while I'm operating on one set of dataset, I have to check other values in the database.

babycode:
If you are using SQLdb, I noticed that it always closes the query after iteration. One solution I found was to create a temporary query to query the data behind while another already created query is inserting the data.

egsuh:
@babycode

Thank you for your concern. Transaction.Commit or Transaction.Rollback closes the related TDataSets like TSQLQuery, etc. So there are CommitRetaining and RollbackRetaining.

rvk:

--- Quote from: egsuh on May 22, 2024, 05:38:56 am ---When I try to open qr3 with trRollback, I get error saying "trying to implicitly start trAQ".  -- This does not happen at first try from opening the application. It happens at second try of opening qr3.

--- End quote ---
Is that the COMPLETE error message ???

You have a problem starting a transaction.
So you need to look at all (both) transaction parameters.
Are they read/write/snapshot/record_version etc.

https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref40/fblangref40-transacs.html

It could be that you are trying to read something, that the other transaction has exclusive write access to, prohibiting reading on another transaction.
In that case you need to change the transaction params to record_version.

I normally use the params: read_committed + rec_version + nowait

If you still have problems, then we need to know the database structures (tables etc) and the SQL you are trying to use, to determine if there is some exclusion and deadlock.

egsuh:

--- Quote ---Is that the COMPLETE error message ???
--- End quote ---

Not exactly the same, but that's all.

Trying to start transaction for fbAQ implicitly, transaction "trAQ" is nearer to exact message.

Hmmm... SQL's are not simply reading ...  it tries to read from stored procedure, and tries to write to a field of another table. But shouldn't this a problem as it is controlled within a transaction that opens the stored procedure?  The stored procedures' contents are similar to the following:


--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  FOR      SELECT * FROM table2 WHERE pid=:pid         info :f1, :f2, ...       do suspend;    UPDATE table1 SET pid_open=TRUE WHERE pid=:pid; 
Please notice table names, table1 and table2.

But, the same error continues to happen even though I comment out the last update statement.

Navigation

[0] Message Index

[#] Next page

Go to full version