Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

DB2-L - HEXTORAW in DB2 z/OS simulieren

Subject:

HEXTORAW on z/OS

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

DB2 List <db2-l@lists.idug.org>

Date:

2014.09.05 22:21:00


of course, you can always write a program that does this transformation ...


Am 05.09.2014 22:19, schrieb Bernd Oppolzer:
> another suggestion:
>
> please describe with more details the problem that you are trying to solve;
> maybe there is a solution using temp tables or other internediate stages,
> which we can find, if we know the overall conditions and circumstances?
>
> I can imagine a solution where there are two varchars and by a sequence
> of repeated updates you read two characters from the "expanded" hex representation,
> delete them there and append one character to the "compact" hex representation, one by one.
> But I don't know if this will help you in your context.
>
> Kind regards
>
> Bernd
>
>
>
> Am 05.09.2014 22:09, schrieb Bernd Oppolzer:
>> if the length of the column argument that you want to translate is not too long,
>> you could maybe find a solution using the builtin function EBCDIC_CHR.
>>
>> for example:
>>
>> if your column is only 4 bytes long and contains 4 hex digits and should be
>> translated to 2 chars, you could write an expression like this:
>>
>> EBCDIC_CHR (first_exp) CONCAT EBCDIC_CHR (second_exp)
>>
>> and the first_exp and second_exp have to be a little complicated
>> expressions that yield the numeric values from 0 to 255 from the chars one / two
>> and three / four of your source column, respectively.
>>
>> functions that come to mind are:
>>
>> ASCII - giving the ascii numeric value of a char
>> TRANSLATE - to translate the chars 0 .. 9 and A .. F to another
>> sequence of chars
>>
>> etc. etc.
>>
>> the solution will be ugly, but I think it should work.
>>
>> Kind regards
>>
>> Bernd
>>
>>
>>
>>
>> Am 05.09.2014 16:09, schrieb J.H.:
>>>
>>> DB2 on LUW has a function called HEXTORAW
>>> <http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0059480.html?cp=SSEPGG_10.5.0%2F2-12-4-1-63>,
>>> a synonym for VARCHAR_BIT_FORMAT
>>> <http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0024845.html?cp=SSEPGG_10.5.0%2F2-12-4-1-187>.
>>> There appears to be no analogous function for DB2 on z/OS.
>>>
>>> The function essentially takes a character string, and casts it
>>> directly into a hex, or raw format without converting the character
>>> encodings. such that: HEXTORAW('12AB') = x'12AB'
>>>
>>> Is there anything that can be done in DB2 for z/OS to accomplish the
>>> same thing?
>>>
>>> I've hit a wall, and it appears that every available function
>>> atempts to convert the numbers and letters to the HEX for the
>>> character encoding. This is the closest I've gotten: CAST('12AB' as
>>> VARCHAR FOR BIT DATA) = x'F1F2C1C2'
>>>
>>> I need to apply this function to a column value, so I can't just
>>> type in the literal x'12AB'.
>>>
>>>
>>> -----End Original Message-----
>>
>
>
> -----End Original Message-----

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie