I'm attempting to run the below stored procedure.
CREATE PROCEDURE RNS_CLEANTEXT_MAX_LENGTH()
BEGIN
SELECT MAX(LENGTH(rns_cleantext) - LENGTH(REPLACE(rns_cleantext," ", ""))+1) FROM rns;
END
However this query doesn't run as I get 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 3
I've also attempted single quotes, escaped quotes and as above double quotes.
Any idea.
Fixed by @eggyal:
The fixed query now looks like this:
CREATE FUNCTION RNS_CLEANTEXT_MAX_LENGTH()
SELECT MAX(LENGTH(rns_cleantext) - LENGTH(REPLACE(rns_cleantext," ", ""))+1) FROM fns;
As @eggyal points out the Begin and End statements are not required. And in the cases where they are I have to modify the delimiter.
Thanks!
As documented under Defining Stored Programs:
In your case, since your sproc comprises only a single statement, you can simply remove the
BEGIN ... ENDblock.