TUniMetaData - Find AutoIncrement fields

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tkoscielski
Posts: 5
Joined: Mon 10 Jul 2017 21:49

TUniMetaData - Find AutoIncrement fields

Post by tkoscielski » Fri 21 Jul 2017 14:58

With TUniMetaData, I have looked at all the information it provides for various MetaDataKind options for different database types. The one thing I am having a problem finding is auto increment fields.

Is this attribute easily defined or perhaps I need some help interpreting the data I am looking at.

Thank you.

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

Re: TUniMetaData - Find AutoIncrement fields

Post by azyk » Mon 24 Jul 2017 11:30

TUniMetaData does not provide metadata about autoincrement fields. You can use the following code to determine the autoincrement field in the dataset:

Code: Select all

uses 
  ..., DBAccess, CRAccess;
...
procedure TForm1.Button1Click(Sender: TObject);
var
  RecordSet: TCRRecordSet;
begin
  ...
  UniQuery1.SQL.Text := 'select * from emp';
  UniQuery1.Open;
  RecordSet := TDBAccessUtils.GetIRecordSet(UniQuery1);

  if RecordSet.IdentityField <> nil then
    ShowMessage('IdentityField=' + RecordSet.IdentityField.Name)
  else
    ShowMessage('No identity field');
end;
Alternatively, you can create SQL queries by yourself to get metadata for each Uni provider.

tkoscielski
Posts: 5
Joined: Mon 10 Jul 2017 21:49

Re: TUniMetaData - Find AutoIncrement fields

Post by tkoscielski » Tue 25 Jul 2017 14:03

Thank you. I have actually decided to go the route of writing the SQL query for the meta data of each type to collect this info.

Post Reply