You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Can someone please explain why I get this error ER_MAX_PREPARED_STMT_COUNT_REACHED when I am following this documentation
Here is my code:
exportconstgetById=(id)=>{returndb().then(async(connection)=>{constsql=awaitconnection.format(` SELECT * FROM ${baseTables} WHERE ${baseWhere} AND status = 'ACTIVE' AND id = ?`,[id]);constresultSet=awaitconnection.execute(sql);constrow=get(resultSet,"[0].[0]");if(row){constrowItem=t.buildRow(row);connection.unprepare(sql);connection.release();returnrowItem;}});};
Yet every couple months I get this error: ER_MAX_PREPARED_STMT_COUNT_REACHED
I have read: #158 #393 #702
Should I do the manual version, and do it like this instead?
export const getById = (id) => {
return db().then(async (connection) => {
const sql = await connection.prepare(`
SELECT * FROM ${baseTables}
WHERE ${baseWhere}
AND status = 'ACTIVE'
AND id = ?`,
[ id ]
);
const resultSet = await connection.execute(sql);
const row = get(resultSet, "[0].[0]");
if (row) {
const rowItem = t.buildRow(row);
connection.close();
return rowItem;
}
});
};
Thanks.
The text was updated successfully, but these errors were encountered:
@okbrown you are formatting sql interpolatining parameters on the client and then send it to server to prepare ( each time parameter is different it's a new prepared statement because sql text is different )
Should I do the manual version, and do it like this instead?
main problem is that "format" is client-side interpolation while "prepare" is server-side
Your second example can be still automatic, just send constant query separate from variable parameters with .execute() or .prepare()
exportconstgetById=async(id,connection)=>{constresultSet=awaitconnection.execute((` SELECT * FROM ${baseTables} WHERE ${baseWhere} AND status = 'ACTIVE' AND id = ?`,[id]);constrow=get(resultSet,"[0].[0]");if(row){constrowItem=t.buildRow(row);returnrowItem;}returnnull;};
Hi,
Can someone please explain why I get this error
ER_MAX_PREPARED_STMT_COUNT_REACHED
when I am following this documentationHere is my code:
Yet every couple months I get this error:
ER_MAX_PREPARED_STMT_COUNT_REACHED
I have read:
#158
#393
#702
Should I do the manual version, and do it like this instead?
Thanks.
The text was updated successfully, but these errors were encountered: