本文整理汇总了TypeScript中mssql.Request.bulk方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Request.bulk方法的具体用法?TypeScript Request.bulk怎么用?TypeScript Request.bulk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mssql.Request
的用法示例。
在下文中一共展示了Request.bulk方法的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) => { });
}
示例2: function
request3.batch('create procedure #temporary as select * from table', function(err, recordset) {
// ... error checks
});
/**
* bulk https://github.com/patriksimek/node-mssql#bulktable-callback
*/
const table = new sql.Table('table_name'); // or temporary table, e.g. #temptable
table.create = true;
table.columns.add('a', sql.Int, {nullable: true, primary: true});
table.columns.add('b', sql.VarChar(50), {nullable: false});
table.rows.add(777, 'test');
const request4 = new sql.Request();
request4.bulk(table, function(err, rowCount) {
// ... error checks
});
/**
* cancel https://github.com/patriksimek/node-mssql#cancel
*/
const request5 = new sql.Request();
request5.query('waitfor delay \'00:00:05\'; select 1 as number', function(err, recordset) {
console.log(err instanceof sql.RequestError); // true
console.log(err.message); // Cancelled.
console.log(err.code); // ECANCEL
// ...
});
request5.cancel();