node-query/node_modules/mysql2/examples/sprocedure.js

12 lines
560 B
JavaScript

var mysql = require('../test/common').createConnection();
//var create_proc = "mysql.query('DROP PROCEDURE IF EXISTS p; CREATE PROCEDURE p(IN i INT) BEGIN SELECT i as f; END;');";
var create_proc = "CREATE PROCEDURE `get_user1`(IN supplied_user_id INT) BEGIN select * from mil1 ua where ua.id = supplied_user_id; END";
mysql.query(create_proc, function(err, rows, fields) {
console.log('Error:', err, rows, fields);
});
mysql.execute('CALL get_user1(?)', [ 1 ], function (err, rows) {
console.log(JSON.stringify(err, rows, null, 2));
mysql.end();
});