How do you convert SYS_GUID() to varchar? How do you convert SYS_GUID() to varchar? oracle oracle

How do you convert SYS_GUID() to varchar?


Don't forget to use HEXTORAW(varchar2) when comparing this value to the RAW columns.

There is no implicit convesion from VARCHAR2 to RAW. That means that this clause:

WHERE raw_column = :varchar_value

will be impicitly converted into:

WHERE RAWTOHEX(raw_column) = :varchar_value

, thus making indices on raw_column unusable.

Use:

WHERE raw_column = HEXTORAW(:varchar_value)

instead.


Use RAWTOHEX(USER_GUID).


select RAWTOHEX(USER_GUID) from user where email = 'user@example.com'