SQL iQuery Script Built-in Function


toASCII / e2a

Convert to ASCII CCSID

The TOASCII() built-in function returns the data from parameter 1 after converting it to UTF-8/ASCII (to ccsid 1208).
The E2E() (ebcdic to ascii) built-in function does the same thing.


The TOASCII() translates the data in the first parameter to CCSID 1208 using the iconv API.


  1. The name of an iQuery Session Variable or a literal value/string to be converted from the job ccsid to ASCII.
  INTO &Name, &City, &State 
from qiws.qcustcdt 
where cusnum = 192837; 
eval &a_Name = toascii(&name); 
eval &a_City = toascii(&city); 
eval &a_state = toascii(&state); 
#msg Data in Job CCSID:  &Name, &City, &State  
#msg Data in ASCII/UTF8: &a_Name, &a_City, &a_State

The output from the above script is:

Data in Job CCSID:  Lee, Hector, NY  
Data in ASCII/UTF8: <ÁÁ, çÁÄÈ?Ê, +ß

To show the values in hex:

    Data in Job CCSID:  'D38585' 'C88583A39699' 'D5E8'
    Data in ASCII/UTF8: '4C6565' '486563746F72' '816DD5E8'