Page 1 of 1
primary index
Posted: Tue 09 Feb 2016 10:04
by uffek
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
Re: primary index
Posted: Tue 09 Feb 2016 10:44
by AlexP
You can use the IndexFieldNames property for sorting:
https://www.devart.com/unidac/docs/?dev ... dnames.htm .
Re: primary index
Posted: Tue 09 Feb 2016 11:14
by uffek
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?
Re: primary index
Posted: Tue 09 Feb 2016 12:56
by AlexP
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;
Re: primary index
Posted: Tue 09 Feb 2016 13:50
by uffek
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.
Re: primary index
Posted: Wed 10 Feb 2016 19:37
by uffek
Solved: A fully qualified tablename was needed "schema.tablename".
Re: primary index
Posted: Thu 11 Feb 2016 06:30
by AlexP
Glad to see that you solved the problem. If you have any other questions, feel free to contact us
Re: primary index
Posted: Thu 11 Feb 2016 06:38
by uffek
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.
Re: primary index
Posted: Thu 11 Feb 2016 08:14
by AlexP
We will add description of this method to the help shortly.