I have SELECT queries that I need to run on regular intervals. I have created a sql::Connection object that I hold onto.
Every interval I generate a sql::Statement from the connection I have and run the SELECT. I then run through the result set and then delete the resultset and the statment.
The first iteration works fine, but on every next interval, when I run the SELECT I get the following error:
SQL ERROR (2014):: Commands out of sync; you can't run this command now.
This is the same query that ran fine the time before.
All the examples I have seen show the connection object being temporary to the method being called.
Is this the way it should be run? Wouldn't it be expensive to generate a connection object for every request to be run?
Thanks,
Chris
Every interval I generate a sql::Statement from the connection I have and run the SELECT. I then run through the result set and then delete the resultset and the statment.
The first iteration works fine, but on every next interval, when I run the SELECT I get the following error:
SQL ERROR (2014):: Commands out of sync; you can't run this command now.
This is the same query that ran fine the time before.
All the examples I have seen show the connection object being temporary to the method being called.
Is this the way it should be run? Wouldn't it be expensive to generate a connection object for every request to be run?
Thanks,
Chris