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

Re: Getting oid with libpq

From: "Johan C(dot) de Koning" <johan(dot)de(dot)koning(at)geodan(dot)nl>
To: <jtv(at)xs4all(dot)nl>
Cc: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Getting oid with libpq
Date: 2005-08-10 12:12:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
Thanks for you answer, 

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?

Best regards,

Johan de Koning 

-----Oorspronkelijk bericht-----
Van: pgsql-interfaces-owner(at)postgresql(dot)org
[mailto:pgsql-interfaces-owner(at)postgresql(dot)org] Namens jtv(at)xs4all(dot)nl
Verzonden: woensdag 10 augustus 2005 12:52
Aan: Johan C. de Koning
CC: pgsql-interfaces(at)postgresql(dot)org
Onderwerp: Re: [INTERFACES] Getting oid with libpq

Johan C. de Koning wrote:

> I have stored some large objects (which are images) with the lo_import
> function. Now I can read the images with the other functions like lo_read
> within libpq. But I have one problem with the oid I have to give to this
> method. Inside my program I will do a select like this

> Select texture from building_face where face_id > 100;

> Textures is the oid field. When I use PQgetValue() I get a complete
> different value then when I do  a select inside pgAdmin. How can I get the
> same oid so that I can use this for reading the data of the images inside
> my c++ program. Because it is not working with the oid from PQgetValue.

Just a guess, but...

One mistake many people make is to cast the char * returned by
PQgetValue() to the type they expect to get.  Which won't work, since it's
a pointer to a value (in this case a number) in a textual format.  It
needs to be parsed so you get the actual numeric value.

Also, when you parse the number, be aware that the standard-library
functions (such as sscanf()) take the applicable locale setting into
account--which is not what you want in this case.  Best reset to the
default locale before parsing.


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not

In response to

pgsql-interfaces by date

Next:From: John DeSoiDate: 2005-08-10 18:30:23
Subject: Re: Connect to a PostgreSQL-Server by TCP/IP
Previous:From: jtvDate: 2005-08-10 10:52:12
Subject: Re: Getting oid with libpq

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