Quantcast
Channel: SCN : Discussion List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 685

Obtaining the (JDBC) local transaction ID and durably checking if a table was updated by it

$
0
0

Hello,

 

I have a use case where I am unable to enable XA transactions but still need to achieve the following property:

"After a server or client failure, discover if a previously executing JDBC local transaction successfully completed."

 

I do not wish to influence the outcome of that transaction, simply to determine whether that the transaction committed or aborted. I am currently able to achieve this functionality in Oracle using its FLASHBACK_TRANSACTION_QUERY feature:

 

1. Obtaining local transaction ID before crash:

SELECT xid from v$TRANSACTION where XIDUSN = (select regexp_substr(dbms_transaction.local_transaction_id, ('^[0-9]+')) from dual) and XIDSLOT = (select  substr(regexp_substr(dbms_transaction.local_transaction_id,'.[0-9]+'), 2) from dual) and XIDSQN = (select regexp_substr(dbms_transaction.local_transaction_id, ('[0-9]+$')) from dual)

 

2. Determining if transaction was successful after crash:

SELECT COMMIT_SCN from FLASHBACK_TRANSACTION_QUERY where XID = '" + transactionId + "'

 

I have tried to use sp_lock, sp_transactions and systransactions but these do not appear to give me a unique transaction identifier as the "loid" sequence number loops quite quickly (and so I have not investigated if it appears in any auditing tables as it does appear unusable). spid similarly does not seem to be unique? Perhaps there is a composite including timestamp that would help, but even so I seem unable to tally the output from these queries to the specific JDBC connection I am on?

 

Many thanks for any guidance you can offer!

Tom

 

PS I could maintain my own table storing unique numbers of my own creation and update that in the same JDBC local transaction and then develop a garbage collection routine for these but I would prefer to leverage features of the database if they are more efficient.


Viewing all articles
Browse latest Browse all 685

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>