How to use the mssql.Decimal function in mssql

To help you get started, we’ve selected a few mssql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / mssql / mssql-tests.ts View on Github external
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('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
github DefinitelyTyped / DefinitelyTyped / types / mssql / mssql-tests.ts View on Github external
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('StoredProcedureName', function (err, recordsets, returnValue) {
            if (err != null) {
                console.error(`Error happened calling Query: ${err.name} ${err.message}`);
github DefinitelyTyped / DefinitelyTyped / types / mssql / mssql-tests.ts View on Github external
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);
}
github dymajo / waka / server-worker / db / gtfs-import.js View on Github external
const table = new sql.Table(name)
    if (name === 'agency') {
      table.columns.add('agency_id', sql.VarChar(50), {nullable: false})
      table.columns.add('agency_name', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_url', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_timezone', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_lang', sql.VarChar(50), {nullable: true})
      table.columns.add('agency_phone', sql.VarChar(50), {nullable: true})
      table.columns.add('agency_fare_url', sql.VarChar(100), {nullable: true})
      table.columns.add('agency_email', sql.VarChar(50), {nullable: true})
    } else if (name === 'stops') {
      table.columns.add('stop_id', sql.VarChar(100), {nullable: false})
      table.columns.add('stop_code', sql.VarChar(50), {nullable: true})
      table.columns.add('stop_name', sql.VarChar(100), {nullable: false})
      table.columns.add('stop_desc', sql.VarChar(150), {nullable: true})
      table.columns.add('stop_lat', sql.Decimal(10,6), {nullable: false})
      table.columns.add('stop_lon', sql.Decimal(10,6), {nullable: false})
      table.columns.add('zone_id', sql.VarChar(50), {nullable: true})
      table.columns.add('stop_url', sql.VarChar(100), {nullable: true})
      table.columns.add('location_type', sql.Int, {nullable: true})
      table.columns.add('parent_station', sql.VarChar(100), {nullable: true})
      table.columns.add('stop_timezone', sql.VarChar(100), {nullable: true})
      table.columns.add('wheelchair_boarding', sql.Int, {nullable: true})
    } else if (name === 'routes') {
      table.columns.add('route_id', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_id', sql.VarChar(100), {nullable: true})
      table.columns.add('route_short_name', sql.VarChar(50), {nullable: false})
      table.columns.add('route_long_name', sql.VarChar(150), {nullable: false})
      table.columns.add('route_desc', sql.VarChar(150), {nullable: true})
      table.columns.add('route_type', sql.Int, {nullable: false})
      table.columns.add('route_url', sql.VarChar(100), {nullable: true})
      table.columns.add('route_color', sql.VarChar(50), {nullable: true})
github dymajo / waka / server-worker / db / gtfs-import.js View on Github external
if (name === 'agency') {
      table.columns.add('agency_id', sql.VarChar(50), {nullable: false})
      table.columns.add('agency_name', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_url', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_timezone', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_lang', sql.VarChar(50), {nullable: true})
      table.columns.add('agency_phone', sql.VarChar(50), {nullable: true})
      table.columns.add('agency_fare_url', sql.VarChar(100), {nullable: true})
      table.columns.add('agency_email', sql.VarChar(50), {nullable: true})
    } else if (name === 'stops') {
      table.columns.add('stop_id', sql.VarChar(100), {nullable: false})
      table.columns.add('stop_code', sql.VarChar(50), {nullable: true})
      table.columns.add('stop_name', sql.VarChar(100), {nullable: false})
      table.columns.add('stop_desc', sql.VarChar(150), {nullable: true})
      table.columns.add('stop_lat', sql.Decimal(10,6), {nullable: false})
      table.columns.add('stop_lon', sql.Decimal(10,6), {nullable: false})
      table.columns.add('zone_id', sql.VarChar(50), {nullable: true})
      table.columns.add('stop_url', sql.VarChar(100), {nullable: true})
      table.columns.add('location_type', sql.Int, {nullable: true})
      table.columns.add('parent_station', sql.VarChar(100), {nullable: true})
      table.columns.add('stop_timezone', sql.VarChar(100), {nullable: true})
      table.columns.add('wheelchair_boarding', sql.Int, {nullable: true})
    } else if (name === 'routes') {
      table.columns.add('route_id', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_id', sql.VarChar(100), {nullable: true})
      table.columns.add('route_short_name', sql.VarChar(50), {nullable: false})
      table.columns.add('route_long_name', sql.VarChar(150), {nullable: false})
      table.columns.add('route_desc', sql.VarChar(150), {nullable: true})
      table.columns.add('route_type', sql.Int, {nullable: false})
      table.columns.add('route_url', sql.VarChar(100), {nullable: true})
      table.columns.add('route_color', sql.VarChar(50), {nullable: true})
      table.columns.add('route_text_color', sql.VarChar(50), {nullable: true})
github dymajo / waka / server-worker / stops / search.js View on Github external
return new Promise((resolve, reject) => {
      const latDist = distance / 100000
      const lonDist = distance / 65000

      const sqlRequest = connection.get().request()
      sqlRequest.input('stop_lat_gt', sql.Decimal(10, 6), lat - latDist)
      sqlRequest.input('stop_lat_lt', sql.Decimal(10, 6), lat + latDist)
      sqlRequest.input('stop_lon_gt', sql.Decimal(10, 6), lon - lonDist)
      sqlRequest.input('stop_lon_lt', sql.Decimal(10, 6), lon + lonDist)
      sqlRequest
        .query(
          `
        select
          stop_code as stop_id,
          stop_name,
          stop_lat,
          stop_lon
        from stops
        where
          (location_type = 0 OR location_type IS NULL)
          and stop_lat > @stop_lat_gt and stop_lat < @stop_lat_lt
          and stop_lon > @stop_lon_gt and stop_lon < @stop_lon_lt`
        )
        .then(result => {
          const stops = search._stopsFilter(