1

Trying to call sql server sproc from node.js using "mssql" module, when we call, it throws the error "EREQUEST", Error Details :"RequestError: Cannot insert the value NULL into column 'colName'". Don't know why but when run it on sql server it works as expected and gives the result. My Sproc containing the temp table and insert the null values in some of the columns.Please refer the following code.

    var request = new sql.Request();
    request.input("param1", value1);
    request.input('param2', value2);

    request.stream = true;  
    request.execute('Sp_Name', function (err, recordset) {
    });

    var rows = [];
    request.on('row', function (row) {
        rows.push(row);
        console.dir(row);
    });

    request.on('error', function (err) {
        console.log('IN error =>' + err.code + "=>"  +err);

    });

    request.on('done', function (returnValue) {
        console.log('IN Done');
    });

thanks for your help..:)

Vinay K
  • 463
  • 6
  • 18
Sachin
  • 109
  • 1
  • 8
  • Any time I run into a SQL statement not doing the same as when it's called by a client, it usually means there's some difference between what you simulate in SSMS and what the application is actually calling. I'd start by tracing how colName is populated in the proc, and work your way backwards and see how whatever is put into that column could end up null based on your input parameters. Without seeing the SQL code however, your guess is as good as mine. – Xedni Feb 11 '15 at 07:36
  • @Xedni, there is no point in doing that, he says that stored procedure runs fine on the server, but, does not work through NodeJS mssql, so, it obvious that problem is related to NodeJS mssql not with stored procedure. – Vinay K Feb 16 '15 at 13:05
  • @VinayKharecha how do you figure there's no point? The error being surfaced is a SQL Server database error, so clearly the call is getting through to the database.If the call he's making in SSMS works, but the "equivalent" call from Node returns that error, it's a problem with the parameters to the procedure and what is being passed into the procedure. Which leads me back to what I posted on the 11th. Either find out a way to debug exactly what is literally being passed into SQL, or work from the other end, and determine which parameters on the procedure could lead to such an error. – Xedni Feb 16 '15 at 18:21
  • 1
    @Xedni I am passing same parameters in both(i.e SSMS and node.js) and also debug from node.js for what is been pass it was the same parameters. – Sachin Feb 17 '15 at 05:29

0 Answers0