I'm trying to define a function in mysql (mysql-server version 8.0) like this:
CREATE FUNCTION myVeryCoolFunc ( json1 JSON, json2 JSON )
RETURNS JSON
DETERMINISTIC
BEGIN
DECLARE abc JSON;
DECLARE foo INT;
DECLARE bar INT;
...
but it fails with the message
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
In other words: Somehow "declare abc JSON;" contains a syntax error. I just can't figure out why.
Additionally, I only get this when I try to use the mysql console or the mysql command with "--execute=...", not when I use my IDE (PyCharm).
Any help with this is greatly appreciated as I'm really losing my mind over this.