X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F26152C00 for ; Wed, 10 Aug 2005 07:52:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82703-01 for ; Wed, 10 Aug 2005 10:52:13 +0000 (GMT) Received: from smtp-vbr13.xs4all.nl (smtp-vbr13.xs4all.nl [194.109.24.33]) by svr1.postgresql.org (Postfix) with ESMTP id 7AA3552A11 for ; Wed, 10 Aug 2005 07:52:11 -0300 (ADT) Received: from webmail.xs4all.nl (webmail12.xs4all.nl [194.109.22.172]) by smtp-vbr13.xs4all.nl (8.13.3/8.13.3) with ESMTP id j7AAqChS075987; Wed, 10 Aug 2005 12:52:12 +0200 (CEST) (envelope-from jtv@xs4all.nl) Received: from 202.47.227.25 by webmail.xs4all.nl with HTTP; Wed, 10 Aug 2005 12:52:12 +0200 (CEST) Message-ID: <10445.202.47.227.25.1123671132.squirrel@202.47.227.25> In-Reply-To: <20050810093352.EAD8B5287F@svr1.postgresql.org> References: <20050810093352.EAD8B5287F@svr1.postgresql.org> Date: Wed, 10 Aug 2005 12:52:12 +0200 (CEST) Subject: Re: Getting oid with libpq From: jtv@xs4all.nl To: "Johan C. de Koning" Cc: pgsql-interfaces@postgresql.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.228 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200508/15 X-Sequence-Number: 5686 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. Jeroen