2

I have a problem with calling a function I created using MySQL Workbench. Function:

DELIMITER $$
CREATE FUNCTION welcome()
RETURNS TEXT
deterministic
BEGIN
    RETURN 'Hello World!';
END
$$
DELIMITER ;

After I hit this button: buttonMySQL

enter image description here

I get: "Error parsing sql code for object Syntax error: unexpected 'COLLATE' (collate)"

Funny thing is when i call this function using code, like:

SELECT world.welcome();

It works.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
HTF
  • 33
  • 1
  • 8
  • I thought this was a duplicate of https://stackoverflow.com/questions/39399563/mysql-workbench-6-3-mac-hangs-on-simple-queries but that problem is that queries hang, instead of getting a syntax error like you report. So I have reversed my vote to mark your question a duplicate. – Bill Karwin Sep 04 '17 at 22:25
  • I tried your function with MySQL 8.0.1 and MySQL Workbench 6.3.2.0 and it works fine with no error. – Bill Karwin Sep 04 '17 at 22:26
  • It sounds a bit like Workbench strikes yet again, parsing code it doesn't need to be parsing, trying to reverse engineer the function instead of just running it. – Michael - sqlbot Sep 05 '17 at 02:04
  • Just tested that on macOS with WB 6.3.9 and it works as intended. Clicking on the flash icon opens a new SQL editor with the text `selelct test.welcome()` and runs it. This opens a result set with a single column and row, containing the "Hello World" text. What MySQL server and WB version do you use? What does the WB log show? – Mike Lischke Sep 05 '17 at 07:50
  • I'm using mysql server 5.7.22 on Ubuntu 16.04.5 with Workbench 6.3.10 and I get the same error when I execute the same script above. I don't think that question is duplicate. – Ignjatije Jul 31 '18 at 15:13

0 Answers0