Page 1 of 1

SQL server with sequence's

Posted: Wed 28 Dec 2016 10:55
by Sergo
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;

Re: SQL server with sequence's

Posted: Thu 29 Dec 2016 12:32
by azyk
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

Re: SQL server with sequence's

Posted: Thu 29 Dec 2016 13:35
by Sergo
Thank you for the answer. It works.