The command works, however the file seems to be in EBCDIC when I try and
open it in EXCEL on the PC. I'm presuming that a code conversion hasn't
taken place. It looks fine when I open the file in the iSeries.

Two statements sum up what's happening:

  1) When QShell writes it's output to an IFS file, it converts
     the data to whichever CCSID the file is tagged with.

  2) When QShell creates a new file, by default, it'll tag it
     with the default CCSID for the current job.

So when you run your example program, and it creates an IFS file, it
tags it with the CCSID of your job, which is almost certainly an

You can override this default by setting the QIBM_CCSID environment variable to the CCSID you want to use. For example, if you set it to
1252, it'll create any new files with CCSID 1252, which is Microsoft's
encoding for Latin-1 ASCII.

Here's an example:

   a) First delete the old file

         rm /mxp/mxpsql.csv

   b) then set the CCSID before running your command this can be done
         in one big QShell statement if you like:

export QIBM_CCSID=1252; db2 "select agtbra || ',' || char(agtnoa) || ',' || agtnaa from anvdev.agtmas" | sed -n '/,/p' > /mxp/mxpsql.csv

Or, you can run the "export QIBM_CCSID=1252" as a separate command before the SQL statement. Or you can set it with the ADDENVVAR CL command before running QShell. Whatever you prefer.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.