Skip to content

Instantly share code, notes, and snippets.

@ChrisRisner
Last active December 27, 2015 12:39
Show Gist options
  • Save ChrisRisner/7327381 to your computer and use it in GitHub Desktop.
Save ChrisRisner/7327381 to your computer and use it in GitHub Desktop.
Examples of using MSSQL QueryRaw in Mobile Services
var mssql = request.service.mssql;
var sql = "UPDATE TableA SET valueOne = ? WHERE userId = ?;UPDATE TableB SET valueTwo = ? WHERE userId = ?;";
mssql.queryRaw(sql, [item.valueOne, user.userId, item.valueTwo, user.userId], {
success: function(results) {
request.respond(200, { Status: 'SUCCESS', Details: 'Tables have been updated'});
},
error: function(error) {
console.error("Error updating tables: ", error);
request.respond(500, 'Error updating email address');
}
});
var mssql = request.service.mssql;
var sql = "UPDATE TableA SET valueOne = ? WHERE userId = ?;UPDATE TableB SET valueTwo = ? WHERE userId = ?;";
var responseCount = 0;
mssql.queryRaw(sql, [item.valueOne, user.userId, item.valueTwo, user.userId], {
success: function(results) {
if (responseCount++ == 1) {
request.respond(200, { Status: 'SUCCESS', Details: 'Tables have been updated'});
}
},
error: function(error) {
console.error("Error updating tables: ", error);
if (responseCount++ == 1) {
request.respond(500, 'Error updating email address');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment