Created
March 20, 2017 01:23
-
-
Save vmussak/4853ee3a7981f3749b42b694e451600a to your computer and use it in GitHub Desktop.
This file contains 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
let transaction = sql.transaction(); | |
transaction.begin((err) = > { | |
if(err) | |
return console.log(err); | |
sql.request(transaction) | |
.input('Nome', 'Gustavo') | |
.input('NomeDaMae', 'Joana') | |
.execute('BuscarUsuario', (err, recordset) => { | |
//Se acontecer algum erro, ROLLBACK na transaction | |
if(err) { | |
transaction.rollback(() => { | |
console.log(err); | |
}); | |
//Caso contrário, COMMIT | |
} else { | |
transaction.commit(() => { | |
console.log(recordset); | |
}); | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment