[...]
if dbDataSet.Active
then dbDataSet.Close;
dbDataSet.CommandText := GetSQLFile(
SQL);
Screen.Cursor := crSQLWait;
try
dbDataSet.Open;
finally
Screen.Cursor := crDefault;
end;
Table.Clear;
//TStringlist
GetFieldConfig(dbDataSet.FieldCount, ExtractFileName(
SQL));
Output('
Daten des SQL "' + ExtractFileName(
SQL) + '
" werden gespeichert.');
Screen.Cursor := crHourGlass;
try
while not dbDataSet.Eof
do begin
Row.Clear;
//TStringlist
for i := 0
to dbDataSet.FieldCount - 1
do begin
s := trim(dbDataSet.Fields[i].AsString);
if Option(cOptionGetWeekByDate, i)
then s := GetWeek(dbDataSet.Fields[GetWantedField(cOptionGetWeekByDate + '
(', '
)', i)].AsDateTime);
if fFieldLength[i] > -1
then begin
if fFieldLength[i] < Length(s)
then s := copy(s, 1, fFieldLength[i]);
if fFieldLength[i] > Length(s)
then begin
if Option(cOptionFillLengthLeft, i)
then
s := FillString(s, fFieldLength[i], false)
else if Option(cOptionFillLengthRight, i)
then
s := FillString(s, fFieldLength[i], true);
end;
end;
Row.Add(s);
end;
Row.Delimiter := '
;';
//damit's eine csv kompatible Datei wird
Table.Add(Row.DelimitedText);
dbDataSet.Next;
end;
Table.SaveToFile(OutputFile);
//TStringlist speichern - dadurch wird eine csv kompatible Datei erstellt
finally
Screen.Cursor := crDefault;
end;
[...]