Re: ODBC Error while selecting a numeric data field - Mailing list pgsql-general

From Tom Ince
Subject Re: ODBC Error while selecting a numeric data field
Date
Msg-id c8GX8.792$iI5.303@nwrddc03.gnilink.net
Whole thread Raw
In response to ODBC Error while selecting a numeric data field  ("Tom Ince" <tom.ince@netzero.net>)
Responses Re: ODBC Error while selecting a numeric data field
List pgsql-general
Well, I have managed to get the ODBC SQL select call to work with the
NUMERIC database type.

In the Windows ODBC Help file there is a section called "Converting Data
from SQL to C Data Types"

In this section there is a chart which shows the default conversion for the
SQL_NUMERIC data type to
a C data type is SQL_C_CHAR.  So I made a stab and used that in my
SQLBindCol statement and it worked!

Here is my SQLBindCol statement that didn't work :
rc = SQLBindCol ( hstmt, i+1, SQL_C_NUMERIC, &fields[i].variant.f_numeric,
fields[i].size, &fields[i].length );

and here is the one that now works :
rc = SQLBindCol ( hstmt, i+1, SQL_C_CHAR, &fields[i].variant.f_char,
fields[i].size, &fields[i].length );

I am still a little curious as to why the original way did not work, if
anyone can point that out to me it would be
greatly appreciated...


"Tom Ince" <tom.ince@netzero.net> wrote in message
news:_CEX8.812$ak5.680@nwrddc01.gnilink.net...
> I have done a test and created the table with the field being a float
> instead
> of numeric and everything works fine.
>
> Any help please???
>
>
> "Tom Ince" <tom.ince@netzero.net> wrote in message
> news:OLCX8.718$ak5.93@nwrddc01.gnilink.net...
> > I have tried PostgreSQL version 7.1.3 with iODBC-3.0.5
> >
> > and
> >
> > PostgreSQL version 7.2.1 with iODBC-3.0.6
> >
> > and in both cases I get an error when attempting to do a select on a
field
> > with the numeric data type.
> >
> > Using the psql program I do the following :
> >
> > CREATE TABLE test (lat numeric(9,6) );
> > INSERT INTO test VALUES (12.23);
> > SELECT * FROM test;
> >
> > When I do the select in the psql program I get  :
> >
> >     lat
> > ----------
> >  12.230000
> > (1 row)
> >
> >
> > Now, I have an application attempting to perform the same SELECT
statement
> > using the iODBC drivers SDK.
> > When calling SQLFetch with a SELECT statement attempting to pull data
from
> a
> > field of type NUMERIC, I get
> > the error :
> >
> > 07006
> > Received an unsupported type from Postgres.
> >
> >
> > Please help....
> >
> >
> >
>
>



pgsql-general by date:

Previous
From: "Ravi Malghan"
Date:
Subject: tcl/tk - postgresql ?
Next
From: "Tom Ince"
Date:
Subject: Re: ODBC Error while selecting a numeric data field