Tem como saber este campo e Primary Key?

Delphi

30/04/2003

Ola pessoal, sera que existem uma propriedade que me retorne True caso o campo seja primary key ex:

if Sys_Campos.FieldByName(´cCampo´).AsString then
ShowMessage(´Este campo e Primary key´)





:wink:


Rodrigo Ferreira

Rodrigo Ferreira

Curtidas 0

Respostas

Infante

Infante

30/04/2003

Tem Sim.
se vc estiver utilizando interbase e firebird o código abaixo servirá, transforme ele numa função.
este código busca a informação no schema do BD
.......................................................................
select rdb$field_name,RDB$FIELD_POSITION
from RDB$index_segments
where rdb$index_name IN ( select RDB$index_name
from RDB$relation_constraints
where rdb$constraint_type = ´PRIMARY KEY¬´ and
RDB$Field_name = ´Nome do Campo que deseja Verificar´


GOSTEI 0
Rodrigo Ferreira

Rodrigo Ferreira

30/04/2003

Valeu ! :wink:


GOSTEI 0
POSTAR