Exporting Delimited Data

From InterBase
Jump to: navigation, search

Go Up to Exporting and Importing Delimited Data


To export delimited data, you will need TIBSQL, TIBDatabase, and TIBTransaction components. Set up the database component, and associate the components with each other. In the following example, the database and transaction components are set to active in the code.

Tip: Use the Database Editor to set up the database component. To start the Database Editor, right click the database component with the mouse and select Database Editor from the drop-down menu.

The following code snippet outputs selected data with a SQLSELECT statement from the SOURCE table to the file source_delim.

procedure TForm1.Button3Click(Sender: TObject);
var
DelimOutput : TIBOutputDelimitedFile;
begin
IBSQL3.Database.Open;
IBSQL3.Transaction.StartTransaction;
IBSQL3.SQL.Text := 'Select name, number, hired from Source';
DelimOutput := TIBOutputDelimitedFile.Create;
try
DelimOutput.Filename := 'source_delim';
IBSQL3.BatchOutput(DelimOutput);
finally
DelimOutput.Free;
IBSQL3.Transaction.Commit;
end;
end;