Thanks for the question, Anup kumar.
Asked: December 01, 2016 - 11:54 am UTC
Last updated: December 01, 2016 - 4:27 pm UTC
Version: 4.1
Viewed 1000+ times
You Asked
Hi Experts,
I have major experience in SQL Server and I am quite new to Oracle and trying to implement something . I need a help from you guys.
I have converted a varchar value into a GUID which looks like this 7171D6557B34C0BF47F166092EE93E0683ABD180 , the original value was 'Anup'.
Now I want to convert this GUID into a random or deterministic string of same size as the original one. For example since 'Anup' was 4 characters , the value generated from that logic using the input GUID i.e. '7171D6557B34C0BF47F166092EE93E0683ABD180' should be of 4 characters , lets say 'xzyc' .
I was looking into some functions like REGEX_REPLACE , REGEX_SUBSTR but was not able to do that . Can someone please help with this.
Any help would be very much appreciated . Thanks.
and Chris said...
I don't understand what you mean "converted Anup to a GUID". GUIDs are unique generated. You don't create them "from" something.
Anyway, if you want to return a string the same length as the original, just substring passing the length of the string as the second parameter:
select substr('7171D6557B34C0BF47F166092EE93E0683ABD180', 1, length('Anup'))
from dual;
SUBSTR('7171D6557B34C0BF47F166092EE93E0683ABD180',1,LENGTH('ANUP'))
7171
Is this answer out of date? If it is, please let us know via a Comment