Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSxQ2-0007Fh-Q7 for pgsql-general@arkaria.postgresql.org; Wed, 13 Jun 2018 04:30:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fSxPz-0005QM-BP for pgsql-general@arkaria.postgresql.org; Wed, 13 Jun 2018 04:29:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSxPz-0005QC-3L for pgsql-general@lists.postgresql.org; Wed, 13 Jun 2018 04:29:59 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fSxPv-0002YZ-UW for pgsql-general@postgresql.org; Wed, 13 Jun 2018 04:29:58 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 574004108E; Wed, 13 Jun 2018 06:29:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id 3dFV-8trc7X8; Wed, 13 Jun 2018 06:29:52 +0200 (CEST) Message-ID: <1528864191.2657.11.camel@cybertec.at> Subject: Re: How can I retrieve double or int data type for libpq From: Laurenz Albe To: a <372660931@qq.com>, pgsql-general Date: Wed, 13 Jun 2018 06:29:51 +0200 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk a wrote: > I wanna use C library to connect pgsql server and I got 2 questions: This is all well documented in https://www.postgresql.org/docs/current/static/libpq.html > 1, If I can fetch a row's data instead of using PQgetvalue? PGgetvalue *is* the way to fetch the row's data. There is no call to fetch *all* columns at once, but that is not necessary. > 2, PQgetvalue will return all data as text, I would have to convert them into the > relative data type, is there a way of getting data by its original format? You will get the data in binary form if you specify a resultFormat of 1 with PQexecParams. Note, however, that they will be in the native binary format of the *server*. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com