By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,044 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,044 IT Pros & Developers. It's quick & easy.

Usisng PQgetvalue

P: 39
Hi I am using PQgetvalue() function in c to get the value like

PQgetvalue(result,0,2)

but the program outputs

column number 2 is out of range 0..0

Can someone tell me how can I get this field and whats wrong?

Thanks
Apr 29 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 534
Did you check what this query actually returns?
Both, row and column numbers are zero-based, so it has to return at least three columns.

You can use PQntuples and PQnfields to check whether you get any rows, and if so how many columns are there, or perhaps you could just execute the same query via psql or any other interface like pgAdmin.

Returns the number of rows in the query result.
int PQntuples(const PGresult *res);
-- -- --
Returns the number of columns (fields) in each row of the query result.
int PQnfields(const PGresult *res);
Apr 30 '07 #2

P: 39
Thanks man , I just realized that my query wasn't retruning the 3rd column.
May 1 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.