28
28
**********************************************************************
30
* $Id: SQLTransact.c,v 1.1.1.1 2001/10/17 16:40:07 lurcher Exp $
30
* $Id: SQLTransact.c,v 1.6 2002/12/05 17:44:31 lurcher Exp $
32
32
* $Log: SQLTransact.c,v $
33
* Revision 1.6 2002/12/05 17:44:31 lurcher
35
* Display unknown return values in return logging
37
* Revision 1.5 2002/09/18 14:49:32 lurcher
39
* DataManagerII additions and some more threading fixes
41
* Revision 1.3 2002/08/20 12:41:07 lurcher
43
* Fix incorrect return state from SQLEndTran/SQLTransact
45
* Revision 1.2 2002/08/12 16:20:44 lurcher
47
* Make it try and find a working iconv set of encodings
33
49
* Revision 1.1.1.1 2001/10/17 16:40:07 lurcher
35
51
* First upload to SourceForge
108
124
#include "drivermanager.h"
110
static char const rcsid[]= "$RCSfile: SQLTransact.c,v $ $Revision: 1.1.1.1 $";
126
static char const rcsid[]= "$RCSfile: SQLTransact.c,v $ $Revision: 1.6 $";
112
128
SQLRETURN SQLTransact( SQLHENV environment_handle,
113
129
SQLHDBC connection_handle,
114
130
SQLUSMALLINT completion_type )
132
SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ];
116
134
if ( connection_handle != SQL_NULL_HDBC )
118
136
DMHDBC connection = (DMHDBC) connection_handle;
218
236
return function_return( connection, SQL_ERROR );
239
if( SQL_SUCCEEDED(ret) )
242
SQLINTEGER stmt_remaining;
243
SQLSMALLINT cb_value;
244
SQLSMALLINT cb_value_length = sizeof(SQLSMALLINT);
248
* for each statement belonging to this connection set its state
249
* relative to the commit or rollback behavior
252
statement = __get_stmt_root();
253
stmt_remaining = connection -> statement_count;
255
/* release thread so we can get the info */
256
thread_release( SQL_HANDLE_DBC, connection );
258
if( completion_type == SQL_COMMIT )
260
ret1 = SQLGetInfo(connection,
261
SQL_CURSOR_COMMIT_BEHAVIOR,
266
else /*SQL_ROLLBACK*/
268
ret1 = SQLGetInfo(connection,
269
SQL_CURSOR_ROLLBACK_BEHAVIOR,
275
/* protect thread again */
276
thread_protect( SQL_HANDLE_DBC, connection );
278
if( SQL_SUCCEEDED( ret1 ) )
280
while ( statement && stmt_remaining > 0 )
282
if ( statement -> connection == connection )
284
if ( (statement -> state == STATE_S2 ||
285
statement -> state == STATE_S3) &&
286
cb_value == SQL_CB_DELETE )
288
statement -> state = STATE_S1;
289
statement -> prepared = 0;
291
else if ( statement -> state == STATE_S4 ||
292
statement -> state == STATE_S5 ||
293
statement -> state == STATE_S6 ||
294
statement -> state == STATE_S7 )
296
if( !statement -> prepared &&
297
(cb_value == SQL_CB_DELETE ||
298
cb_value == SQL_CB_CLOSE) )
300
statement -> state = STATE_S1;
302
else if( statement -> prepared )
304
if( cb_value == SQL_CB_DELETE )
306
statement -> state = STATE_S1;
307
statement -> prepared = 0;
309
else if( cb_value == SQL_CB_CLOSE )
311
if ( statement -> state == STATE_S4 )
312
statement -> state = STATE_S2;
314
statement -> state = STATE_S3;
320
statement = statement -> next_class_list;
221
325
if ( log_info.log_flag )
223
327
sprintf( connection -> msg,
224
328
"\n\t\tExit:[%s]",
225
__get_return_status( ret ));
329
__get_return_status( ret, s1 ));
227
331
dm_log_write( __FILE__,