SQL server with sequence's

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Sergo
Posts: 6
Joined: Wed 28 Dec 2016 10:48

SQL server with sequence's

Post by Sergo » Wed 28 Dec 2016 10:55

Hello,
i am using unidac 6.3.13. I have Sql server 2012 where is use for id values sequence.
The table is generated like this:
ALTER TABLE [dbo].[l_matriksi] ADD CONSTRAINT [DF_L_MATRIKSI_id_matriksa] DEFAULT (NEXT VALUE FOR [id_matriksa_seq]) FOR [id_matriksa].

Table is l_matriksi, key field is id_matriksa, and sequence is id_matriksa_seq.

When i use insert and post i cant get back key field value?
uniquery1.insert;
uniquery.Post;

uniquery.fieldbyname('id_matriksa').AsInteger <- this is empty

Records are inserted ok.
Is there any settings i should use? In order that this insert works i only set RequiredFields := false;

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

Re: SQL server with sequence's

Post by azyk » Thu 29 Dec 2016 12:32

To obtain the key field value generated on the server when inserting a record, set the
TUniQuery.Options.DefaultValues property value to True. More information about DefaultValues in our online documentation: https://www.devart.com/unidac/docs/?dev ... values.htm

Sergo
Posts: 6
Joined: Wed 28 Dec 2016 10:48

Re: SQL server with sequence's

Post by Sergo » Thu 29 Dec 2016 13:35

Thank you for the answer. It works.

Post Reply