當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Request.query方法代碼示例

本文整理匯總了TypeScript中mssql.Request.query方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Request.query方法的具體用法?TypeScript Request.query怎麽用?TypeScript Request.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mssql.Request的用法示例。


在下文中一共展示了Request.query方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

var connection = new mssql.Connection (config, function (err)
	{
	var request = new mssql.Request(connection);

	var command: string = sql_manipulate.delete_command_gen (id_in);

	request.query (command, function(err, rows)
		{
		if (err) throw err;

		console.log ("*** 終了 ***");
		});

	connection.close ();

});
開發者ID:ekzemplaro,項目名稱:data_base_language,代碼行數:16,代碼來源:mssql_delete.ts

示例2: function

request.query (command, function (err, rows)
	{
	for (var key in dict_aa)
		{
console.log (key);
		var sql_str: string  = "insert into cities ";
		sql_str += "(id,name,population,date_mod) values (";

		var str_data: string = "'" + key + "','" + dict_aa[key].name;
		str_data += "'," + dict_aa[key].population;
		str_data += ",'" + dict_aa[key].date_mod + "')";

		sql_str += str_data;
			request.query (sql_str);
		}

	connection.close ();
	console.log ("*** 終了 ***");
	});
開發者ID:ekzemplaro,項目名稱:data_base_language,代碼行數:19,代碼來源:mssql_create.ts

示例3: 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 => {
開發者ID:motionpicture,項目名稱:ttts-functions,代碼行數:19,代碼來源:pos_sales.ts

示例4: Date

app.get('/tweets', (req, res) => {
    const startTime = req.query.startTime;
    const endTime = req.query.endTime;
    
    const sqlQuery = `SELECT id, retweet_count, tweet_text, tweeted_by, tweet_id, created_at, timestamp
                      FROM dbo.tweets WHERE timestamp >= @startTime AND timestamp <= @endTime ORDER BY timestamp DESC`;
    
    const request = new sql.Request();
    request.input('startTime', sql.DateTime, new Date(startTime));
    request.input('endTime', sql.DateTime, new Date(endTime));
    
    request.query(sqlQuery).then((results) => {
         res.send(results).end();
        return;
    })
    .catch((ex) => {
        res.status(500).end();
    })
})
開發者ID:kenstone,項目名稱:tweeter-center,代碼行數:19,代碼來源:app.ts

示例5: function

sql.connect(config, function(err) {
    // ... error checks

    var request = new sql.Request();
    request.stream = true; // You can set streaming differently for each request
    request.query('select * from verylargetable'); // or request.execute(procedure);

    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(affected) {
        // Always emitted as the last one
    });
});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:23,代碼來源:streaming.ts

示例6: function

var connection = new mssql.Connection (config, function (err)
	{
	var request = new mssql.Request(connection);

	var str_sql: string = "select * from cities";

	request.query (str_sql, function(err, rows)
		{
		for (var it in rows)
			{
			var str_out: string = rows[it].id + "\t";
			str_out += rows[it].name + "\t";
			str_out += rows[it].population + "\t";
			str_out += rows[it].date_mod;
			console.log (str_out);
			}

		console.log ("*** 終了 ***");
		});

	connection.close ();

});
開發者ID:ekzemplaro,項目名稱:data_base_language,代碼行數:23,代碼來源:mssql_read.ts

示例7: function

