sql - function or script to reverse Byte Order oracle -



sql - function or script to reverse Byte Order oracle -

i want write script in pl/sql convert byte order of hexadecimal number in pairs

ex. a1b2c3d4 should become d4c3b2a1

could please help me function or script should use.

the utl_raw bundle has handy reverse function:

select utl_raw.reverse('a1b2c3d4') dual; utl_raw.reverse('a1b2c3d4') --------------------------- d4c3b2a1

that gives raw value, , i'm doing implicit conversion string raw in illustration don't know info type you're starting with.

you can expand convert explicitly varchar2 hextoraw function:

select utl_raw.reverse(hextoraw('a1b2c3d4')) dual; utl_raw.reverse(hextoraw('a1b2c3d4')) ------------------------------------- d4c3b2a1

and varchar2 rawtohex function:

select rawtohex(utl_raw.reverse(hextoraw('a1b2c3d4'))) dual; rawtohex(utl_raw.reverse(hextoraw('a1b2c3d4'))) ----------------------------------------------- d4c3b2a1

... depending on need back.

sql oracle

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -