Why does my statement result in a syntax error?
You use DECLARE in compound-statement syntax to declare a local variable, cursor, condition or handler. However, your variable @batchsize is a session global variable due to the presence of the @ prefix, and it is an error to attempt to redeclare a global variable.

Change the name of your variable from @batchsize to batchsize, and then read up on MySQL variables.