Board index » delphi » Export to text file

Export to text file


2008-05-04 12:59:08 AM
delphi138
Is there a way to directly export data (determined by a SQL) from interbase
to a .csv file?
I am coding in VB/VBA and I can do it via an ADO recordset, but wonder if
there is a direct way.
We are still on Interbase 5.6.
RBS
 
 

Re:Export to text file

RB Smissaert writes:
Quote
Is there a way to directly export data (determined by a SQL) from
interbase to a .csv file?
No. You can export to a fixed length ASCII file but that is the only
format that is supported.
--
Bill Todd (TeamB)
 

Re:Export to text file

OK, that might be fine as well.
How would I do that from VB?
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>Is there a way to directly export data (determined by a SQL) from
>interbase to a .csv file?

No. You can export to a fixed length ASCII file but that is the only
format that is supported.

--
Bill Todd (TeamB)
 

Re:Export to text file

RB Smissaert writes:
Quote
How would I do that from VB?
What is VB?<g>Seriously, I have no idea. The last time I wrote any
BASIC was on a GE mainframe in 1970.
--
Bill Todd (TeamB)
 

Re:Export to text file

OK, I can see that it is done via an external table and will see if I can
figure it out.
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>How would I do that from VB?

What is VB?<g>Seriously, I have no idea. The last time I wrote any
BASIC was on a GE mainframe in 1970.

--
Bill Todd (TeamB)
 

Re:Export to text file

How would you do it from whatever language you know?
Had a look in the documentation, but can not see it yet.
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>How would I do that from VB?

What is VB?<g>Seriously, I have no idea. The last time I wrote any
BASIC was on a GE mainframe in 1970.

--
Bill Todd (TeamB)
 

Re:Export to text file

RB Smissaert writes:
Quote
OK, I can see that it is done via an external table and will see if I
can figure it out.
I thought you were asking how to read and write a fixed length text
file in VB. If you have questions about using external tables in IB I
would be happy to try to help.
--
Bill Todd (TeamB)
 

Re:Export to text file

What I'd like to do is create an external table, which is a text file
and then
write to that external table with an INSERT with a SELECT on regular
Interbase tables.
Just found this one:
dn.codegear.com/article/25425
And that seems to get me on the way.
Thanks in any case for the offer to help.
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>OK, I can see that it is done via an external table and will see if I
>can figure it out.

I thought you were asking how to read and write a fixed length text
file in VB. If you have questions about using external tables in IB I
would be happy to try to help.

--
Bill Todd (TeamB)
 

Re:Export to text file

RB Smissaert writes:
Quote
What I'd like to do is create an external table, which is a text
file and then write to that external table with an INSERT with a
SELECT on regular Interbase tables.
External tables are also discussed in the Data Definition Guide. If you
want to read the external file with a text editor it is easier if you
add a CHAR(2) field as the last field in the record and insert a
carriage return/line feed in that field. This may make it easier to
read the data in VB(Visual Basic) also if VB(Visual Basic) does not have routines for reading
undelimited fixed length records.
--
Bill Todd (TeamB)
 

Re:Export to text file

Thanks, I can see this may work.
I am experimenting with this now in IB_SQL.
What I noticed is that although these tables are text files
they are kind of real tables and they appear in RDB$RELATIONS.
Although I can drop these tables and make them disappear from RDB$RELATIONS,
something is still holding on to the text file and I can not for example
delete these files.
How do I break this lock without stopping Interbase?
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>What I'd like to do is create an external table, which is a text
>file and then write to that external table with an INSERT with a
>SELECT on regular Interbase tables.

External tables are also discussed in the Data Definition Guide. If you
want to read the external file with a text editor it is easier if you
add a CHAR(2) field as the last field in the record and insert a
carriage return/line feed in that field. This may make it easier to
read the data in VB(Visual Basic) also if VB(Visual Basic) does not have routines for reading
undelimited fixed length records.

--
Bill Todd (TeamB)
 

Re:Export to text file

RB Smissaert writes:
Quote
How would you do it from whatever language you know?
Had a look in the documentation, but can not see it yet.
See the Data Definition Guide. In Delphi I'd use the text file I/O
routines AssignFile, Reset, Rewrite, Readln and Writeln if the records
end with CR/LF. If the records do not end with CR/LF I'd use the
TFileStream.Read method.
--
Bill Todd (TeamB)
 

Re:Export to text file

Quote
See the Data Definition Guide
Thanks, found this now and all looking simple enough.
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>How would you do it from whatever language you know?
>Had a look in the documentation, but can not see it yet.

See the Data Definition Guide. In Delphi I'd use the text file I/O
routines AssignFile, Reset, Rewrite, Readln and Writeln if the records
end with CR/LF. If the records do not end with CR/LF I'd use the
TFileStream.Read method.

--
Bill Todd (TeamB)
 

Re:Export to text file

RB Smissaert writes:
Quote
How do I break this lock without stopping Interbase?
What version of IB are you using? This is a known bug and I thought it
was fixed in IB2007.
--
Bill Todd (TeamB)
 

Re:Export to text file

I am on IB 5.6 here.
RBS
"Bill Todd [TeamB]" <XXXX@XXXXX.COM>writes
Quote
RB Smissaert writes:

>How do I break this lock without stopping Interbase?

What version of IB are you using? This is a known bug and I thought it
was fixed in IB2007.

--
Bill Todd (TeamB)
 

Re:Export to text file

With version 5.6 the only way to unlock the file that I know of is to
bounce the IB server service.
--
Bill Todd (TeamB)