unixODBC and freeTDS column-wise parameter binding

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

unixODBC and freeTDS column-wise parameter binding

Alex Zlotnikov
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


_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unixODBC and freeTDS column-wise parameter binding

Martin J. Evans-2
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

_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unixODBC and freeTDS column-wise parameter binding

Nick Gorham
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
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unixODBC and freeTDS column-wise parameter binding

Alex Zlotnikov
In reply to this post by Alex Zlotnikov
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
 
 
Date: Sat, 11 Jun 2005 00:42:18 +0100
From: Nick Gorham <[hidden email]>
Subject: Re: [unixODBC-support] unixODBC and freeTDS column-wise
 parameter binding
To: Support for the unixODBC project <[hidden email]>
Message-ID: <[hidden email]>
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
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unixODBC and freeTDS column-wise parameter binding

Nick Gorham
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 <[hidden email]
> <mailto:[hidden email]>>
> Subject: Re: [unixODBC-support] unixODBC and freeTDS column-wise
>  parameter binding
> To: Support for the unixODBC project <[hidden email]
> <mailto:[hidden email]>>
> Message-ID: <[hidden email]
> <mailto:[hidden email]>>
> 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
>[hidden email]
>http://mail.easysoft.com/mailman/listinfo/unixodbc-support
>  
>

_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: unixODBC and freeTDS column-wise parameterbinding

박승호
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: [hidden email]
[mailto:[hidden email]] 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 <[hidden email]
> <mailto:[hidden email]>>
> Subject: Re: [unixODBC-support] unixODBC and freeTDS column-wise
>  parameter binding
> To: Support for the unixODBC project <[hidden email]
> <mailto:[hidden email]>>
> Message-ID: <[hidden email]
> <mailto:[hidden email]>>
> 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
>[hidden email]
>http://mail.easysoft.com/mailman/listinfo/unixodbc-support
>  
>

_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support


_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unixODBC and freeTDS column-wise parameterbinding

Nick Gorham
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
_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unixODBC and freeTDS column-wise parameter binding

Alex Zlotnikov
In reply to this post by Alex Zlotnikov

Hi Nick, please see the attached log files. Setting SQL_DESC_ARRAY_SIZE instead of SQL_ATTR_PARAMSET_SIZE did not make a difference. It is on Solaris 8.

Thanks,

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


_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support

unixOdbc.log (7K) Download Attachment
dataDirect.log (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: unixODBC and freeTDS column-wise parameter binding

Nick Gorham
Alexander Zlotnikov (azlotnlk) wrote:

> Hi Nick, please see the attached log files. Setting
> SQL_DESC_ARRAY_SIZE instead of SQL_ATTR_PARAMSET_SIZE did not make a
> difference. It is on Solaris 8.
>

As I said, I don't know if freeTDS supports arrays of parameters, but I
would expect the DD driver to work the same under either driver manager.
Unless the DD driver manager has some special tweeks to make it work
with the DD driver.

I don't know how much you want to look into this, but trying a copy of
Easysoft ODBC-ODBC bridge under both driver managers and enabling
traching in the bridge would show what the driver manager is passing to
the driver. The DM trace shows what the app passes to the driver manager
not what that then does with the driver.

--
Nick
_______________________________________________
unixODBC-support mailing list
[hidden email]
http://mail.easysoft.com/mailman/listinfo/unixodbc-support
Loading...