1 /**********************************************************************
2 * SQLFreeConnect
3 *
4 * Do not try to Free Dbc if there are Stmts... return an error. Let the
5 * Driver Manager do a recursive clean up if it wants.
6 *
7 **********************************************************************
8 *
9 * This code was created by Peter Harvey (mostly during Christmas 98/99).
10 * This code is LGPL. Please ensure that this message remains in future
11 * distributions and uses of this code (thats about all I get out of it).
12 * - Peter Harvey pharvey@codebydesign.com
13 *
14 **********************************************************************/
15
16 #include <config.h>
17 #include "driver.h"
18
_FreeConnect(SQLHDBC hDrvDbc)19 SQLRETURN _FreeConnect( SQLHDBC hDrvDbc )
20 {
21 HDRVDBC hDbc = (HDRVDBC)hDrvDbc;
22 int nReturn;
23
24 /* SANITY CHECKS */
25 if( NULL == hDbc )
26 return SQL_INVALID_HANDLE;
27
28 sprintf((char*) hDbc->szSqlMsg, "hDbc = $%08lX", (long)hDbc );
29 logPushMsg( hDbc->hLog, __FILE__, __FILE__, __LINE__, LOG_WARNING, LOG_WARNING, (char*)hDbc->szSqlMsg );
30
31 if( hDbc->bConnected )
32 {
33 logPushMsg( hDbc->hLog, __FILE__, __FILE__, __LINE__, LOG_WARNING, LOG_WARNING, "SQL_ERROR Connection is active" );
34 return SQL_ERROR;
35 }
36
37 if ( hDbc->hFirstStmt != NULL )
38 {
39 logPushMsg( hDbc->hLog, __FILE__, __FILE__, __LINE__, LOG_WARNING, LOG_WARNING, "SQL_ERROR Connection has allocated statements" );
40 return SQL_ERROR;
41 }
42
43 nReturn = _FreeDbc( hDbc );
44
45 return nReturn;
46
47 }
48
SQLFreeConnect(SQLHDBC hDrvDbc)49 SQLRETURN SQLFreeConnect( SQLHDBC hDrvDbc )
50 {
51 return _FreeConnect( hDrvDbc );
52 }
53
54