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

Nick Gorham nick.gorham at easysoft.com
Tue Jun 14 10:36:39 BST 2005


SEUNGHO PARK wrote:

>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 think you are confusing two emails. I metioned charset as I couldn't 
read the text in your first email. The array size issue is from another 
thread in the list. Not the one you are interested in.

>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 .
>  
>

What driver are you using on the non windows side, it may be that there 
are problems, or it may be that you could try the current postgres 
driver from the DB vendors. That will build fine with a --with-unixODBC 
flag.

>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;
>}
>  
>

I am not sure why you append the data to the file each time, why not 
just write it from the start. pData and its length nColLen should 
contain the entire image.

-- 
Nick



More information about the unixODBC-support mailing list