How can I call MySql procedures from Node JS

I want to call a stored procedure from a MySql node :

What should I call it? The documentation states:

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


I tried searching for it on the internet but got very old results that no longer work.

I tried:

connection.query('procedure_name()', {84,Bhuwan}, function(err, result) {
    if (err)
      throw err;
    callback(err, result);


But I am getting error.

Can anyone provide the correct syntax for it?


source to share

1 answer

You must use the "invocation" command, and if you have parameters to pass the request, you need to add '?' Tags. Check the code.

connection.query("call procedure_name(?,?)", [param1, param2], function (err, result) {
    if (err) {
        console.log("err:", err);
    } else {
        console.log("results:", result);





All Articles