Postgresql PQgetvalue: returning an array

I have a table created as:

CREATE TABLE tbl_test
(
  id        bigserial    PRIMARY KEY,
  interest  int          ARRAY[2]
);

I got PGresult* reswithPQexec(conn, "SELECT * FROM tbl_test");

Now how can I get int[]out PQgetvalue(res, 0, 1).
I do not want to depend on the structures defined in array.h, as they can change.

I could not find the API in the Postgresql docs that could do anything.
Please inform.

Regards,
Mayank

+5
source share
1 answer

PQgetvalue () returns a string representation of the field value if you did not specify a binary pointer. In any case (a string or a binary cursor) you will need to provide the code to control the result in the desired form.

PostgreSQL.

  • SRC//Utils//arrayfuncs.c
  • SRC//Utils/array.h.

contrib/intarray.

http://doxygen.postgresql.org/ "", "".

, PQgetvalue(), , , Google, -.

+5

All Articles