user1464363
user1464363

Reputation:

Why is the query not being recognized?

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

Answers (1)

Brendan
Brendan

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

Related Questions