hi jacker wrote:
> Cause, when i try to run this code at the "MySQL
> Query Browser" or another mySQL query tool:
>
> DELIMITER |
> DROP PROCEDURE IF EXISTS sp_declare\G|
> I get several errors.
Actually I get only one error and it clearly states: "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 '\G' at line 1". So it is obvious the \G is the culprit. Next thing is that it does not make any sense to have the "go" delimiter and and the normal delimiter in one line. Actually, the "go" delimiter (\g and \G) does not make any sense in general because we have the normal delimiter. I'd strongly recommend to avoid \g and \G, it isn't even supported in MySQL Query Browser.
> BUT, if i paste this inside the mySQL console it
> works FINE !
It does not. I get:
mysql> use test;
Database changed
mysql> DELIMITER |
mysql> DROP PROCEDURE IF EXISTS sp_declare\G|
Query OK, 0 rows affected (0.00 sec)
ERROR:
No query specified
mysql> CREATE PROCEDURE sp_declare (P INT)
-> BEGIN
-> DECLARE x INT;
-> DECLARE y INT DEFAULT 10;
-> SET x = P*y;
-> SELECT x;
-> END|
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql>
See the ERROR in the middle?
Mike
Mike Lischke, MySQL Developer Tools
Oracle Corporation
MySQL Workbench on Github:
https://github.com/mysql/mysql-workbench
On Twitter:
https://twitter.com/MySQLWorkbench
On Slack: mysqlcommunity.slack.com (#workbench)
Report bugs to
http://bugs.mysql.com
MySQL documentation can be found here:
http://dev.mysql.com/doc/refman/8.0/en/