Last active
December 27, 2015 12:39
-
-
Save ChrisRisner/7327381 to your computer and use it in GitHub Desktop.
Examples of using MSSQL QueryRaw in Mobile Services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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