3

How can I fetch the corresponding warning identified after the query execution as in:

connection.query( squery, function(err, rows){
   ... 
   // search for OkPacket in 2 dimension array
   var warningCounter = okPacket.warningCount;
   if ( warningCounter > 0 ){
      ???
   }

});
Alain
  • 1,450
  • 3
  • 20
  • 37

1 Answers1

2

Execute the query:

SHOW WARNINGS

Here is more on SHOW WARNINGS Syntax

blue
  • 1,939
  • 1
  • 11
  • 8
  • So, node-mysql does now not execute it implicitly... I have to relaunch another query from within the query callback or is there another way ? – Alain Apr 09 '14 at 12:42
  • Can you tap it onto the end of the SQL? db.query('INSERT (1,2,3) INTO table; SHOW WARNINGS;', callback); – Adrian Lynch Oct 23 '14 at 14:35
  • @blue - How can SHOW WARNINGS be used safely? – Adrian Lynch Oct 23 '14 at 14:35
  • 1
    @AdrianLynch - Here is a question about executing multiple queries with node-mysql: [Approach to multiple MySQL queries with Node.js](http://stackoverflow.com/q/6622746/3440995) – blue Oct 29 '14 at 10:02