dbTalk Databases Forums  

Output to text file

comp.database.oracle comp.database.oracle


Discuss Output to text file in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sean
 
Posts: n/a

Default Output to text file - 07-10-2004 , 12:44 AM






I would like a general-purpose PL/SQL proc for outputting the contents of a
table or view to a text file, with the field values separated by a
delimiter.

Currently I have a proc for each table that I export, in which I use a
cursor to select the records, construct each line by concatenating the
fields with the delimiter in between, and output to the file with
UTL_FILE.PUT_LINE. Is there a way to generalize this to work for any table?
The thought would be to pass in the table name as a parameter, along with
the file path and file name of the destination file.

Any suggestions would be greatly appreciated!



Reply With Quote
  #2  
Old   
Michael J. Moore
 
Posts: n/a

Default Re: Output to text file - 07-11-2004 , 10:54 PM






Query the dictionary to get the names and datatypes of the columns of the
target table. You probably only want to PUT_LINE on simple datatypes and
not LOBS, so you might want to skip over datatypes that you don't want to
deal with. Using this information, build your SELECT statement and then
execute it with NDS (Native Dynamic SQL).

Mike


"Sean" <sgeraghty (AT) yahoo (DOT) com> wrote

Quote:
I would like a general-purpose PL/SQL proc for outputting the contents of
a
table or view to a text file, with the field values separated by a
delimiter.

Currently I have a proc for each table that I export, in which I use a
cursor to select the records, construct each line by concatenating the
fields with the delimiter in between, and output to the file with
UTL_FILE.PUT_LINE. Is there a way to generalize this to work for any
table?
The thought would be to pass in the table name as a parameter, along with
the file path and file name of the destination file.

Any suggestions would be greatly appreciated!





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.