postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: markmaker (@markmaker) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: Re: [postgresql-interfaces/psqlodbc] issue #116: Understanding Transactions in ODBC
Date: Wed, 21 May 2025 07:30:14 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

Thanks @davecramer,

> There is a way to see if you are in a transaction

From outside the ODBC driver? How?

> Also you are correct this is how you control transactions

So to begin a transaction, I would

1. `SQLSetConnectAttr(... SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF ...);`
2. `SQLSetConnectAttr( ... SQL_ATTR_TXN_ISOLATION, SQL_TXN_SERIALIZABLE ...);`


To commit I would...

1. `SQLEndTran(... SQL_COMMIT);`
2. `SQLSetConnectAttr(... SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_ON ...);`
3. `SQLSetConnectAttr( ... SQL_ATTR_TXN_ISOLATION, SQL_TXN_READ_COMMITTED ...);`

Rollback the same but with `SQL_ROLLBACK` in the first call.

### Error handling

If I can't commit (deadlock etc.) then it is _implicitly_ a rollback, right? Or should I then call  `SQLEndTran(... SQL_ROLLBACK)` to be on the safe side? 

I any case, I would still continue with 2. and 3. 

_Mark


view thread (3+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://postgresql-interfaces/psqlodbc
  Cc: [email protected], [email protected]
  Subject: Re: [postgresql-interfaces/psqlodbc] issue #116: Understanding Transactions in ODBC
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox