Home » RDBMS Server » Server Utilities » Query Result to a Text File
Query Result to a Text File [message #142037] Thu, 13 October 2005 05:13 Go to next message
abmohan75
Messages: 7
Registered: October 2005
Junior Member
Hello All!,

I am having Oracle 10i/Windows 2000 Server. I would like to export query result to a text file. If any one give idea that I can implement in my VB project.

I'm waiting for your valuable suggestions.

Regards,
Mohan
Re: Query Result to a Text File [message #142057 is a reply to message #142037] Thu, 13 October 2005 06:14 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
'exporting' would be a wrong term here.
In oracle,Exporting means something else.
The options are
1. You can spool the file ( which may not work from VB).
This can write your output to anywhere (clientside)
2. Use UTL_FILE builtin package.
You can read from and write to any textfile using oracle pl/sql
methods. But this is serverside only. YOu can write to a file in
the client node.
3. There should be some options in VB to do the file i/o.
Look into that.
Re: Query Result to a Text File [message #142921 is a reply to message #142057] Tue, 18 October 2005 07:31 Go to previous message
abmohan75
Messages: 7
Registered: October 2005
Junior Member
Finally I found the solution. And I would like to share here, that may useful for others too.

Dim fs As New FileSystemObject, txtf
Dim clsvar As New Class3
Dim sql As String
Dim rsc As New ADODB.Recordset

Set txtf = fs.CreateTextFile("c:\test.txt", True)
sql = "select * from test1"
If rsc.State = adStateOpen Then rsc.Close
rsc.Open sql, clsvar.conn
While Not rsc.EOF
txtf.WriteLine (rsc(0).Value & vbTab & rsc(1) & vbTab & rsc(2))
rsc.MoveNext
Wend
txtf.Close
set rsc = Nothing
MsgBox "Over"


Regards,
Mohan

[Updated on: Tue, 18 October 2005 07:32]

Report message to a moderator

Previous Topic: does oracle 8 support export to multiple files ?
Next Topic: SQL Loader - Multiple Update
Goto Forum:
  


Current Time: Thu Dec 26 05:52:26 CST 2024