0
我知道Node.js是異步的,但我不知道爲什麼我的兩個查詢沒有執行,只有第一個查詢。如果第一個查詢是OK,我只是試圖放置查詢,但即使第二個查詢不執行。Node.js - 爲什麼我的兩個查詢沒有執行?
這裏是我的代碼:
sql = "INSERT INTO TB_DISPOSITIVOS_VOZ (DS_CLIENTID, FK_ID_GRUPO) ";
sql = sql + " VALUES ('" + alexaClientId + "', " + idgrupo + ") ";
connection.query(sql, function(erro2, rows2, fields2) {
if (!erro2) {
console.log("Inserted alexa in the group: " + idgrupo + "with the clientId: " + alexaClientId);
} else {
console.log("Error - When inserting alexa in the group" + erro2);
context.fail("Error - When inserting alexa in the group" + erro2);
}
});
sql1 = "DELETE FROM TB_FILA_PAREAMENTO_OTP WHERE DS_CLIENTID = '" + alexaClientId + "'";
connection.query(sql1, function(erro3, rows3, fields3) {
if (!erro3) {
console.log("Query Delete TB_FILA_PAREAMENTO_OTP OK");
} else {
console.log("Error - Delete query does not works correctly..." + erro3);
context.fail("Error - Delete query does not works correctly..." + erro3);
}
});
你用什麼包的mysql? – mrdotb