How to find the PKs of a table

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

How to find the PKs of a table

Post by radub » Tue 04 Feb 2014 16:02

Hello,

Is there any way to find the primary key of a given table?
Something similar with "GetKeyList" from ODAC or "GetFieldDesc(FieldName).IsKey" from SDAC.

Thank you,
Radu B.

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

Re: How to find the PKs of a table

Post by AlexP » Wed 05 Feb 2014 16:36

Hello,

To retrieve information about Constraint and Index, you can use the TPgMetaData component

Code: Select all

  PgMetaData1.Restrictions.Values['TABLE_NAME'] := 'your_table_name';
  PgMetaData1.MetaDataKind := 'Constraints'; //IndexColumns, ...
  PgMetaData1.Open;

radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

Re: How to find the PKs of a table

Post by radub » Thu 06 Feb 2014 06:59

I succeeded in obtain the fields working with PgMetaData.
It should be better to have a more detailed help above the functionalities for this component.

Case closed.

Thank you,
Radu B.

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

Re: How to find the PKs of a table

Post by AlexP » Thu 06 Feb 2014 12:31

Description of this component properties is in the PgDAC documentation: http://www.devart.com/pgdac/docs/index. ... tadata.htm

Post Reply