Skip site navigation (1) Skip section navigation (2)

Re: psqlodbc driver returning empty string

From: imad <immaad(at)gmail(dot)com>
To: Zahid Khan <khanzahid235(at)yahoo(dot)com>
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: psqlodbc driver returning empty string
Date: 2009-05-14 14:52:01
Message-ID: 1f30b80c0905140752k11844aao33edb9b8997c0bb6@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-odbc
I believe you are retrieving value of a varchar type column which is
variable length. According to MS documentation, SQLGetData returns
value of variable length field on multiple calls. That is why it is
designed like that. In your case all the value is returned in the
first call and second call has nothing to return. If you try with a
fixed length field like INT or DATE it should work on subsequent
calls.

This is where I get my reference from
http://msdn.microsoft.com/en-us/library/ms715441.aspx

--Imad


On Thu, May 14, 2009 at 11:44 PM, Zahid Khan <khanzahid235(at)yahoo(dot)com> wrote:
>
> Hi All,
>
>
> I am facing a issue in psqlodbc driver, that when i try to get the value of
> same colum twice throug ADO,odbc driver sends the empty value on second
> iteration.e.g if we get 'value1' of colum 'a' and we try to fetch the same
> value through ADO in loop then we will get a empty string.
>
> After investigation ,I found that odbc driver is explicit returning
> NO_DATA_FOUND on the column if that is already fetched .following is the
> code snippt in convert.c.
>
> if (pgdc->data_left == 0)
>         {
>             if (pgdc->ttlbuf != NULL)
>             {
>                 free(pgdc->ttlbuf);
>                 pgdc->ttlbuf = NULL;
>                 pgdc->ttlbuflen = 0;
>             }
>             pgdc->data_left = -2;        /* needed by ADO ? */
>             return COPY_NO_DATA_FOUND;
>         }
>
>  We can fix this by not returning NO_DATA_FOUND on the column value which is
> already fetched .We can allow the driver to copy same value in client buffer
> even that was fetched already.I have written C code to test this
> scenario.Following is the code snippet which will help in more
> understanding.
>
>         rc=SQLFetch(*(*hStmt));
>         if(SQL_NO_DATA == rc)
>         {
>             printf("No Data...\r\n");
>             return 0;
>         }
>
> Till here lets say we have fetched the data on driver.
>
> Now following call of  SQLGetData() will copy the value of colum '1' (second
> param) into the client buffer.which is good.
>
>         SQLGetData( *(*hStmt),1,SQL_C_CHAR,szData,sizeof(szData),&cbData);
>         printf("Date one call = [%s]\n",szData);
>
>
> Now we have same following call of SQLGetData() and trying to get same
> colum('1') second time.But the driver is returing NO_DATA_FOUND in code and
> no string copied in buffer.
>
>         SQLGetData( *(*hStmt),1,SQL_C_CHAR,szData,sizeof(szData),&cbData);
>         printf("Data 2 call = [%s]\n",szData);
>
> I hope I am able to describe the whole scenario.We can fix this by not
> returning NO_DATA_FOUND. But I wanted to confirm that if NO_DATA_FOUND is
> explicitly returned.
>
> Thanks,
> Zahid K.
>
>

In response to

pgsql-odbc by date

Next:From: Ken SellDate: 2009-05-14 22:17:34
Subject: Re: DataDirect Driver, ExecDirect and UTF-8
Previous:From: Zahid KhanDate: 2009-05-14 13:44:40
Subject: psqlodbc driver returning empty string

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group