Re: Getting oid with libpq - Mailing list pgsql-interfaces

From jtv@xs4all.nl
Subject Re: Getting oid with libpq
Date
Msg-id 8327.202.47.227.25.1123743997.squirrel@202.47.227.25
Whole thread Raw
In response to Re: Getting oid with libpq  (jtv@xs4all.nl)
Responses Re: Getting oid with libpq
List pgsql-interfaces
Johan C. de Koning wrote:

> I am not an expert in C/C++ so do you know maybe where I can find some
> example code or documentation about the parsing process with sscanf?

In C, you'd probably want to use
 const char *OldLocale = setlocale(LC_NUMERIC, "C");

Then run the pointer returned by PQgetValue() through atol() to get a
numeric value, and finally restore the previous locale with
 setlocale(LC_NUMERIC, OldLocale);

If you're using C++, best thing to do may be to use libpqxx instead of
libpq.  It has functions to do the conversions for you, and takes care of
locale and overflow issues as well.


Jeroen




pgsql-interfaces by date:

Previous
From: David
Date:
Subject: Re: pgperl vs dbd-perl
Next
From: Tom Lane
Date:
Subject: Re: Getting oid with libpq