Handle Hex Values in DB2 SQL

Handle Hex Values in DB2 SQL

If you have any data which is unicode or contains special characters like German Umlauts (? ? ü) or any special Character like currency signs £, €, $ then you can use the hex values in SQL to fetch/update/insert the correct data from DB2.

Often in DB2 in Z/os we have this encoding or special character issue where our Database can handle special characters due to UTF-8 and UTF-16 support but not the SQL's inline in JCL or in PDS can handle. Sometime we see the special character gets corrupt and show incorrect results. So the best way to handle such special characters is by using hex value.

Steps to generate the Hex Values

1) For this you can use the notepad++ plugin

Select the data you want to convert into hex and click on Plugins >> Converter >> ASCII to Hex

No alt text provided for this image

2) Now Select the data and click on ASCII à HEX and it will convert the data in

No alt text provided for this image

3) Now use the Hex Values in SQL embedded in single quotes and precedence with X. Like for the hex value C3BC, we have to use X'C3BC' in SQL to refer german umlat ü

INSERT INTO SCHEMA.TABLE COL1 VALUES(X'C3BC')

4) To refer the sam hex value in LIKE clause in SQL refer the following sample query.

SELECT * FROM SCHEMA.TABLE WHERE COL1 LIKE '%' || X'C3BC' ||'%'


要查看或添加评论,请登录

Abhishek Verma的更多文章

  • Mainframe Migration Trends for 2024: Embracing Modernization, Cloud Adoption, and AI

    Mainframe Migration Trends for 2024: Embracing Modernization, Cloud Adoption, and AI

    Mainframes, the workhorses of the computing industry for decades, continue to play a vital role in many organizations…

    5 条评论
  • Ansible on Mainframe

    Ansible on Mainframe

    What is Ansible? Ansible is an open source automation platform. It is very simple to setup and yet powerful.

  • What is DB2 REST Api?

    What is DB2 REST Api?

    What is REST Api? A RESTful API is an architectural style for an Application Program Interface (API) that uses HTTP…

    2 条评论
  • DevOps for Mainframe: Agile Development

    DevOps for Mainframe: Agile Development

    Can you do DevOps on your mainframe? That might seem like a silly question. DevOps is among the newest trends in IT…

    5 条评论
  • IBM Cloud Pak for Data

    IBM Cloud Pak for Data

    Overview IBM Cloud Pak ? for Data is an integrated solution for implementing a complete analytics environment. This…

    2 条评论
  • IBM DB2 for Data Gate

    IBM DB2 for Data Gate

    The IBM Db2 for z/OS Data Gate service extracts, loads, and synchronizes your mission-critical data from Db2 for z/OS…

  • UrbanCode Deploy

    UrbanCode Deploy

    Application Planning UrbanCode Deploy is used to automate the deployment of apps to different environments, typically…

  • DB2 Z/os: How to find the thread causing deadlock

    DB2 Z/os: How to find the thread causing deadlock

    When you receive a deadlock or time out time abend, go to JESMSGLG of the Db2 master job and the job name will be in…

  • IBM DB2 - Recursive SQL

    IBM DB2 - Recursive SQL

    Recursive is the process in which the query executes itself. It is used to get results based on the output of base…

    1 条评论
  • IBM DB2 V12 - Incompatibilities and Improvements over V11.

    IBM DB2 V12 - Incompatibilities and Improvements over V11.