0

I'm trying to Create a procedure named GetOrderItemQuantity with the previous query that takes OrderNumber as an input parameter and the quantity of items for that order as an output parameter.

    DELIMITER $$

USE `mystoredb`$$

DROP PROCEDURE IF EXISTS `GetOrderItemQuantity`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `GetOrderItemQuantity`(
IN orderNumber INT (11),
OUT `Items` INT (11)
)
BEGIN
SELECT
o.OrderNumber,
COUNT(oi.*) `Items`
FROM `Order` o 
LEFT JOIN orderItem oi ON o.OrderId = oi.OrderId
WHERE o.OrderNumber = orderNumber
GROUP BY o.OrderNumber;
END$$

DELIMITER ;

For some reason it doesn't seem to be functioning.

4
  • Every time you run it, it causes your house to explode? Commented Sep 27, 2018 at 14:07
  • it seems to do nothing. Commented Sep 27, 2018 at 14:09
  • But you do assign a value to the variable, and also inspect the contents of the variable after you finish calling the procedure, right? Show the code that does that (this code doesn't assign a value, or call the proc, or inspect the variable value), show what you get, show why it is different to what you expect Commented Sep 27, 2018 at 14:21
  • Possible duplicate of MySQL: Set user variable from result of query Commented Sep 27, 2018 at 14:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.