Danil Onishchenko
Danil Onishchenko

Reputation: 2040

erlang odbc: How to disable autocommit for oracle

I need to disable autocommit for oracle using erlang odbc module in Linux. I'm created connection with code:

{ok, Con} = odbc:connect("DSN=MyDSN", [{auto_commit, off}, {scrollable_cursors, off}]).

Connection was created succesfully. When I'm trying to update a table the request is successfull, but it is commited automaticaly. What am I doing wrong?

Upvotes: 5

Views: 1425

Answers (2)

Danil Onishchenko
Danil Onishchenko

Reputation: 2040

Ok, guys. I fixed the problem myself. As I said in comments earlier the issue is the Oracle ODBC driver for Linux was ignoring setting autocommit mode during driver initialization before a connection creation. And after a connection has beeen already created the autocommit mode is set rightfully.

I created a fix for C source for erlang odbc module and now it works just right. You can get my patches for Erlang OTP here - https://github.com/RubberCthulhu/erlang-odbc-oracle-fix.

Update: The news is belated, but nevertheless it might be useful to inform here about. My fix for Oracle ODBC has been included in Erlang/OTP. So since R16A the problem is not actual and if you need to use ODBC with Oracle just try the latest version of Erlang/OTP. The patches for R14B04-R15B02 are available here - https://github.com/RubberCthulhu/erlang-odbc-oracle-fix .

Upvotes: 3

Michał Niklas
Michał Niklas

Reputation: 54332

In ODBC there is SQLSetConnectAttr() function. It can be used with SQL_ATTR_AUTOCOMMIT and SQL_AUTOCOMMIT_OFF values. But I don't know how to call it from Erlang.

Upvotes: 0

Related Questions