spencergadd
spencergadd

Reputation: 57

Command Line Only Returning -> After Trying to Execute Procedure

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.

  1. Can you tell me what to call it when MySQL just returns ->?
  2. Is there something wrong with my procedure?

Upvotes: 0

Views: 164

Answers (2)

spencergadd
spencergadd

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

Poshan Tyagi
Poshan Tyagi

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

Related Questions