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


TypeScript PreparedStatement.execute方法代码示例

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


在下文中一共展示了PreparedStatement.execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: function

ps5.prepare('select @param as value', function(err) {
    // ... error checks

    ps5.stream = true;
    const request = ps5.execute({param: 12345}, function(err) {
        ps5.unprepare(function(err) {
            // ... error checks
        });
    });

    request.on('recordset', function(columns) {
        // Emitted once for each recordset in a query
    });

    request.on('row', function(row) {
        // Emitted for each row in a recordset
    });

    request.on('error', function(err) {
        // May be emitted multiple times
    });

    request.on('done', function(returnValue, affected) {
        // Always emitted as the last one

        console.log(affected); // Returns number of affected rows in case of INSERT, UPDATE or DELETE statement.
    });
});
开发者ID:typed-contrib,项目名称:node-mssql,代码行数:28,代码来源:preparedstatement.ts


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