Re: C++: get value for integral types? - Mailing list pgsql-general

From Tommi Maekitalo
Subject Re: C++: get value for integral types?
Date
Msg-id 200211110853.01940.t.maekitalo@epgmbh.de
Whole thread Raw
In response to Re: C++: get value for integral types?  (Frank Miles <fpm@u.washington.edu>)
Responses Re: C++: get value for integral types?  (Vassil Kriakov <vassilk@yahoo.com>)
List pgsql-general
Hi,

it would be hard to interpret the binary value. I think it is not specified,
how a specific type is represented as a binary value. The programmers guide
just tells: "But if PQbinaryTuples() is 1, the value returned by PQgetvalue
is the binary representation of the type in the internal format of the
backend server". So its internal and platformspecific. It is even hard to get
usable type-information. The types are defined in a systemtable (pg_type).
But new types are created in some situations, when you just create a new
table.

I think the safest way to retrieve values in C++ is to convert the
stringrepresentation.

It might be helpful to define some api-functions to retrieve some integral
types (PGgetLong, PGgetDouble). The backendprocess knows better about
datatypes. What do you think?


Tommi

Am Sonntag, 10. November 2002 23:56 schrieb Frank Miles:
> On Sun, 10 Nov 2002, Vassil Kriakov wrote:
> > Does anyone know whether it is possible to get a tuple's value as an
> > int, float, bool, etc. using the C++ postgresql library?
> >
> > Getting floats as string representations (via char* GetValue(...)) of
> > the value is not acceptable! Using strings and streams to convert the
> > values to the corresponding integral type may cause problems!
> >
> > Any ideas, workarounds? Is BinaryTuples really not implemnted yet?
>
> Doesn't the C++ version work?  Have you DECLAREd a binary cursor and
> used FETCH to get the data?  (It works with libpq)
>
> HTH--
>
>     -frank
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
Dr. Eckhardt + Partner GmbH
http://www.epgmbh.de

pgsql-general by date:

Previous
From: Justin Clift
Date:
Subject: Re: PostgreySQl.
Next
From: "scott.marlowe"
Date:
Subject: Re: Hardware estimation