freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "cui yanxin" <cuiyanxin AT hotmail.com>
- To: freetds AT lists.ibiblio.org
- Subject: [freetds] Two statements on one connection
- Date: Fri, 02 Dec 2005 21:58:42 +0000
Thanks for all your reply.
BTW, freeddy77, how to 'enable' the cursor you mentioned? Is it on ODBC driver side or SQL Server side?
----------------------------------------- you said ---------------------------------
Enabling cursor would---------------------------------------------------------------------------------
allow you (for instance) to do a select and use results for another
query using same connection.
Dear All,
I am using freeTDS 0.63 and unixODBC under Redhat 7.1. Is it OK to use two statements on one connection? The below code gives me 'invalid cursor state' error while trying to do the second SQLExexDirect(). The code works fine for Oracle and MySQL drivers. What should I do if I want to achieve the below goal(e.g. fetch one table inside loopof fetching another table)?
.......
V_OD_erg=SQLExecDirect(V_OD_hstmt,"select employeeid,firstname,hiredate,
salary,dsc FROM employees", SQL_NTS);
SQLAllocHandle(SQL_HANDLE_STMT, V_OD_hdbc, &V_OD_hstmt2);
SQLBindCol(V_OD_hstmt2,1,SQL_C_CHAR,&V_OD_buffer2,150,&V_OD_err);
V_OD_erg=SQLExecDirect(V_OD_hstmt2,"select firstname from table2 ", SQL_NTS);
V_OD_erg=SQLFetch(V_OD_hstmt);
while(V_OD_erg != SQL_NO_DATA)
{
printf("row(%d) Result: [%d] [%s] [%s] [%f] [%s]\n",
i,V_OD_id,V_OD_buffer,V_OD_date,V_OD_double,V_OD_dsc);
V_OD_erg=SQLFetch(V_OD_hstmt2);
printf("second Result: [%s]\n", V_OD_buffer2 );
V_OD_erg=SQLFetch(V_OD_hstmt);
i++;
};
Regards
Yanxin
Short reply:
use two connections
Long reply:
mssql by default (using normal queries) do not allow two active
statement on same connection. This for TDS protocol limit. There is
however an option witch is the use of cursors. Enabling cursor would
allow you (for instance) to do a select and use results for another
query using same connection. However currectly FreeTDS odbc driver do
not provide cursors support...
freddy77
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-
[freetds] Two statements on one connection,
cui yanxin, 12/02/2005
- <Possible follow-up(s)>
- [freetds] Two statements on one connection, cui yanxin, 12/02/2005
- Re: [freetds] Two statements on one connection, ZIGLIO, Frediano, VF-IT, 12/02/2005
- Re: [freetds] Two statements on one connection, Pickett, David, 12/02/2005
- Re: [freetds] Two statements on one connection, Lowden, James K, 12/02/2005
- [freetds] Two statements on one connection, cui yanxin, 12/02/2005
- Re: [freetds] Two statements on one connection, Lowden, James K, 12/02/2005
Archive powered by MHonArc 2.6.24.