community.borland.com

Article #26393: How to insert new lines into external files

Q. I have a table in an InterBase database that I want to insert into an external file that includes new lines. How do I get the new lines into the external file?

A. What a new line is varies on your platform. For UNIX it is a single line feed. For Windows it is a carrage return line feed combination. This example will create new lines for Windows.

If you have Delphi or C++ Builder the simplest way to create a text file is to use the BatchMove component. Here are simple step by step directions. These steps assume the BDE is installed.

If you have Delphi or C++ Builder you can also use a straight INSERT statement doing the following:

Query.SQL.Clear;
Query.SQL.ADD('INSERT INTO DEST SELECT Field1,Field2,"' + #13#10 + '" FROM Source');
Query.ExecSQL;

In this example #13#10 is equivilent to a Carrage Return and a Line Feed. It assumes Dest is a foreign file table specification you have already created.

Finally, the Developer Guide manual included with InterBase 6 includes steps to fill a foreign text file using InterBase express. If you use a SELECT statement similar to the SELECT statement embeded in the INSERT statement about that includes #13#10 InterBase Express can create a foreign file with new lines in it.

Last Modified: 02-JAN-01