[unixODBC-support] Issue with long queries with FreeTDS

Cristian Mammoli cristian.mammoli at gmail.com
Thu Oct 23 17:45:18 BST 2008


Hi I have a problem with a query with FreeTDS driver. Performing a long 
query (1322 characters) with isql results in [ISQL]ERROR: Could not 
SQLExecute. A shorter one (300 characters) works like a charm. The query 
is syntactically correct and works great with the FreeTDS tools such as 
bsqldb and tsql.

My odbcinst.ini:
[FreeTDS]
Description  = v0.63 with protocol v8.0
Driver  = /usr/lib/libtdsodbc.so
Driver64  =
Setup  =
Setup64  =
UsageCount  = 1
CPTimeout  =
CPReuse  =

[ODBC]
Trace  = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling  = Yes

My odbc.ini:
[WINE_40]
Driver  = FreeTDS
Description = DB WINE_40 on SRV346
Trace  = No
Server  = SRV346
Port   = 1433
Database = WINE_40

The query:
[root at faxapra ~]# echo "SELECT CF.COD_CF, CF.RAG_SOC_CF, CF.INDI_CF, 
CF.CAP_CF, CF.COMUNE_CF, CF.PROVINCIA_CF, CF.TEL_CF, CF.FAX_CF, 
CF.E_MAIL_CF, CF.NOTE_CF, CF.P_IVA_CF, Case when (CF.COD_CAT <> '' and 
CF_CLI.COD_CAT <> '' and CF_FOR.COD_CAT <> '') then CF.COD_CAT + ';' + 
CF_CLI.COD_CAT + ';' + CF_FOR.COD_CAT else Case when (CF.COD_CAT = '' 
and CF_CLI.COD_CAT = '' and CF_FOR.COD_CAT = '') then '' else Case when 
(CF.COD_CAT <> '' and CF_CLI.COD_CAT = '' and CF_FOR.COD_CAT = '') then 
CF.COD_CAT else Case when (CF.COD_CAT = '' and CF_CLI.COD_CAT <> '' and 
CF_FOR.COD_CAT = '') then CF_CLI.COD_CAT else Case when (CF.COD_CAT = '' 
and CF_CLI.COD_CAT = '' and CF_FOR.COD_CAT <> '') then CF_FOR.COD_CAT 
else Case when (CF.COD_CAT <> '' and CF_CLI.COD_CAT <> '' and 
CF_FOR.COD_CAT = '') then CF.COD_CAT + ';' + CF_CLI.COD_CAT else Case 
when (CF.COD_CAT = '' and CF_CLI.COD_CAT <> '' and CF_FOR.COD_CAT <> '') 
then CF_CLI.COD_CAT + ';' + CF_FOR.COD_CAT else Case when (CF.COD_CAT <> 
'' and CF_CLI.COD_CAT = '' and CF_FOR.COD_CAT <> '') then CF.COD_CAT + 
';' + CF_FOR.COD_CAT end end end end end end end end AS CODCAT FROM CF 
INNER JOIN CF_CLI ON CF.COD_CF = CF_CLI.COD_CF INNER JOIN CF_FOR ON 
CF.COD_CF = CF_FOR.COD_CF order by CF.COD_CF" | isql wine_40 sa essentia
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
[ISQL]ERROR: Could not SQLExecute

Trace File:

[...]
[ODBC][10058][SQLConnect.c][3549]
                Entry:
                        Connection = 0x9ba7130
                        Server Name = [wine_40][length = 7 (SQL_NTS)]
                        User Name = [sa][length = 2 (SQL_NTS)]
                        Authentication = [********][length = 8 (SQL_NTS)]
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 
'UCS-2LE'

[ODBC][10058][SQLConnect.c][4123]
                Exit:[SQL_SUCCESS]
[ODBC][10058][SQLAllocHandle.c][510]
                Entry:
                        Handle Type = 3
                        Input Handle = 0x9ba7130
[ODBC][10058][SQLAllocHandle.c][872]
                Exit:[SQL_SUCCESS]
                        Output Handle = 0x9bbb0f8
[ODBC][10058][SQLPrepare.c][189]
                Entry:
                        Statement = 0x9bbb0f8
                        SQL = [SELECT CF.COD_CF, CF.RAG_SOC_CF, 
CF.INDI_CF, CF.CAP_CF, CF.COMUNE_CF, CF.PROVINCIA_CF, CF.TEL_C
F, CF.FAX_CF, CF.E_MAIL_CF, CF.NO...][length = 1213 (SQL_NTS)]
[ODBC][10058][SQLPrepare.c][364]
                Exit:[SQL_SUCCESS]
[ODBC][10058][SQLExecute.c][183]
                Entry:
                        Statement = 0x9bbb0f8
[ODBC][10058][SQLExecute.c][344]
                Exit:[SQL_ERROR]
                DIAG [08S01] [FreeTDS][SQL Server]Read from SQL server 
failed.

[ODBC][10058][SQLFreeStmt.c][140]
                Entry:
                        Statement = 0x9bbb0f8
                        Option = 1
[ODBC][10058][SQLFreeHandle.c][365]
                Entry:
                        Handle Type = 3
                        Input Handle = 0x9bbb0f8
[ODBC][10058][SQLFreeHandle.c][462]
                Exit:[SQL_SUCCESS]
                DIAG [08S01] [FreeTDS][SQL Server]Write to SQL Server 
failed.

[ODBC][10058][SQLDisconnect.c][204]
[...]

Any help is greatly appreciated

Cristian



More information about the unixODBC-support mailing list