pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jtv@xs4all.nl
To: Johan C. de Koning <johan.de.koning@geodan.nl>
Cc: jtv@xs4all.nl
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Getting oid with libpq
Date: Thu, 11 Aug 2005 09:06:37 +0200 (CEST)
Message-ID: <8327.202.47.227.25.1123743997.squirrel@202.47.227.25> (raw)
In-Reply-To: <200508101213.j7ACD9lb077874@mxdrop11.xs4all.nl>
References: <10445.202.47.227.25.1123671132.squirrel@202.47.227.25>
	<200508101213.j7ACD9lb077874@mxdrop11.xs4all.nl>

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





view thread (7+ messages)  latest in thread

Message-ID: <8327.202.47.227.25.1123743997.squirrel@202.47.227.25>
Permalink:  ../8327.202.47.227.25.1123743997.squirrel@202.47.227.25/
Also on:    postgresql.org/message-id/8327.202.47.227.25.1123743997.squirrel@202.47.227.25

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jtv@xs4all.nl, johan.de.koning@geodan.nl
  Subject: Re: Getting oid with libpq
  In-Reply-To: <8327.202.47.227.25.1123743997.squirrel@202.47.227.25>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox