[unixODBC-dev] Getting SQLGetInfo to get the correct results on AIX 64 bit with Easysoft Oracle driver

Peter Nolan peter at peternolan.com
Thu Aug 19 20:43:50 BST 2004


Hi All,,
I am updating my software to allow for commits to be performed at a user
specified frequency.

To do this the user passes some parameters to say Autocommit=No and
CommitFrequency=nnnn.

To make this work I am told I need to check to see if the ODBC driver allows
for auto commit to be
turned off so it needs to know the cursor behavior at commit times...if
prepared statements and cursors are
destroyed then my software will not work....so the driver connect method
must tell me if
SQLCommitsSupported = TRUE.

The run log from the code is below....

You can see that the call to unconditionally set autocommit off (for
testing) returns SQLCODE=0.

But the call to SQLGetInfo returns 65536 (all 1's I think this is...) which
would seem to indicate that an
incorrect data type was passed to the SQLGetInfo routine.  I have defined
ws_SQLCursorCommitBehavior as
SQLUINTEGER.  I am running on AIX 64 with the easysoft AIX/Oracle driver.

This code works and returns the correct value on win2000 using the Oracle
driver. I was thinking that anyone else
out there who has done AIX 64 bit easysoft Oracle SQLGetInfo calls to
determine cursor behavior might be able to
tell me if I have done something wrong here...


Also, does the Easysoft driver support user commits?  I am forcing my code
to issue commits every 10,000 rows but
when I look at the TOAD/DBXray logs I see that the software is still issuing
one commit per every row inserted/updated.

It seems that even though I have made the call to set autocommit off and
gotten a 0 return code that the driver is
still auto committing. Again, I believe this is working correctly on win2000
and SQL Server but I am not absolutely
sure since I cannot see the autocommit behavior on SQL Server....I will try
out oracle on win2000 and see...

But any suggestions on how to define ws_SQLCursorCommitBehavior properly on
AIX 64 would be much appreciated...

Best Regards

Peter Nolan.



Run Log.................

begin CODBCDatabase::DriverConnect
Autocommit is false
setting autocommit off and the SQLCODE from this call
SQLCODE=0
check the cursor commit behavior
ws_SQLCursorCommitBehavior=0
ws_SQLCursorCommitBehavior=65536
SQLCODE=0
SQLCommitsSupported=0
end CODBCDatabase::DriverConnect



definition of  ws_SQLCursorCommitBehavior

SQLUINTEGER ws_SQLCursorCommitBehavior ;



DriverConnect method.........................................

BOOL CODBCDatabase::DriverConnect(CHAR* szConnStr, CHAR* szConnStrOut, HWND
hWnd, enum drvCompletion drvConn)
BEGIN_

 SQLSMALLINT pcbConnStrOut;
  int ws_debug_level = 9;

DEBUG_PRINT (begin CODBCDatabase::DriverConnect ) ;

 if(drvConn == sqlPrompt && hWnd == NULL)
  return FALSE;

 if(ConnectionTimeout > 0)
      BEGIN_
  SQLCODE = SQLSetConnectAttr(DBConnectionHandle,
SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER)ConnectionTimeout, 0);
   END_

 SQLCODE = SQLSetConnectAttr(DBConnectionHandle, SQL_ATTR_LOGIN_TIMEOUT,
(SQLPOINTER)LoginTimeout, 0);

    IF (AutoCommit EQUALS_ TRUE) THEN
   BEGIN_
//  SQLCODE = SQLSetConnectAttr(DBConnectionHandle, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_ON, 0);
DEBUG_PRINT (Autocommit is true ) ;

   END_
    ELSE
   BEGIN_
  SQLCODE = SQLSetConnectAttr(DBConnectionHandle, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_OFF, 0);
DEBUG_PRINT  (Autocommit is false ) ;
   END_

// unconditional call for testing....
 SQLCODE = SQLSetConnectAttr(DBConnectionHandle, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_OFF, 0);

DEBUG_PRINT  (setting autocommit off and the SQLCODE from this call ) ;
DEBUG_VARIABLE  (SQLCODE ) ;

 SQLCODE = SQLDriverConnect(DBConnectionHandle,
       hWnd,
       (SQLCHAR*)szConnStr,
       SQL_NTS,
       (SQLCHAR*)szConnStrOut,
       sizeof(szConnStrOut),
       &pcbConnStrOut,
       (SQLUSMALLINT)drvConn);

 IsConnectedFlag = SQLCODE_SUCCEEDED(SQLCODE) ;
////////////////////////////////////////////////////////////////////////////
//////////////////
//  Check the call.
        //
////////////////////////////////////////////////////////////////////////////
//////////////////
    SQL_OK  = SQLCODE_SUCCEEDED(SQLCODE) ;
 CALL_RETURNED_OK = SQL_OK ;
////////////////////////////////////////////////////////////////////////////
//////////////////
//  If the call did not work then get the error messages using the
//
//  GetConnectionHandleErrorMessages method and return the fact that the
call did not work. //
////////////////////////////////////////////////////////////////////////////
//////////////////
 IF (!CALL_RETURNED_OK) THEN
   BEGIN_
     GetConnectionHandleErrorMessages(DBConnectionHandle) ;
  return IsConnectedFlag;
   END_

 ws_SQLCursorCommitBehavior = 0 ;
DEBUG_PRINT  (check the cursor commit behavior ) ;
DEBUG_VARIABLE  (ws_SQLCursorCommitBehavior ) ;

 SQLCODE = SQLGetInfo( DBConnectionHandle,
                       SQL_CURSOR_COMMIT_BEHAVIOR,
                      (SQLPOINTER) &ws_SQLCursorCommitBehavior,
                sizeof(ws_SQLCursorCommitBehavior),
        NULL);
DEBUG_VARIABLE  (ws_SQLCursorCommitBehavior ) ;
DEBUG_VARIABLE  (SQLCODE ) ;

////////////////////////////////////////////////////////////////////////////
//////////////////
//  Check the call.
//
////////////////////////////////////////////////////////////////////////////
//////////////////
  SQL_OK  = SQLCODE_SUCCEEDED(SQLCODE) ;
  CALL_RETURNED_OK = SQL_OK ;
////////////////////////////////////////////////////////////////////////////
//////////////////
//  If the call did not work then get the error messages using the
//
//  GetConnectionHandleErrorMessages method and return the fact that the
call did not work. //
////////////////////////////////////////////////////////////////////////////
//////////////////
  IF (CALL_RETURNED_OK) THEN
    BEGIN_
      IF((ws_SQLCursorCommitBehavior EQUALS_ SQL_CB_CLOSE)
OR_(ws_SQLCursorCommitBehavior EQUALS_ SQL_CB_PRESERVE)) THEN
     BEGIN_
    SQLCommitsSupported = TRUE ;
     END_
       END_
DEBUG_VARIABLE  (SQLCommitsSupported ) ;

DEBUG_PRINT (end CODBCDatabase::DriverConnect ) ;

 return IsConnectedFlag;
END_





More information about the unixODBC-dev mailing list