mysql - Node 没有为成功的存储过程返回值

标签 mysql node.js asynchronous

您还在为这个问题烦恼吗?

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/

相关文章:

PHP/MySQL - 更新查询

php - 我想重新设计xml结构

node.js - 如何向子类构造函数传递附加参数?

javascript - 从 Node.js 将文件插入 MongoDB 时出错

ruby - 像 Ruby 'exec' 但对于 Node.js?

java - 返回具有不同 Http 状态的 Rest CompletableFuture

javascript - Promise 中未正确调用异步 Javascript 函数

php - 如何编写查询来比较具有逗号分隔值的列?

javascript - AngularJS promise 没有回调?

mysql - 将日期输入数据库(phpMyAdmin、SQL)