我想从MySql node调用存储过程:
我该怎么称呼它?文档说:
You can call stored procedures from your queries as with any other mysql driver. If the stored procedure produces several result sets, they are exposed to you the same way as the results for multiple statement queries
我尝试在互联网上搜索它,但得到的结果非常旧,不再适用了。
我试过了:
connection.query('procedure_name()', {84,Bhuwan}, function(err, result) {
connection.destroy();
if (err)
throw err;
callback(err, result);
});
但我收到了错误。
任何人都可以为它提供正确的语法吗?
答案 0 :(得分:0)
你必须使用'call'命令,如果你有参数传递给查询,你需要添加'?'分数。检查代码。
connection.query("call procedure_name(?,?)", [param1, param2], function (err, result) {
if (err) {
console.log("err:", err);
} else {
console.log("results:", result);
}
});