Reputation: 85
I'm trying to do a DROP CREATE stored procedure in MySQL.
The first block of code runs just fine.
DELIMITER //
-- IMPORTANT: Change to ecom_prod
USE ecom_dev;
DROP PROCEDURE IF EXISTS `usp_getDetails`;
The second block gives an error in statement #2 near --DROP CREATE Procedure
DROP PROCEDURE IF EXISTS usp_getDetails
; at line 1
DELIMITER //
-- IMPORTANT: Change to ecom_prod
USE ecom_dev;
-- DROP CREATE Procedure
DROP PROCEDURE IF EXISTS `usp_getDetails`;
The only difference is the addition of extra comments. I can't understand how the extra comment is causing this error.
Any and all help is welcome
Upvotes: 0
Views: 48
Reputation: 108370
Once the DELIMITER is changed to something other than semicolon, the new delimiter should be used in place of the semicolon.
For example:
DELIMITER $$
-- IMPORTANT: Change to ecom_prod
USE ecom_dev$$
DROP PROCEDURE IF EXISTS `usp_getDetails`$$
DELIMITER ;
I'm not sure how your code is working with the semicolons. I don't think the issue has anything to do with the comments. But I haven't tested it. I always have a blank line preceding and following DELIMITER. And the only time I ever use DELIMITER
is when I'm issuing a CREATE <stored_program_type>
.
Upvotes: 1