Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    2

    Unanswered: Delimiter in Unload To function

    Hi,

    Anyone know how to get rid of the last delimiter in the output file when we use the UNLOAD TO statement?

    i.e. The statement is UNLOAD TO 'output' DELIMITER '|'
    SELECT shoes, bottoms, tops FROM closet

    The results will be: running shoes|jeans|tutleneck| <- don't want this
    high heals|skirt|shirt|

    Please help, thanks alot!!!

  2. #2
    Join Date
    Jan 2004
    Location
    Somerset
    Posts
    5

    Re: Delimiter in Unload To function

    Originally posted by bettyng
    Hi,

    Anyone know how to get rid of the last delimiter in the output file when we use the UNLOAD TO statement?

    i.e. The statement is UNLOAD TO 'output' DELIMITER '|'
    SELECT shoes, bottoms, tops FROM closet

    The results will be: running shoes|jeans|tutleneck| <- don't want this
    high heals|skirt|shirt|

    Please help, thanks alot!!!
    try

    unload to 'output' delimiter ""
    select shoes,"|",bottoms,"|",tops from closet

    its a bit manual ..but it may work for you.

  3. #3
    Join Date
    Aug 2012
    Posts
    1
    Hello, maybe this is gonna avoid someone to lose some time..

    don't try the last option, using delimiter "", will use the default delimiter wich is |.

    I'm still looking for a solution.

    thanks

  4. #4
    Join Date
    Jun 2009
    Location
    Lisboa, Portugal
    Posts
    78
    Hi Bettyng,

    Which Operating System is IDS installed?
    Last edited by Luis Santos; 08-17-12 at 13:41.
    LS

  5. #5
    Join Date
    Jun 2009
    Location
    Lisboa, Portugal
    Posts
    78
    Hi again,

    As you didn't responded yet, i advance with... if you are using Linux or Unix, try this:

    Code:
    cat unl_file_no_last_pipe.sh
    #!/usr/sh
    
    $INFORMIXDIR/bin/dbaccess - <<EOF
    DATABASE name_of_database;
    UNLOAD TO 'file1.out' DELIMITER '|'
        SELECT shoes, bottoms, tops FROM closet;
    EOF
    
    sed -e 's/|$//' <file1.out >file2.out
    You will obtain on file2.out the result of the unload without the last pipe.

    Hope it works
    Last edited by Luis Santos; 08-20-12 at 13:25.
    LS

Posting Permissions

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