Hy there
How can i get the generatorname from a field in a table?
i use firebird 2
thanks for reply
generatorname from a field
Moderators: gto, EgonHugeist
hy seawolf thanks for your reply.
i now had a look at the metadata tables from firebird and there is a table called dependencies now if i made a trigger for the generater i can read the generatorname from the table.
something like that
i now had a look at the metadata tables from firebird and there is a table called dependencies now if i made a trigger for the generater i can read the generatorname from the table.
something like that
Code: Select all
function GetGeneratorNameFromTableAndField(sTableName, sFieldName: String): String;
var
tempquery : TZQuery;
sTriggerName : String;
begin
tempquery := TZQuery.Create(nil);
tempquery.Connection := DBDataMod.ZCDB;
tempquery.SQL.Add('Select * From RDB$DEPENDENCIES where RDB$DEPENDED_ON_NAME = '''+sTableName+''' and RDB$FIELD_NAME = '''+sFieldName+'''');
tempquery.Open;
if tempquery.RecordCount > 0 then begin //RDB$DEPENDENT_NAME
sTriggerName := tempquery.FieldByName('RDB$DEPENDENT_NAME').AsString;
end else begin
sTriggerName:='';
end;
if sTriggerName = '' then begin
result := '';
end else begin
tempquery.Close;
tempquery.SQL.Clear;
tempquery.SQL.Add('Select CAST(RDB$DEPENDED_ON_NAME as VARCHAR(255)) gen From RDB$DEPENDENCIES where RDB$DEPENDENT_NAME = '''+sTriggerName+''' and RDB$FIELD_NAME is NULL');
tempquery.Open;
if tempquery.RecordCount = 0 then begin
result := '';
end else begin
result := tempquery.FieldByName('GEN').AsString;
end;
end;
tempquery.Close;
tempquery.Free;
end;