Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    9

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  3. #3
    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

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

  5. #5
    Join Date
    Apr 2004
    Posts
    9

    CLP redirect output to Delimited File

    Thanks
    This should work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •