[unixODBC-dev] Commiting transations in ODBC

Nick Gorham nick at easysoft.com
Sun Aug 8 01:48:08 BST 2004


Peter Nolan wrote:
> Hi All,
> 
> I've written an ETL tool and I'd like to introduce the ability to specify
> how many statements are executed before a commit is performed. (It
> autocommits after each statement at the moment.)
> 
> I believe the following statement will set auto commit off...is this
> correct?
> 
> SQLCODE = SQLSetConnectAttr(DBConnectionHandle, SQL_ATTR_AUTOCOMMIT,
> SQL_AUTOCOMMIT_OFF, 0);
> 
> I also have a commit function to call SQLendtran as follows:
> 
> SQLCODE = SQLEndTran(SQL_HANDLE_DBC,DBConnectionHandle,SQL_COMMIT);
> 
> ////////////////////////////////////////////////////////////////////////////
> //////////////////
> 
> // Check the call. //
> 
> ////////////////////////////////////////////////////////////////////////////
> //////////////////
> 
> SQL_OK = SQLCODE_SUCCEEDED(SQLCODE) ;
> 
> CALL_RETURNED_OK = SQL_OK ;
> 
> return CALL_RETURNED_OK ;
> 
> But I have one question....when the SQLEndTran is called, will it cause any
> problems to my prepared statements? I have prepared statements for
> insert/update/deletes which is what I want to commit. I am guessing there is
> no problem because the application is already committing after each call.
> 
> 
It depends on the driver, some will close cursors and other close 
statements after a commit (and rollback). There is a SQLGetInfo value to 
get the result of this SQL_CURSOR_COMMIT_BEHAVIOR.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbccommit_and_rollback_behavior.asp

-- 
Nick Gorham
Easysoft Limited



More information about the unixODBC-dev mailing list