> I tried to use atol but i get always 0 as result. Is this because I use a
> binary cursor to select the data (there are some PostGIS datatypes inside
> my resultset which are binary data).
That changes everything.
With a binary cursor you get all data in a binary format which "I'm sure
is documented somewhere." I believe in the case of oids it's a 32-bit
integer in network (big-endian) byte order. If that is indeed the case,
you should be able to read the oid as "ntohl(*(uint32_t
*)PQgetValue(...))".
On a side note, I don't think you actually need a binary cursor to
transfer binary data (apart from the fact that it's likely to improve
performance).
Jeroen