Search code examples
sqldatabasemariadbheidisql

MariaDB incorrect syntax near ''


as the title says, I have an error with my syntax somewhere. This is MariaDB 10.1.31.

DROP FUNCTION IF EXISTS NO_UMLAUT;
CREATE FUNCTION NO_UMLAUT(TextString VARCHAR(255)) RETURNS VARCHAR(255)
BEGIN
    SET TextString = REPLACE(TextString, 'ä', 'a');
    SET TextString = REPLACE(TextString, 'ë', 'e');
    SET TextString = REPLACE(TextString, 'ḧ', 'h');
    SET TextString = REPLACE(TextString, 'n̈', 'n');
    SET TextString = REPLACE(TextString, 'ï', 'i');
    SET TextString = REPLACE(TextString, 'ẗ', 't');
    SET TextString = REPLACE(TextString, 'ö', 'o');
    SET TextString = REPLACE(TextString, 'ẅ', 'w');
    SET TextString = REPLACE(TextString, 'ß', 'b');
    SET TextString = REPLACE(TextString, 'ü', 'u');
    SET TextString = REPLACE(TextString, 'ẍ', 'x');
    SET TextString = REPLACE(TextString, 'ÿ', 'y');
    RETURN TextString;
END;

and the error:

 You have an error in your SQL syntax;
 check the manual that corresponds to your MariaDB server version
 for the right syntax to use near '' at line 3.

So far I tried a function from the documentation and there also was an error with the syntax. I am executing this query in HeidiSQL 9.5.0.5196.


Solution

  • I think you just need DELIMITER statements.

    The function itself is fine, as shown by this SQL Fiddle (MariaDB and MySQL are the same for this purpose).

    Try adding:

     DELIMITER $$
    
     <your function definition>
    
     DELIMITER ;