DB 2 CCSID

(click to open)

Quick Page Table of Contents

Scanning…

PHP DB2 CCSID

[goto main page]

[goto document links]

[goto XMLSERVICE links]

CCSID summary on IBM i

When running PHP to DB2 on IBM i (ibm_db2, pdo_ibm, odbc), you need to be aware of CCSID conversions. The story is simple, PHP runs ASCII and most DB2 tables or stored procedure calls are EBCDIC (few actual UTF-x IBM i databases in production), therefore there will be some sort of conversion between the environments.

So at a glance:

  • ASCII/EBCDIC conversion is a two way street, SO job default setting of 65535 *HEX (IBM i manufacturing), will simply not work
    • CHGSYSVAL SYSVAL(QCCSID) VALUE(37) change entire machine
      • —or —
    • CHGUSRPRF USRPRF(ME) CCSID(37) change your active user profile
      • —or—
    • change you CCSID in httpd.conf (DefaultFsCCSID 37 , CGIJobCCSID 37)
  • Use default PASE CCSID 819, if you do not have Unicode considerations (Latin countries)
    • conversions to/from job CCSID / PASE CCSID 819 are slightly faster over 1208
    • Notes:
      • PASE driver libdb400.a will do implicit conversions for operations like SQLExecDirect (db2_exec), which will affect data literals in your sql statement.
      • PASE driver libdb400.a will pass parameter marker data (?,?,?), directly to DB2 without implicit conversion when using prepare/execute (another reason to use db2_prepare/db2_execute)
  • Use PASE CCSID setting 1208, if you have Unicode considerations (DBCS, parts Europe, etc.)
    • specify the setting in fastcgi.conf (SetEnv=“LANG=C”, SetEnv=“CCSID=1208″)
    • Notes:
      • Under 1208 setting (UTF-8), PASE driver libdb400.a simply passes statement, data, literals, etc. directly to IBM DB2, NO implicit conversions in libdb400.a db2_exec, db2_prepare, db2_execute)