Frage

What is the best way to obtain the numeric value from a guid column?

I am trying this line but i am getting:

ORA-00904: "HASHBYTES": invalid identifier
00904. 00000 -  "%s: invalid identifier"

Query is below:

SELECT HASHBYTES('MD5',CAST(prod AS varchar2(30)))
FROM PRODS;

Please advice.

War es hilfreich?

Lösung

Oracle doesn't have the HASHBYTES function. You can convert hex to decimal using TO_NUMBER(hex-string, 'xx'), but you must have enough x characters in your format string to cover the input value. In the case of a GUID, that's 32 x characters:

SELECT TO_NUMBER(prod, RPAD('x', 32, 'x'))
FROM PRODS;

Andere Tipps

GUIDs don't really lend themselves to being represented as numerics. However, you can do it if you need to.

This question has been asked before in this post

This will convert MD5 hash (hex) to decimal number

SELECT CONV('MD5', 16, 10)
FROM PRODS;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top