MySQL 1615 Prepared statement needs to be re-prepared

I get the error ‘1615 Prepared statement needs to be re-prepared’ on a prepared statement.

"
Dim ps As PreparedSQLStatement

If NOT open_db Then
Return False
End If

ps = DB.Prepare(sql)

"

Did some Google on it. Found about the related DB settings. But this seems not to be the cause, because other prepared statements on the DB work fine.

Does anyone know how to ‘re-prepare’ a sql statement?

Which type of db are you using? Why are you using the generic PreparedSQLStatement? This is the base class for the db specific classes that you should be using.

Hi Jay,

I’m using MySQL. You are right. It should be " MySQLPreparedStatement "

Still, then it gives the same error.

Can you post the SQL statement that is causing this error?

Also, what version of MySQL are you using?

mysql Ver 15.1 Distrib 10.0.31-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

SELECT
CONCAT(MODEL_1.YEAR,
MODEL_1.MONTH) AS YD,
AEX_MONTH.AVG_MONTH,
MODEL_1.AVG_MONTH AS M1,
IFNULL(MODEL_1.AVG_MONTH_M2,0) AS M2
FROM
MODEL_1
LEFT JOIN
AEX_MONTH
ON
AEX_MONTH.YEAR = MODEL_1.YEAR
AND
AEX_MONTH.MONTH = MODEL_1.MONTH

I don’t see any reason this query would cause issues. Are you issuing a SQLSelect right after preparing the statement? Exactly when does the error occur - after the Prepare statement or after the SQLSelect statement?

I neither see it. It occurs after the ps.SQLSelect.

Some of the search results suggest a newer version of MySQL (or MariaDB in your case) might solve it. Don’t know how easy this is for you to test.

Another possible solution, if you aren’t using any user-supplied values in a WHERE clause, is to not use a prepared statement for this query.

To be honest, I might have been to lazy in programming. I use one select session method to do all DB handling to limit the open DB sessions. Works fine. The obvious thing in this case to enable it to switch to a non prepared select. And obviously that works fine!

Thanks Jay for reflecting.