Reputation:
The code is to access a specific row within a column from a pgSQL table. I keep receiving an error that reads "You need to query() something first." However, I thought pgsql.query line would be enough to retrieve the value I am seeking. Other than that, this code seems to work.
int r;
...
//connect to database
if ( pgsql.connect() )
{
//class submits query
pgsql.query( "SELECT * FROM (SELECT ROW_NUMBER (" + str(r) + ") AS co2 FROM tree;" );
//iterate r
r++;
//return query value
return( pgsql.getFloat("co2") );
}
else
{
//disconnect from database
}
return(0)
Upvotes: 0
Views: 79
Reputation: 1247
I don't know what language this is, but the line in your example is missing a parentheses after the word tree - see my edit below
"SELECT * FROM (SELECT ROW_NUMBER (" + str(r) + ") AS co2 FROM tree);"
Upvotes: 1