Reputation: 57
I'm pretty new to MySQL, and I'm sure this is a common error, but I cannot figure out how to describe the issue to google to fix it. It's like I'm stuck in an infinite loop but I don't have a loop. I created and executed this procedure:
DELIMITER //
CREATE PROCEDURE getprofit (pcode1 VARCHAR(255), pcode2 (VARCHAR(255))
BEGIN
SELECT p.productName
,p.productCode
,p.buyPrice
,od.priceEach
,od.priceEach - p.buyPrice AS profit
FROM products p
JOIN orderdetails od ON p.productCode=od.productCode
WHERE p.productCode LIKE pcode1 OR p.productCode LIKE pcode2
ORDER BY profit DESC;
END //
DELIMITER;
But now, any line of code I type afterward isn't executed. All the terminal does is populate an additional line:
mysql> SHOW PROCEDURE STATUS WHERE DEFINER LIKE 'user%';
->
Even if I \c out of the line, the next line of code I execute does the same thing. I have to exit MySQL and re-enter for it to reset.
Upvotes: 0
Views: 164
Reputation: 57
For future reference, I was running the whole procedure on the same line in the terminal. I guess you can't run two delimiter commands on the same line. Once I ran them on opposite lines it worked fine.
Upvotes: 0
Reputation: 60
There is a problem with declaring DELIMITER you didn't add space between DELIMITER
and ;
The right way to redefine the default delimiter is -
DELIMITER ;
Upvotes: 1