Oracle Build UUID

Source: Internet
Author: User

Select Sys_guid () from dual;

-->78ae331adb2b4ce7ab598b1317b39d58


But the function has the following problem:
1 . The return type is raw
2 . No- (dash) delimiter
3 . Capitalization of letters returned

To make the resulting UUID conform to the RFC 4122 standard
Create the function as follows and test pass.

Create or Replace function Get_uuid return VARCHAR2 is
V_uuid varchar (36);
Begin
V_uuid: = Lower (Rawtohex (Sys_guid ()));
V_uuid: = substr (V_uuid, 1, 8) | | '-' | | SUBSTR (V_uuid, 9, 4) | | '-' | |
SUBSTR (V_uuid, 13, 4) | | '-' | | SUBSTR (V_uuid, 17, 4) | | '-' | |
SUBSTR (V_uuid, 21, 12);
return v_uuid;
End Get_uuid;

Select Get_uuid () from dual;
-->7bb0152a-4c5c-4078-a1b8-f57ae58254e5

Oracle Build UUID

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.