Subject | Re: [IBO] Dynamically discover primary key name |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2006-07-03T07:41:08Z |
A place to find answers to many such questions in the general term (not
IBO specific, hence no mentioning of KeyFields) is www.fbtalk.net. This
particular question is answered by this thread:
http://www.fbtalk.net/viewtopic.php?id=214
Though in this particular case, I'd suggest removing 'LEFT' from 'LEFT
JOIN RDB$INDICES' in it's suggested answer. Left joins should only be
used when necessary or occationally for improving performance.
Otherwise, fbtalk is generally a good place to find answers to system
table queries.
Set
Ramil wrote:
IBO specific, hence no mentioning of KeyFields) is www.fbtalk.net. This
particular question is answered by this thread:
http://www.fbtalk.net/viewtopic.php?id=214
Though in this particular case, I'd suggest removing 'LEFT' from 'LEFT
JOIN RDB$INDICES' in it's suggested answer. Left joins should only be
used when necessary or occationally for improving performance.
Otherwise, fbtalk is generally a good place to find answers to system
table queries.
Set
Ramil wrote:
> 1. KeyFields property of dataset.
> 2. SQL query for all Tables:
> SELECT I.RDB$RELATION_NAME, S.RDB$FIELD_NAME
> FROM RDB$RELATION_CONSTRAINTS C,
> RDB$INDICES I,
> RDB$INDEX_SEGMENTS S
> WHERE RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
> AND C.RDB$RELATION_NAME = I.RDB$RELATION_NAME
> AND C.RDB$INDEX_NAME = I.RDB$INDEX_NAME
> AND I.RDB$INDEX_NAME = S.RDB$INDEX_NAME
> ORDER BY 1,2;
> You can change this query for the necessary table only.
>
> Best regards,
> Ramil
>>
>> Hi guys. Does anyone knows if there are any way to dinamically
>> discover the primary key name of any table with ibo? Thanks in advance
>> for all help.