2
私は、最初のものの直後に別の要求を行うために、リクエスト(これはINSERT要求です)で退屈なコールバックを使用することはできません。何か案が ?ここに私のコードです。ここでSQL Server退屈なコールバック
error: RequestError: Requests can only be made in the LoggedIn state, not the SentClientRequest state
は私のAzureのSQLの構成です:
function intermediaryPositionSQL(decodeMessage, connection) {
if (typeof (decodeMessage.latitudeInt) != "undefined" && typeof (decodeMessage.longitudeInt) != "undefined")
{
var request = new Request(requestPosQuery, function (error)
{
if (error) {
winston.error(error);
}
});
request.addParameter('v_pos_latitude', TYPES.Float, decodeMessage.latitudeInt);
request.addParameter('v_pos_longitude', TYPES.Float, decodeMessage.longitudeInt);
request.addParameter('v_pos_altitude', TYPES.Int, (typeof (decodeMessage.altitude) != "undefined") ? decodeMessage.altitude : null);
request.addParameter('v_pos_speed', TYPES.Int, (typeof (decodeMessage.speed) != "undefined") ? decodeMessage.speed : null);
request.addParameter('v_pos_move', TYPES.Int, decodeMessage.move);
request.addParameter('v_pos_type', TYPES.Int, 2);
request.addParameter('v_pos_device', TYPES.VarChar, decodeMessage.device);
request.addParameter('v_pos_timestamp', TYPES.Int, decodeMessage.time);
request.on('doneInProc', function (rowCount, more, rows) {
return;
});
connection.execSql(request);
} else {
return;
}
}
function actualPositionSQL(decodeMessage, connection) {
if (typeof (decodeMessage.latitude) != "undefined" && typeof (decodeMessage.longitude) != "undefined")
{
var request = new Request(requestPosQuery, function (error)
{
if (error) {
winston.error(error);
}
});
request.addParameter('v_pos_latitude', TYPES.Float, decodeMessage.latitude);
request.addParameter('v_pos_longitude', TYPES.Float, decodeMessage.longitude);
request.addParameter('v_pos_altitude', TYPES.Int, (typeof (decodeMessage.altitude) != "undefined") ? decodeMessage.altitude : null);
request.addParameter('v_pos_speed', TYPES.Int, (typeof (decodeMessage.speed) != "undefined") ? decodeMessage.speed : null);
request.addParameter('v_pos_move', TYPES.Int, decodeMessage.move);
request.addParameter('v_pos_type', TYPES.Int, 1);
request.addParameter('v_pos_device', TYPES.VarChar, decodeMessage.device);
request.addParameter('v_pos_timestamp', TYPES.Int, decodeMessage.time);
request.on('doneInProc', function (rowCount, more, rows) {
intermediaryPositionSQL(decodeMessage, connection);
});
connection.execSql(request);
} else {
intermediaryPositionSQL(decodeMessage, connection);
}
}
このコードは
誤りがあるだけでSQLリクエストで最初に時刻を挿入して、新しい値で再びそれを行う必要がありますサーバー:
var config = {
userName: '***@***',
password: '*******',
server: '******.database.windows.net',
options: {encrypt: true, database: '******'}
};
私はdoneProc、rowを使って試してみましたが、成功しなくてもやってみました。 doneProcはdoneInProcと同じエラーを出し、row/doneは呼び出されません。