Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

TO_BYTES adding leading zero byte - response (3) by markhuggins

$
0
0

Hi,
 
If your data is of a fixed size you can use SUBBITSTR(bytes,0,length_in_bits) to select the correct number of bytes from the LSB end and removed the extra byte that teradata adds to the MSB end.
 
so,

-- Teradata adds a null byte when the Most Significant Bit is 1
-- This makes no sense
-- SUBBITSTR will select the 20bytes from the LSB end to work around this
SUBBITSTR(
    -- Convert to BYTES as this will take half the storage vs. storing HEX in VARCHAR
    TO_BYTES(
        --TO_BYTES expects UNICODE string hash_sha1 provides LATIN
        TRANSLATE(hexstring_20_bytes_long USING LATIN_TO_UNICODE),
        'base16'
    )
    ,0,160
)

 

Regards,
Mark


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>