您还在为这个问题烦恼吗?
CALL eveql.sp_matFinder('ishkur');
在 DBeaver 中成功返回并为我返回 15 行。 我在 node.js 中遵循此语法进行调用。
connection.query('CALL eveql.sp_matFinder(?);', [itemName], function(err, rows){
if(err) throw err;
console.log(rows);
console.log(JSON.stringify(rows));
});
.query( 成功返回,但是我收到一个空数组,而我的结果应该在该数组中。
[ **[]**,
OkPacket {
fieldCount: 0,
affectedRows: 0,
insertId: 0,
serverStatus: 34,
warningCount: 0,
message: '',
protocol41: true,
changedRows: 0 } ]
Data : [[],{"fieldCount":0,"affectedRows":0,"insertId":0,"serverStatus":34,"warningCount":0,"message":"","protocol41":true,"changedRows":0}]
所以我也很茫然。这可能是 mysql 针对 Node 版本的版本控制问题。
最佳答案
根据 mysql docs
A procedure is invoked using a CALL statement (see Section 13.2.1, “CALL Syntax”), and can only pass back values using output variables. A function can be called from inside a statement just like any other function (that is, by invoking the function's name), and can return a scalar value.
要么使用函数返回结果集,要么使用 OUT 参数返回标量值。
关于mysql - Node 没有为成功的存储过程返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42279983/