0

I don't know why I can't access my property.

connection.query("call VerifyAccountToken(0, null)", function(err, rows, fields) {
    if(err) console.log("Error: " + err);

    console.log("SQLRet: ", rows[0].result);
    console.log(rows);
    console.log(fields);
});

VerifyAccountToken returns a single row/column result with the column named 'result'. The console outputs the following:

SQLRet: undefined

[ [ { result: 0 } ], { fieldCount: 0, affectedRows: 0, insertId: 0, serverStatus: 2, warningCount: 1, message: '', protocol41: true, changedRows: 0 } ]

[ [ { catalog: 'def', db: '', table: '', orgTable: '', name: 'result', orgName: 'iRes', filler1: , charsetNr: 63, length: 11, type: 3, flags: 0, decimals: 0, filler2: , default: undefined, zeroFill: false, protocol41: true } ], undefined ]

Everything I know tells me this should work.

1 Answers1

0

Ok apparently I needed to use

rows[0][0].result;

I'm not sure why node-mysql nests stored procedures' returned results.

  • Presumably that would be because a MySQL stored procedure can return multiple result sets, which is a very useful capability, and rows[0] could be the first one of "n"; see the last paragraph here: http://dev.mysql.com/doc/refman/5.6/en/stored-routines-syntax.html – Michael - sqlbot Nov 28 '13 at 04:39