DEV Community

rajeshalda
rajeshalda

Posted on

Calling the SP from MSsql issuse

I am trying to calling the SP from MSSQL and I am getting an error:

exports.ExportPropertyReport = catchAsyncErrors(async(req, res, APN, TimeTrend, MONTH_YEAR, lowrange, highrange) => {
    // const APN = req.body.APN;
    try {
        let pool = await sql.connect(config, { requestTimeout: 30000 })
        //let pool = await sql.connect(config)
        let result = await pool.request()
            .input('APN', sql.Float, APN)
            .input('TimeTrend', sql.NVarChar, TimeTrend)
            .input('MONTH_YEAER', sql.NVarChar, MONTH_YEAR)
            .input('LOWRANGE', sql.VarChar, lowrange)
            .input('HighRange', sql.VarChar, highrange)
            .execute('dbo.Usp_ExportPropertyReport')

        console.log(result.recordset);

        sql.close();

        res.status(200).json({
            success: true,
            message: `ExportPropertyReport called successfully`,
            result
        });

    } catch (err) {
        console.log(err);
        res.status(500).json({
            "error": true,
            "message": "Error executing query"
        });
    }
});
Enter fullscreen mode Exit fullscreen mode

error message :

RequestError: Validation failed for parameter 'APN'. Invalid number. at Request.userCallback (E:\spcall\node_modules\mssql\lib\tedious\request.js:811:19) at Request.callback (E:\spcall\node_modules\tedious\lib\request.js:205:14) at E:\spcall\node_modules\tedious\lib\connection.js:1982:17 at processTicksAndRejections (node:internal/process/task_queues:78:11) { code: 'EPARAM',

Top comments (1)

Collapse
 
yarkul profile image
yarkul

Can you show the stored procedure? What APN type is there?