pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How can I retrieve double or int data type for libpq
2+ messages / 2 participants
[nested] [flat]

* How can I retrieve double or int data type for libpq
@ 2018-06-13 03:08  a <372660931@qq.com>
  0 siblings, 1 reply; 2+ messages in thread

From: a @ 2018-06-13 03:08 UTC (permalink / raw)
  To: pgsql-general

Hi


I wanna use C library to connect pgsql server and I got 2 questions:


1, If I can fetch a row's data instead of using PQgetvalue?


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?


Thanks so much!


Shore

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How can I retrieve double or int data type for libpq
@ 2018-06-13 04:29  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: a <372660931@qq.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Laurenz Albe @ 2018-06-13 04:29 UTC (permalink / raw)
  To: a <372660931@qq.com>; pgsql-general

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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-06-13 04:29 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13 03:08 How can I retrieve double or int data type for libpq a <372660931@qq.com>
2018-06-13 04:29 ` Laurenz Albe <laurenz.albe@cybertec.at>

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