If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > CLP redirect output to Delimited File

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-23-05, 12:06
inf_developer inf_developer is offline
Registered User
 
Join Date: Apr 2004
Posts: 9
CLP redirect output to Delimited File

Hello,

I am trying to solve a problem to redirect output from a sql command to a delimited file

I am doing

db2 connect to $database user $username using $password
db2 select * from x > file.out
db2 terminate

I am struggling to get an option that allows me to write to a delimited file(file.out). The default is it is writing in a fixed width flat file

Could any of you please help me in this

any help is greatly appreciated

Thanks
Reply With Quote
  #2 (permalink)  
Old 02-23-05, 12:10
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Try the export command. See the Command Reference for the correct options to get a delimited output file.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 02-23-05, 12:33
inf_developer inf_developer is offline
Registered User
 
Join Date: Apr 2004
Posts: 9
CLP redirect output to Delimited File

Thanks for the repply
I could use the export , but the export has to have different set of privilages which I dont have.
the other thing is export is creating a file on the DB Server , which I dont have privilage to

so I am forced to create this wey

Thanks for the repply
Reply With Quote
  #4 (permalink)  
Old 02-23-05, 15:13
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Try:
Code:
db2 -x -r file.out "select field1 || ',' || field2 || ',' ... from x"
You may need to convert numeric and date/time fields to their character representations for the concatenation to work.
Reply With Quote
  #5 (permalink)  
Old 02-24-05, 10:35
inf_developer inf_developer is offline
Registered User
 
Join Date: Apr 2004
Posts: 9
CLP redirect output to Delimited File

Thanks
This should work
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On