[freetds] (ODBC) processing multiple statements on one connec tio n

Thompson, Bill D (London) bill_d_thompson at ml.com
Fri Apr 30 03:59:46 EDT 2004


Hi Roger,

> Anyway, please tell me if you can - there must be some attribute to set or
> something that would allow this scenario to succeed.
> Right?

Wrong, alas.

This functionality isn only possible if the driver supports true
cursor-style 
interaction with the server.

Freetds does not support cursors at present.

I am (on and off) working on cursor support in freetds, but I am only
working with our ct-library api.
when, or if, I am able to introduce theoretical support for cursors, there
would be a good deal of work to do on the ODBC api...

ATM, your only option is to have two connections to the server.

Sorry for the bad news,

Bill

> -----Original Message-----
> From:	Roger Reynolds [SMTP:rogerr at softix.com]
> Sent:	30 April 2004 08:11
> To:	'FreeTDS Development Group'
> Subject:	[freetds] (ODBC) processing multiple statements on one
> connectio n
> 
> Right off, let state that the following may likely have
> more to do with ODBC in general, than freetds in particular,
> but maybe somebody here can help me out (I hope).
> 
> Essentially, the problem is that I need to operate on two
> statements against the same connection in parallel.
> That is, as each row is fetched from one statement, to be
> able to execute a second statement on that same connection.
> 
> The following code illustrates:
> 
>     // assume you have a connection handle called svc
>     // assume you have a table called "test_table" with 
>     // an int column "t1" and test_table has at least 
>     // one row of data
>  
>     HSTMT stmtHandle;
> 	
>     SQLAllocStmt(svc, &stmtHandle);
> 
>     const char* s = "select t1 from test_table";
> 
>     SQLPrepare(stmtHandle, (SQLCHAR*) s, SQL_NTS);
>     
>     SQLExecute(stmtHandle);
> 
>     int val;
>     long ind;
>     SQLBindCol(stmtHandle, 1, SQL_C_LONG, &val, sizeof(val), &ind);
> 
>     while (SQLFetch(stmtHandle) == 0) {
> 	HSTMT s2;
> 
> 	SQLAllocStmt(svc, &s2);
> 
>       printf ("val = %d\n", val);
> 	const char* s = "insert into t2 values(0)";
> 	if (SQLExecDirect(s2, (SQLCHAR*)s, SQL_NTS) != SQL_SUCCESS)
> 	    printf("s2 failed!\n");
> 	SQLFreeStmt (s2, SQL_CLOSE);
>     }
>     
> When I run this, I get the following error from SQLExecDirect:
> 
>     Attempt to initiate a new SQL Server operation with results pending.
> 
> and an SQLSTATE of 07005, and a "native error code" of 20019 
> 
> Interestingly, the description of SQLSTATE 07005 from
> 
>  
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/
> od
> bcodbc_error_codes.asp
> 
> is described as
>   
>   Prepared statement not a cursor-specification
> 
> and isn't claimed to be generated by SQLExecDirect.
> Curious.
> 
> 
> Anyway, please tell me if you can - there must be some attribute to set or
> something
> that would allow this scenario to succeed.
> 
> Right?
> 
> Thanks for your help.
> 
> roger
> 
> 
> 
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

==============================================================================

If you are not an intended recipient of this e-mail, please notify
the sender, delete it and do not read, act upon, print, disclose,
copy, retain or redistribute it.

Click here for important additional terms relating to this e-mail.
     <http://www.ml.com/email_terms/>

==============================================================================




More information about the FreeTDS mailing list