In an earlier post I wrote about how to convert a character string to hexadecimal, and back to character again. The obvious question followed:
What if wanted to convert a number to hexadecimal with SQL?
One of the issues is that numbers come in different forms in modern RPG and in SQL. Here are the common types of numbers I encounter:
| Type | RPG | SQL |
| Packed | PACKED | DECIMAL, DEC |
| Signed | ZONED | NUMERIC, NUM |
| Integer | INT | INTEGER, INT, SMALLINT, BIGINT |
In this post I am going to give examples of how to convert each of these RPG number types to hexadecimal, and then back again.
This is my program:



