You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me start off by saying I've never written a stored procedure, so if you have the patience to answer this in any way, that's my starting point. (My learning curve would be so great, I'm not even going to try, but I'm reasonably good at taking some sort of an example and working it to what I want).
Background.
We have a number of DB2 tables containing binary fields, which in turn contain any number of mainframe COBOL fields. One of the "problems" I'm having is being able to convert EBCDIC character field representation to "readable" data. The actual selection that extracts each character field is along the lines of
, hex(substr(DL1_SEGMENT1,009,001)) as SORTKOD
which shows the result as "F4" (which is EBCDIC for the number 4 and where the "real" content of the field is a 4).
I've seen various suggestions for converting something like this (F4 to 4), but they were so convoluted that they're basically (in my mind) non-starters.
I thought that maybe (if I knew how to), I could write a stored procedure that would take the string passed in, and for each character, "translate" it. Maybe something along the lines of TO_EBCDIC(substr(DL1_SEGMENT1,009,001)) as SORTKOD
and let the procedure analyze how many characters are passed in and convert each one to the "correct" character.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let me start off by saying I've never written a stored procedure, so if you have the patience to answer this in any way, that's my starting point. (My learning curve would be so great, I'm not even going to try, but I'm reasonably good at taking some sort of an example and working it to what I want).
Background.
We have a number of DB2 tables containing binary fields, which in turn contain any number of mainframe COBOL fields. One of the "problems" I'm having is being able to convert EBCDIC character field representation to "readable" data. The actual selection that extracts each character field is along the lines of
, hex(substr(DL1_SEGMENT1,009,001)) as SORTKOD
which shows the result as "F4" (which is EBCDIC for the number 4 and where the "real" content of the field is a 4).
I've seen various suggestions for converting something like this (F4 to 4), but they were so convoluted that they're basically (in my mind) non-starters.
I thought that maybe (if I knew how to), I could write a stored procedure that would take the string passed in, and for each character, "translate" it. Maybe something along the lines of
TO_EBCDIC(substr(DL1_SEGMENT1,009,001)) as SORTKOD
and let the procedure analyze how many characters are passed in and convert each one to the "correct" character.
Does this sound
Grateful for any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions