primary index

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
uffek
Posts: 37
Joined: Fri 14 Nov 2014 21:49
Location: Roskilde, DK

primary index

Post by uffek » Tue 09 Feb 2016 10:04

How can I set the index to be the primary index for a TUniTable?
I need records to be returned in that order.

6.2.10, on D10

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: primary index

Post by AlexP » Tue 09 Feb 2016 10:44

You can use the IndexFieldNames property for sorting: https://www.devart.com/unidac/docs/?dev ... dnames.htm .

uffek
Posts: 37
Joined: Fri 14 Nov 2014 21:49
Location: Roskilde, DK

Re: primary index

Post by uffek » Tue 09 Feb 2016 11:14

I don't know the name of the field(s) making up the primary key. How do I find it? Can I somehow test either the whole table or each individual field?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: primary index

Post by AlexP » Tue 09 Feb 2016 12:56

To retrieve the key field name, you can use the TUniConnection.GetKeyFieldNames method:

Code: Select all

  lst := TStringList.Create;
  try
    UniConnection1.GetKeyFieldNames('DEPT', lst);
    for I := 0 to Lst.Count - 1 do
      ShowMessage(Lst[i]);
  finally
    lst.Free;
  end;

uffek
Posts: 37
Joined: Fri 14 Nov 2014 21:49
Location: Roskilde, DK

Re: primary index

Post by uffek » Tue 09 Feb 2016 13:50

Thank, that works nicely for our oracle and postgresql database, but gives this error on mssql: "Unsupported metadata kind". Any trick there? (SQL Server 2008 R2 "express")

When looking in the documentation, I can see it was a new function in 5.5, but it is not listed otherwise.

uffek
Posts: 37
Joined: Fri 14 Nov 2014 21:49
Location: Roskilde, DK

Re: primary index

Post by uffek » Wed 10 Feb 2016 19:37

Solved: A fully qualified tablename was needed "schema.tablename".

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: primary index

Post by AlexP » Thu 11 Feb 2016 06:30

Glad to see that you solved the problem. If you have any other questions, feel free to contact us

uffek
Posts: 37
Joined: Fri 14 Nov 2014 21:49
Location: Roskilde, DK

Re: primary index

Post by uffek » Thu 11 Feb 2016 06:38

This one is still open:
http://forums.devart.com/viewtopic.php?f=5&t=33107

And I hope you have made a note that documentation for GetKeyFieldNames is missing.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: primary index

Post by AlexP » Thu 11 Feb 2016 08:14

We will add description of this method to the help shortly.

Post Reply