TMSQuery and RowsAffected

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 104
Joined: Sat 18 Aug 2012 08:33

TMSQuery and RowsAffected

Post by LHSoft » Fri 07 Oct 2016 10:14

I want to insert a new row into a table with an autoincrement field and want to know the autoincrement value after row inserted.
usually I use TMSSQL but I want a feedback so I think Ihave to use TMSQuery instead with following example syntax:

Code: Select all

INSERT INTO Table (fieldA) 
OUTPUT Inserted.Id
VALUES ('xyz')
The statement works fine, but I get -1 as RowsAffected, but should be 1?
Is this a bug or a mistake on my side?

best regards

Devart Team
Posts: 1058
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSQuery and RowsAffected

Post by azyk » Tue 11 Oct 2016 12:38

We have investigated the behavior you described. The reason is that after execution of the INSERT INTO ... OUTPUT SQL query SQL Server returns us Rowset, but doesn't return the value of RowsAffected, and we can't affect this.

Post Reply