If the transaction has uncommitted updates

Our application has a database update, which is performed only after the subsequent update (as using the same transaction, of course). However, we found a rare thread in which the user exits the application before the second update, as a result of which the first will be discarded. I am looking for a way to recognize this uncommitted update after exiting.

I know issues like this call for redesign, but that is not possible. Due to the rarity of the flow and structure of the application, I wonder if there is a way to just check the transaction for uncommitted updates.

The question is valid for Oracle and SQLServer. The application is written in PowerBuilder, but it can be expanded in various ways (.NET, Win32, etc.), if that matters.

+5
source share
7 answers

In Oracle, you can call DBMS_TRANSACTION.local_transaction_id. This will either return a unique identifier for the current transaction, or NULL if the transaction is not active.

Share and enjoy.

+5
source

It may be useful.

@@ TRANCOUNT (Transact-SQL)

Returns the number of active transactions for the current connection.

+4
source

PB11.5 , -, . SQLPreview , INSERT, UPDATE DELETE, , COMMIT ROLLBACK.

, , SQLCA: , , , , SQLCA. "CREATE transaction" ( PB , PBL Peeper ), , .

, , , File/New/PB Object/Standard Class/Transaction. , (, ) script (, SQLPreview, ) ( , , ). , SQLPreview Transaction 11.5. ( , 11.5, DataWindow SQLPreview.)

,

.

+2

Oracle V$TRANSACTION, . ( , , , DBMS_APPLICATION_INFO.SET_MODULE()). , :

SQL> select t.status
  2  from   v$transaction t
  3         join v$session s
  4         on s.saddr = t.ses_addr
  5  where s.sid = sys_context('userenv', 'sid')
  6  /

STATUS
----------------
ACTIVE

SQL>

, NO_DATA_FOUND. V $ , . joes.

, ? , , . , , , , - .

DBMS_TRANSACTION.LOCAL_TRANSACTION_ID(). , . V $TRANSACTION .

+1

, "WITH MARK". , , , , , .

. SQL Server:

0

SQL Server :

IF @@TRANCOUNT>0 BEGIN
  ROLLBACK;
END;
0

SQL Server 2005/2008 DMV.

0

All Articles