Grzegorz Jaśkiewicz wrote:
Hi,

Anyone here passed array to C/c++ code via libpq(xx) ??

Do you mean, fetching the output of a query like

   SELECT ARRAY['123','456','abc','def'];

?

I need to pass on an array of strings, some of them might contain coma symbol.
I am wondering, if there's anything already in libpq(xx) that would
chop value into an array of char* , or will it just return a string
and it is up to user to chop it.

   pgResult = PQexec(pgConn, "select array['123','456','abc','def'];");
   pgarray = PQgetvalue(pgResult,0,0);

will return a pointer to the ARRAY in postgres format as defined by the typsend/recieve internal functions for the ARRAY type. you would need to walk this and copy the strings comprising the array to your own managed storage (malloc, or whatever) prior to calling PQclear(pgResult). I'm trying to find the docs on what the typsend format for ARRAY looks like and failing.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to