[unixODBC-support] unixODBC and freeTDS column-wise parameterbinding

SEUNGHO PARK shpark94 at samsung.com
Tue Jun 14 10:27:06 BST 2005


Thank you nick.
1st, I don't think that is a character conversion problem, because we don't
convert the binary data.
I don't set the parameter SQL_DESC_ARRAY_SIZE and SQL_ATTR_PARAMSET_SIZE so
maybe our application use the default value and when we get the binary data
from the DB, we set SQL_ATTR_ROW_ARRAY_SIZE 1.

I attach the source code
I add some code that write to file from the binary data of the DB.
I am still wonder that why the pData is different from data of windows
driver that was no problem .

UCHAR* CRQOdbcQueryInfo::GetLongData(RQLONG index, SDWORD& nColLen, SWORD
cType)
{
	switch(m_pDatabase->m_nDatabase)
	{
	default:
	{
		UCHAR *pData;
		SDWORD nSize;
		SDWORD fLen = 0;

		UCHAR*	lpOutData = new UCHAR[MAX_LONGDATA_FOR_ACCESS];

		pData = (UCHAR*) malloc(1L);
		if (pData == NULL)
		{
			delete lpOutData;
			return NULL;
		}

		do
		{
			// cType is SQL_C_BINARY
			m_rc = SQLGetData(m_hstmt, (RQWORD)index, cType,
lpOutData, MAX_LONGDATA_FOR_ACCESS, &nColLen);

			if (m_rc != SQL_SUCCESS && m_rc !=
SQL_SUCCESS_WITH_INFO)
			{
				delete lpOutData;
				free(pData);
				return NULL;
			}
			
			if (nColLen == SQL_NULL_DATA)
			{
				delete lpOutData;
				free(pData);
				return NULL;
			}

			pData = (UCHAR*) realloc(pData, fLen+nColLen+1);

			if (m_rc == SQL_SUCCESS) 
				nSize = nColLen;
			else 
				nSize = MAX_LONGDATA_FOR_ACCESS;
			memcpy(pData+fLen, (UCHAR *)lpOutData, nSize);
			fLen += nSize;
		}
		while (m_rc == SQL_SUCCESS_WITH_INFO);

		nColLen = fLen;
		delete [] lpOutData;
		// determine the image pData
		FILE *pFile;
		pFile = fopen( "image_win.bmp", "w+b" );
		RQLONG	ret = fseek(pFile, 0, SEEK_END);
		if ( fwrite(pData, sizeof(UCHAR), nColLen, pFile) != nColLen
)
		;
		fclose(pFile);

		return pData;
	}	// default
	}	// end of switch

	return NULL;
}

-----Original Message-----
From: unixodbc-support-bounces at easysoft.com
[mailto:unixodbc-support-bounces at easysoft.com] On Behalf Of Nick Gorham
Sent: Tuesday, June 14, 2005 5:33 PM
To: Support for the unixODBC project
Subject: Re: [unixODBC-support] unixODBC and freeTDS column-wise
parameterbinding

Alexander Zlotnikov (azlotnlk) wrote:

> Martin/Nick
> Thank you for quick response.
> It does seem to point to the driver rather then DM. The reason I have 
> suspected DM is because two different drivers ( freeTDS and 
> DataDirect) behave the same way with unixODBC. My code works as 
> expected if I use DataDirect driver manager and DataDirect ms-sql 
> driver.  I could not get freeTDS to work with DataDirect DM.
>  
> Martin, I use a separate array for each parameter and specify 
> SQL_ATTR_PARAM_BIND_TYPE as SQL_PARAMETER_BIND_BY_COLUMN  
>  
> Thank you,
> Alex

Hi,

Out of interest, can you send a log of what happens with DataDirect and 
unixODBC I am interested to see what the difference could be. I don't 
know (but others may) if the freeTDS driver supports arrays of parameters.

How are you setting the size of the parameter array. via the statement 
attr SQL_ATTR_PARAMSET_SIZE, or the descriptor header value 
SQL_DESC_ARRAY_SIZE in the APD?

What platform is it on BTW.

If the unixODBC DM detects a ODBC 2 driver, it will map a 
SQL_ATTR_ROW_ARRAY_SIZE SQLSetStmtAttr to a SQL_ROWSET_SIZE but it 
doesn't go near SQL_ATTR_PARAMSET_SIZE.

-- 
Nick

>  
>  
> Date: Sat, 11 Jun 2005 00:42:18 +0100
> From: Nick Gorham <nick.gorham at easysoft.com 
> <mailto:nick.gorham at easysoft.com>>
> Subject: Re: [unixODBC-support] unixODBC and freeTDS column-wise
>  parameter binding
> To: Support for the unixODBC project <unixodbc-support at easysoft.com 
> <mailto:unixodbc-support at easysoft.com>>
> Message-ID: <42AA255A.7070006 at easysoft.com 
> <mailto:42AA255A.7070006 at easysoft.com>>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>  
> Martin J. Evans wrote:
>  
>> I can confirm that array bound parameters work fine in unixODBC with a
>> number of drivers I have. You say "column-wide" and then "parameters"
>> and I can also confirm array bound columns bound to a result-set work
>> fine in unixODBC with various drivers I have here. I'd suggest you
>> would be better directing this to the FreeTDS list.
>>
>> Martin
>>
>> Alex Zlotnikov wrote:
>>
>>> Column-wide parameter binding does not seems to work with
>>> unixODBC/freeTDS. Only first set of parameters values are being
>>> passed to ms-sql server. The same code works as expected with
>>> DataDirect driver and driver manager.  But if  unixODBC used with
>>> DataDirect driver, I see the same behavior where only first values 
> are passed.
>>> Thank you,
>>> Alex
>>
> In actual fact the DM has very little to do with this, the pointer is 
> passed from the app to the driver without change by the driver manager.
>  
> --
> Nick
>
>------------------------------------------------------------------------
>
>_______________________________________________
>unixODBC-support mailing list
>unixODBC-support at easysoft.com
>http://mail.easysoft.com/mailman/listinfo/unixodbc-support
>  
>

_______________________________________________
unixODBC-support mailing list
unixODBC-support at easysoft.com
http://mail.easysoft.com/mailman/listinfo/unixodbc-support





More information about the unixODBC-support mailing list