We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In the following code, I have been able to successfully return the initial value from the column in a database. However, the code returns the same initial value.
How do I get it to iterate?
float database ()
{
String user = "";
String pass = "";
String database = "";
// connect to database on "localhost"
//
pgsql = new PostgreSQL( this, "127.0.0.1", database, user, pass );
// connected?
if ( pgsql.connect() )
{
pgsql.query( "SELECT COUNT(co2) FROM tree" );
// results found?
if ( pgsql.next() )
{
}
pgsql.query( "SELECT co2 FROM tree LIMIT 1" );
while( pgsql.next() )
//psql.execute();
{
return( pgsql.getFloat("co2") ); //it works here
}
}
else
{
}
return(0);
}
void draw(){
println(database());
delay(5000);
}
Answers
Remove the LIMIT 1 clause from the SQL statement?