Page 1 of 1

MS SQL Azure, last autoinc value with TUniTable/TUniQuery

Posted: Wed 24 May 2017 10:19
by StefanDWC
Hello, how can i retrive the last autoinc value which is generated by inserting of my latest record in a TUniTable or TUniQuery?
if i post a insert script manually then can i use the MS SQL script variable @@IDENTITY.
However, if i use e.g., TUniTable.Insert + TUniTable.Post, how can i get the value then?

Re: MS SQL Azure, last autoinc value with TUniTable/TUniQuery

Posted: Fri 26 May 2017 13:50
by azyk
After inserting record in the TUniTable dataset you can get auto-increment field value from the TUniQuery.LastInsertId:
Https://www.devart.com/unidac/docs/inde ... sertid.htm

Re: MS SQL Azure, last autoinc value with TUniTable/TUniQuery

Posted: Sun 28 May 2017 10:06
by StefanDWC
Thanks for reply.
From your link:
Can be used with MySQL and PostgreSQL servers to get the value of the ID field after executing INSERT statement.
But, i use SQL Server and Azure, where the property is always zero.
As long i use TUniQuery like TUniTable, only with additional SQL filters, have i a solution (over the DoAfterPost methode) which work with most of my tables where i have a default identity field which have always the same name.

However, i would appreciate a native solution from your side.

Re: MS SQL Azure, last autoinc value with TUniTable/TUniQuery

Posted: Fri 16 Jun 2017 10:13
by azyk
Your solution is correct and we cannot propose anything better.