Generated script with syntax error

[expired user #8478]'s profile image [expired user #8478] posted 9 years ago in Running SQL scripts Permalink
I created a function which already works in my database, but the CREATE code of this function generated by the IDE is throwing an error:

Erro SQL (1064): 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 10

The generated code is the following:

CREATE DEFINER=`root`@`localhost` FUNCTION `CONVERTE_VALOR`(`VALOR` VARCHAR(255))
RETURNS decimal(10,0)
LANGUAGE SQL
NOT DETERMINISTIC
NO SQL
SQL SECURITY DEFINER
COMMENT 'Converte valor VARCHAR em DECIMAL para comparação'
BEGIN
RETURN CAST(REPLACE(REPLACE(VALOR, '.', ''), ',', '.') AS UNSIGNED); /* Line 10 */
END


Any suggestions?
ansgar's profile image ansgar posted 9 years ago Permalink
HeidiSQL version?
And when does it throw that error exactly? When you press "Save", or did you run the query by hand?
[expired user #8478]'s profile image [expired user #8478] posted 9 years ago Permalink
When I run the script by hand. I have posted the same problem here and the solution was remove "BEGIN" and "END" commands.
ansgar's profile image ansgar posted 9 years ago Permalink
When you run that by hand, you need to change the current delimiter (semicolon by default). See the main button with the red semicolon on it.
[expired user #8478]'s profile image [expired user #8478] posted 9 years ago Permalink
Thank you, now I got it.

Please login to leave a reply, or register at first.