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


TypeScript mssql.Decimal函數代碼示例

本文整理匯總了TypeScript中mssql.Decimal函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Decimal函數的具體用法?TypeScript Decimal怎麽用?TypeScript Decimal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: test_table

function test_table() {
    var table = new sql.Table('#temp_table');

    table.create = true;

    table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
    table.columns.add('type', sql.Int, { nullable: false });
    table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });

    table.rows.add('name', 42, 3.50);
    table.rows.add('name2', 7, 3.14);
}
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:12,代碼來源:mssql-tests.ts

示例2: 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

示例3: varchar

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

import * as sql from "mssql";

const request = new sql.Request();

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

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

request.input("name", sql.DateTime2, new Date());        // datetime2(7)
request.input("name", sql.DateTime2(5), new Date());     // datetime2(5)
開發者ID:typed-contrib,項目名稱:node-mssql,代碼行數:18,代碼來源:datatypes.ts


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