Skip to Content
0
Former Member
Nov 16, 2014 at 03:26 PM

HEX String to INTEGER conversion

1455 Views

Hi,

I would like to convert a hex string representation to the corresponding INTEGER value.

I've tried:

select cast(hextobin('A') as int) from dummy;

which yields:

Could not execute 'select cast(hextobin('A') as int) from dummy' in 34 ms 902 µs .

SAP DBTech JDBC: [339]: invalid number: '0A' at function to_int()

I know that the next statement works, but 0xA is already binary and I guess implicite typeconversion just parses the token to integer without typecasting.

select cast(0xA as int) from dummy;

Any ideas?

Many thanks in advance,

Bodo

PS: The background is that I'm searching a way to hash a string value with hash_sha256 to number format (like ORA_HASH in oracle db). I've not found a way to typecast varbinary to number. Instead I try to convert to hex representation first and then convert to integer.