문제

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.

도움이 되었습니까?

해결책

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;

다른 팁

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top