CREATE DEFINER=`root`@`%` PROCEDURE `CountOrderByStatus`(
IN orderStatus VARCHAR(50),
OUT total INT)
BEGIN
SELECT count(orderNumber)
INTO total
FROM orders
WHERE status = orderStatus;
END
这是我的存储过程。我只想获取 Nodejs 应用程序中输出参数 total
的值
最佳答案
db_ask.query(("SET @a = 0; CALL CountOrderByStatus('" + _orderStatus + "', @a); SELECT @a;"),function(err, results){
//process result
});
假设 db_ask 是您与 mysql db 的连接。
祝你有美好的一天, 亚历克斯。
关于mysql - 在nodejs代码中向mysql存储过程传入和传出参数并返回out参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24306589/