Delphi-Quellcode:
if (Recordcount > 0) and
not (FieldByName(aFeld).IsNull) and
not (FieldByName(aFeld).asString.IsEmpty) and
((FindField('GELOESCHT') = nil) or (Locate('GELOESCHT', 0, []))) then
Result := FieldByName(aFeld).AsString;
Nice
P.S.: als Zeichen meiner Läuterung; hier der akutelle Code - ohne with -
Delphi-Quellcode:
function GetFeldwertFromID(aTabelle, aFeld: string; aID: integer): Variant;
var
MyQuery: TFDQuery;
begin
Result := StrKeinEintrag;
MyQuery := TFDQuery.Create(MyDB);
try
MyQuery.Connection := MyDB;
if (MyQuery.Connection.Connected) and (aID > 0) then
begin
MyQuery.SQL.Text := 'select * from &pTabelle where ID = :pID';
MyQuery.MacroByName('pTabelle').asRaw := aTabelle;
MyQuery.ParamByName('pId').asInteger := aId;
try
MyQuery.open;
if (MyQuery.Recordcount > 0) and
not (MyQuery.FieldByName(aFeld).IsNull) and
not (MyQuery.FieldByName(aFeld).asString.IsEmpty) and
((MyQuery.FindField('GELOESCHT') = nil) or (MyQuery.Locate('GELOESCHT', 0, []))) then
Result := MyQuery.FieldByName(aFeld).AsString;
except
raise;
end;
end;
finally
MyQuery.Close;
MyQuery.Free;
end;
end;
Michael H.