var connection: sql.ConnectionPool = new sql.ConnectionPool(config, function (err: any) {
    if (err != null) {
        console.warn("Issue with connecting to SQL Server!");
    }
    else {
        connection.query`SELECT ${1} as value`.then(res => { });
        var requestQuery = new sql.Request(connection);

        var getArticlesQuery = "SELECT * FROM TABLE";

        requestQuery.query(getArticlesQuery, function (err, result) {
            if (err) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            // checking to see if the articles returned as at least one.
            else if (result.recordset.length > 0) {
            }
        });

        getArticlesQuery = "SELECT 1 as value FROM TABLE";

        requestQuery.query<Entity>(getArticlesQuery, function (err, result) {
            if (err) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);

            }
            // checking to see if the articles returned as at least one.
            else if (result.recordset.length > 0 && result.recordset[0].value) {
            }
        });

        var requestStoredProcedure = new sql.Request(connection);
        var testId: number = 0;
        var testString: string = 'test';

        requestStoredProcedure.input('pId', testId);
        requestStoredProcedure.input('pString', testString);


        requestStoredProcedure.execute('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(returnValue);
            }
        });

        requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(returnValue);
            }
        });

        var requestStoredProcedureWithOutput = new sql.Request(connection);
        var testId: number = 0;
        var testString: string = 'test';

        requestStoredProcedureWithOutput.input("name", sql.VarChar, "abc");               // varchar(3)
        requestStoredProcedureWithOutput.input("name", sql.VarChar(50), "abc");           // varchar(MAX)
        requestStoredProcedureWithOutput.output("name", sql.VarChar);                     // varchar(8000)
        requestStoredProcedureWithOutput.output("name", sql.VarChar, "abc");              // varchar(3)

        requestStoredProcedureWithOutput.input("name", sql.Decimal, 155.33);              // decimal(18, 0)
        requestStoredProcedureWithOutput.input("name", sql.Decimal(10), 155.33);          // decimal(10, 0)
        requestStoredProcedureWithOutput.input("name", sql.Decimal(10, 2), 155.33);       // decimal(10, 2)

        requestStoredProcedureWithOutput.input("name", sql.DateTime2, new Date());        // datetime2(7)
        requestStoredProcedureWithOutput.input("name", sql.DateTime2(5), new Date());     // datetime2(5)

        requestStoredProcedure.execute('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(requestStoredProcedureWithOutput.parameters['output'].value);
            }
        });

        requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
            }
            else {
                console.info(requestStoredProcedureWithOutput.parameters['output'].value);
            }
        });
    }
});
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:92,代碼來源:mssql-tests.ts

示例8: convert

/** Samples from https://github.com/patriksimek/node-mssql#metadata */

import * as sql from "mssql";

const request = new sql.Request();
request.query('select convert(decimal(18, 4), 1) as first, \'asdf\' as second', function(err, recordset: sql.RecordSet<any>) {
    console.dir(recordset.columns);

    console.log(recordset.columns["first"].type === sql.Decimal); // true
    console.log(recordset.columns["second"].type === sql.VarChar); // true
});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:11,代碼來源:metadata.ts

示例9: function

/** Samples from https://github.com/patriksimek/node-mssql#affected-rows */

import * as sql from "mssql";

// With promises
const request = new sql.Request();
request.query('update myAwesomeTable set awesomness = 100').then(function(recordset) {
    request.rowsAffected.toPrecision(2);
    console.log(request.rowsAffected);
});

// With Callback
const request2 = new sql.Request();
request2.query('update myAwesomeTable set awesomness = 100', function(err, recordset, affected) {
    affected.toPrecision(2);
    console.log(affected);
});
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:17,代碼來源:affectedrows.ts

示例10: function

/**
 * output https://github.com/patriksimek/node-mssql#output-name-type-value
 */

request.output('output_parameter', sql.Int);
request.output('output_parameter', sql.VarChar(50), 'abc');

/**
 * pipe https://github.com/patriksimek/node-mssql#pipe-stream
 */

const request1 = new sql.Request();
let stream: NodeJS.WritableStream;
request1.pipe(stream);
request1.query('select * from mytable');
stream.on('error', function(err) {
    // ...
});
stream.on('finish', function() {
    // ...
});

/**
 * query https://github.com/patriksimek/node-mssql#query-command-callback
 */

const request2 = new sql.Request();
request2.query('select 1 as number', function(err, recordset: sql.RecordSet<MyClass>) {
    // ... error checks
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:29,代碼來源:request.ts


注:本文中的mssql.Request.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。