Re: Need Info

From: jtv <jtv(at)xs4all(dot)nl>
To: Shamik Majumder <shamik(dot)majumder(at)wipro(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Need Info
Date: 2002-02-02 11:06:10
Message-ID: 20020202120610.D25362@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Mon, Jan 28, 2002 at 12:15:20PM +0530, Shamik Majumder wrote:
>
> My problem is - for my application, I need to have the values back in
> their proper format, that means if the datatyoe of one field is integer,
> I want to get it back as an integer type and not as a string.

Two ways:

1. Binary result sets. This gets a little hairy because you'll need to
do your own conversion to your client platform's sizes, byte sex etc.
Documentation doesn't provide all that much in the way of details either.

2. Convert the strings to the right types yourself, using either sscanf()
or atoi() and its friends.

Or if you happen to be writing in C++, you may want to check out my new
C++ frontend (currently in development but quite usable), which lets you
write stuff like

Result R = T.Exec("select number from mytable where id=123");
int n;
if (!R[0][0].to(n)) throw runtime_error("No number set!");

You can find this library at

http://members.ams.chello.nl/j.vermeulen31/proj-libpqxx.html

HTH,

Jeroen

In response to

  • Need Info at 2002-01-28 06:45:20 from Shamik Majumder

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message jtv 2002-02-02 11:12:19 Re: having a whole lot of trouble...
Previous Message jtv 2002-02-02 10:57:26 Re: having a whole lot of trouble...