I'm using SQL to view journal entries on my AS400. All is great except that the data in the field ENTRY_DATA is returned as
800400000000020F000000130000000000000000000000010000000700000046F0F0F0F0F0F0F00000000E0040000000000000000000000000B0F89A7EAC380E9D
HOW do I convert this into a useful string of data?? I have been trying casting and creating functions and about 50 other things... Any little clue would be appreciated.
These among lots of others
SELECT
cast(ENTRY_DATA as varchar(2000) ccsid EBCDIC for sbcs data)
FROM TABLE (
QSYS2.DISPLAY_JOURNAL( 'WVJRNLIB', 'WVPRDAJRN')
) AS JT
WHERE journal_entry_type in ('DL', 'PT', 'PX', 'UP')
and OBJECT LIKE Char('%ITEMMAST%' );
select
( CAST(ENTRY_DATA as VARCHAR(32000) FOR BIT DATA)) As New_Column
FROM TABLE (
QSYS2.DISPLAY_JOURNAL( 'WVJRNLIB', 'WVPRDAJRN')
) AS JT
WHERE journal_entry_type in ('DL', 'PT', 'PX', 'UP')
and OBJECT LIKE Char('%ITEMMAST%' ) ;
You are looking for the INTERPRET function; which was added to the OS in v7.3 TR 18. When used with the
SUBSTRINGfunction you have a way to say "take this many bytes and treat it as an integer, character, packed decimal, or zoned decimal."A good example of usage can be found in IBM's support doc How to extract and search for ENTRY_DATA in DISPLAY_JOURNAL table function
-----Note-----
If you table as nullable columns, the task gets a little more complex. Basically you have to check the
NULL_VALUE_INDICATORScolumn before using the value. Something like so for each nullable field (this assume the first 4 are nullable):If your journal is configured for "minimized entry specific data" the task is very complex. You'd need to dynamically process each journal entry.