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

Re: Getting oid with libpq

From: jtv(at)xs4all(dot)nl
To: "Johan C(dot) de Koning" <johan(dot)de(dot)koning(at)geodan(dot)nl>
Cc: jtv(at)xs4all(dot)nl, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Getting oid with libpq
Date: 2005-08-11 07:06:37
Message-ID: 8327. (view raw, whole thread or download thread mbox)
Lists: 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.


In response to


pgsql-interfaces by date

Next:From: Tom LaneDate: 2005-08-11 13:57:24
Subject: Re: Getting oid with libpq
Previous:From: DavidDate: 2005-08-10 20:22:14
Subject: Re: pgperl vs dbd-perl

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