🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.delphi.bazy-danych
1 messages
1 total messages Started by Tomek Thu, 13 Aug 2015 12:16
IBX TIBOutputDelimitedFile i nie działający OnCalcFields
#82550
Author: Tomek
Date: Thu, 13 Aug 2015 12:16
47 lines
2449 bytes
Witam,

Robię coś takiego (w skrócie):

  baza.toFile.FieldDefs.Clear;

  AnyField := TIBStringField.Create(baza.toFile);
  AnyField.FieldName := 'ANYTXT';
  AnyField.Calculated := True;
  AnyFieldield.DataSet := baza.toFile;

  myFieldsList := AnyField.FieldName;

  if baza.toFile.Active = TRUE then
    baza.toFile.Active := FALSE;

  with baza.toFile do
  begin
    SQL.Clear;
    SQL.Add(' SELECT ');
    SQL.Add(myFieldsList);   
    SQL.Add(' FROM ANYTABLE ');
    Prepare;
    Open; 
  end;

  OutputFile := TIBOutputDelimitedFile.Create;
    try
      OutputFile.ColDelimiter := ',';
      OutputFile.OutputTitles := TRUE;
      OutputFile.FileName := 'D:\temp\tmp.csv';
      baza.toFile.State
      baza.toFile.BatchOutput(OutputFile);
    finally
      OutputFile.Destroy;
    end;

toFile to TIBQuery ze zdefiniowanym zdarzeniem OnCalcFields. Podłączyłem na próbe TDBGrid przez DataSource i rzeczywiście dane textowe z selecta zmienił w DBGridzie. Natomiast w pliku nie mam wartości wyliczonej tylko to co jest faktycznie w tabeli.

procedure TDataModule.toFileCalcFields(DataSet: TDataSet);
begin
  DataSet.FieldByName('ANYTXT').AsString := 'asdfg'; // example
end;

Jak zmusić OutputFile by używał metody onCalcFields obiektu(toFile) ?

Ver IBX 5.06
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads