日期:2014-05-16  浏览次数:21001 次

MYSQL储存过程传入传出
DELIMITER //
CREATE PROCEDURE cc(IN OrderID char,IN MysqlP_Price decimal,IN PayMode INT,OUT OrderStatus int)
BEGIN
UPDATE OrderList
SET OrderStatus='3',
ProPrice=MysqlP_Price
WHERE OrderID=OrderID and OrderStatus='0' AND PayMode=PayMode;
  SELECT OrderStatus into OrderStatus FROM OrderList WHERE OrderID=OrderID;
END//

call cc('20120507000953605783','99.00','3',@OrderStatus);
结果
ERROR 1172(42000) result consisited of more than one row

请问一下
我需要先传值进去,再更新表,最后将订单的当前状态值(Orderstatus)返回出来,请问该如何来写

------解决方案--------------------
CREATE PROCEDURE cc(IN OrderID char,IN MysqlP_Price decimal,IN PayMode INT,OUT OrderStatus int)
参数名改下,不要跟表的字段名一样,再试下
------解决方案--------------------
SELECT OrderStatus into OrderStatus FROM OrderList WHERE OrderID=OrderID这个结果不唯一?



SELECT OrderStatus into OrderStatus FROM OrderList WHERE OrderID=OrderID limit 1;这样
------解决方案--------------------
desc OrderList
贴出来看一下表结构。