function GetTable(TableName, SourceName, FieldName,
Code: string): string;
begin
result := '';
try
with cdsSQL do
begin
Close;
Data := null;
CommandText := ' select ' + FieldName +
' from ' + TableName +
' where ' + SourceName +
' = ''' + Trim(code) + '''';
Open;
if recordcount = 1 then
result := FieldByName(FieldName).asstring
else
result := '';
end;
finally
cdsSQL.Close;
end;
end;