简体   繁体   中英

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?

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM