Reputation: 123
I'm new with MySQL and I'm trying to create a procedure. I connect to the db and handle the data with Oracle SQLDeveloper.
When I try executing the following as a script...
DELIMITER //
CREATE PROCEDURE GetAllProducts()
BEGIN
SELECT * FROM products;
END //
DELIMITER ;
I get the following error...
Error starting at line 1 in command:
DELIMITER //
Error at Command Line:1 Column:0
Error report:
SQL Error: 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 'DELIMITER //' at line 1
I'm using the latest version of Oracle SQL Developer as well as the las MySql version (just installed both)
Can somebody help me on how to use the delimiter?
thanks, Leo
Upvotes: 1
Views: 2898
Reputation: 121932
Your code is 100% correct. The DELIMITER is not a MySQL command, this command has to be supported by client. The DELIMITER helps client to parse statements in a script.
Your procedure has one statement, so you can rewrite it without BEGIN...END and without DELIMITERS, e.g. -
CREATE PROCEDURE GetAllProducts()
SELECT * FROM products;
Also you may try another clients which support DELIMITER: mysql — The MySQL Command-Line Tool, GUI tool - dbForge Studio for MySQL (free express edition), or etc..
Upvotes: 2