user3748717
user3748717

Reputation: 61

passing in and out parameter to a mysql stored procedure and return the out parameter in the nodejs code

CREATE DEFINER=`root`@`%` PROCEDURE `CountOrderByStatus`(
        IN orderStatus VARCHAR(50),
        OUT total INT)
BEGIN
    SELECT count(orderNumber)
    INTO total
    FROM orders
    WHERE status = orderStatus;
END

This is my stored procedure. I just want to get the out parameter total's value in my nodejs application

Upvotes: 0

Views: 2055

Answers (1)

alexsc
alexsc

Reputation: 1206

db_ask.query(("SET @a = 0; CALL CountOrderByStatus('" + _orderStatus + "', @a); SELECT @a;"),function(err, results){


//process result


});

Assuming that db_ask is your connection to mysql db .

Have a nice day, Alex.

Upvotes: 1

Related Questions