本文整理汇总了TypeScript中mssql.Transaction.commit方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Transaction.commit方法的具体用法?TypeScript Transaction.commit怎么用?TypeScript Transaction.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mssql.Transaction
的用法示例。
在下文中一共展示了Transaction.commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test_promise_returns
function test_promise_returns() {
// Methods return a promises if the callback is omitted.
var connection: sql.ConnectionPool = new sql.ConnectionPool(config);
connection.connect().then(() => { });
connection.close().then(() => { });
var preparedStatment = new sql.PreparedStatement(connection);
preparedStatment.prepare("SELECT @myValue").then(() => { });
preparedStatment.execute({ myValue: 1 }).then((recordSet) => { });
preparedStatment.unprepare().then(() => { });
var transaction = new sql.Transaction(connection);
transaction.begin().then(() => { });
transaction.commit().then(() => { });
transaction.rollback().then(() => { });
var request = new sql.Request();
request.batch('create procedure #temporary as select * from table').then((recordset) => { });
request.batch<Entity>('create procedure #temporary as select * from table;select 1 as value').then((recordset) => { });
request.bulk(new sql.Table("table_name")).then(() => { });
request.query('SELECT 1').then((recordset) => { });
request.query`SELECT ${1} as value`.then(res => { });
request.query<Entity>('SELECT 1 as value').then(res => { });
request.execute('procedure_name').then((recordset) => { });
}
示例2:
transaction4.begin(function(err) {
// ... error checks
transaction4.commit(function(err) {
// ... error checks
})
});
示例3: mytable
request.query('insert into mytable (mycolumn) values (12345)', function(err, recordset) {
// ... error checks
transaction.commit(function(err) {
// ... error checks
console.log("Transaction committed.");
});
});
示例4: pos_sales_tmp
await server.connect().then(async pool => {
context.log(`${context.bindingData.name}: Start Transaction.`);
const transaction = new sql.Transaction(pool);
await transaction.begin();
try {
for (let i = 0; i < parts.length; i++) {
const request = new sql.Request(transaction);
await request.query(`INSERT INTO pos_sales_tmp (${header4PosSalesTmp.join(',')}) VALUES ${parts[i].join(', ')};`);
context.log(`${context.bindingData.name}ファイル: ${i + 1}分割追加しました。`);
}
await transaction.commit();
} catch (err) {
await transaction.rollback();
Logs.writeErrorLog(context, context.bindingData.name + '\\' + err.stack);
}
}).then(result => {