javascriptsql-servernode.jstdsnode-sqlserver

Inserting data using Prepare statement doesn't return inserted record


I am using node-sql. recordSet is undefined when i try to insert record in a table using Prepare Statement. Below is the sample line of code.

ps.execute(data, function (err, recordSet, affected) { });

Although record is successfully inserted into database but it gives me undefined variable in callback function.


Solution

  • Yes i found an answer, We need to specify records to be returned using the OUTPUT clause. Like:

    INSERT INTO Table OUTPUT.Id VALUES(...);