sql - rows object returned after executing stored procedure in node-mysql -


i've subquery executing , looking insertid's i'm getting rows object no information.

my stored procedure

create procedure `day`(in start date, in end date, in event_id int) begin     while start <= end         insert day(date, event_id) values(start, event_id);         set start = start + 1;     end while; end 

node.js

var query = "set @start = '" + request.body.from  + "'; \     set @end = '" + request.body.to + "'; \     set @event_id = " + rows.insertid + "; \     call day(@start, @end, @event_id);";  connection.query(query, [], function(error, rows, fields) {     console.log(rows); } 

console output rows

[     {       "fieldcount": 0,       "affectedrows": 0,       "insertid": 0,       "serverstatus": 11,       "warningcount": 0,       "message": "",       "protocol41": true,       "changedrows": 0     },     {       "fieldcount": 0,       "affectedrows": 0,       "insertid": 0,       "serverstatus": 11,       "warningcount": 0,       "message": "",       "protocol41": true,       "changedrows": 0     },     {       "fieldcount": 0,       "affectedrows": 0,       "insertid": 0,       "serverstatus": 11,       "warningcount": 0,       "message": "",       "protocol41": true,       "changedrows": 0     },     {       "fieldcount": 0,       "affectedrows": 1,       "insertid": 0,       "serverstatus": 3,       "warningcount": 0,       "message": "",       "protocol41": true,       "changedrows": 0     }   ] 

expectations , question

i need kind of actual information result of insertions stored procedure.

does stored procedure return anything? stored procedure define variable hook returning this:

declare   the_id integer; begin   insert the_table (first, last, address, zip)   values (first, last, address, zip)   returning _id the_id;  return the_id;  end; 

the return sends id output.

disclaimer: work postgresql , write functions in plpsql, believe syntax similar.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -