当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mssql.Transaction类代码示例

本文整理汇总了TypeScript中mssql.Transaction的典型用法代码示例。如果您正苦于以下问题:TypeScript Transaction类的具体用法?TypeScript Transaction怎么用?TypeScript Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Transaction类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) => { });
}
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:25,代码来源:mssql-tests.ts

示例2: test_classes_extend_eventemitter

function test_classes_extend_eventemitter() {
    var connection: sql.ConnectionPool = new sql.ConnectionPool(config);
    var transaction = new sql.Transaction();
    var request = new sql.Request();
    var preparedStatment = new sql.PreparedStatement();

    connection.on('connect', () => { });
    transaction.on('begin', () => { });
    transaction.on('commit', () => { });
    transaction.on('rollback', () => { });
    request.on('done', () => { });
    request.on('error', () => { });

    preparedStatment.on('error', () => { })
}
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:15,代码来源:mssql-tests.ts

示例3: catch

        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 => {
开发者ID:motionpicture,项目名称:ttts-functions,代码行数:19,代码来源:pos_sales.ts

示例4: mytable

    request.query('insert into mytable (bitcolumn) values (2)', function(err, recordset) {
        // insert should fail because of invalid value

        if (err) {
            if (!rolledBack) {
                transaction2.rollback(function(err) {
                    // ... error checks
                });
            }
        } else {
            transaction2.commit(function(err) {
                // ... error checks
            });
        }
    });
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:15,代码来源:transaction.ts

示例5:

transaction5.begin(function(err) {
    // ... error checks

    transaction5.rollback(function(err) {
        // ... error checks
    })
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:7,代码来源:transaction.ts

示例6: function

transaction2.begin(function(err) {
    // ... error checks

    let rolledBack = false;

    transaction2.on('rollback', function(aborted) {
        // emited with aborted === true

        rolledBack = true;
    });

    const request = new sql.Request(transaction2);
    request.query('insert into mytable (bitcolumn) values (2)', function(err, recordset) {
        // insert should fail because of invalid value

        if (err) {
            if (!rolledBack) {
                transaction2.rollback(function(err) {
                    // ... error checks
                });
            }
        } else {
            transaction2.commit(function(err) {
                // ... error checks
            });
        }
    });
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:28,代码来源:transaction.ts


注:本文中的mssql.Transaction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。