Interbase - Importando e Exportando |
Top Previous Next |
// Exportando do Interbase com Raw Data procedure TForm1.Button1Click(Sender: TObject); var RawOutput : TIBOutputRawFile; begin IBSQL1.SQL.Text := 'Select name, number, hired from Source'; RawOutput := TIBOutputRawFile.Create; try RawOutput.Filename := 'source_raw'; IBSQL1.BatchOutput(RawOutput); finally RawOutput.Free; end; end;
// Importando para o Interbase com Raw Data procedure TForm1.Button2Click(Sender: TObject); var RawInput : TIBInputRawFile; begin IBSQL2.SQL.Text := 'Insert into Destination values(:name, :number, :hired)'; RawInput := TIBInputRawFile.Create; try RawInput.Filename := 'source_raw'; IBSQL2.BatchInput(RawInput); finally RawInput.Free; end; end;
//////////////////////////////////////////////////////////////////////////////// // Por padrão o arquivo gerado tabulado. Se você quiser mudar o delimitador // do arquivo basta incluir. DelimOutput.ColDelimiter := ',';
// Exportando do Interbase com Delimited Data 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; {Inclua aqui o delimitador} try DelimOutput.Filename := 'source_delim'; IBSQL3.BatchOutput(DelimOutput); finally DelimOutput.Free; IBSQL3.Transaction.Commit; end; end;
// Importando para o Interbase com Delimited Data procedure TForm1.Button4Click(Sender: TObject); var DelimInput : TIBInputDelimitedFile; begin IBSQL4.Database.Open; IBSQL4.Transaction.StartTransaction; IBSQL4.SQL.Text := 'Insert into Destination values(:name, :number, :hired)'; DelimInput := TIBInputDelimitedFile.Create; {Inclua aqui o delimitador} try DelimInput.Filename := 'source_delim'; IBSQL4.BatchInput(DelimInput); finally DelimInput.Free; IBSQL4.Transaction.Commit; end; end;
|