CREATE OR REPLACE FUNCTION gen_uuid
  RETURN VARCHAR
AS
  BEGIN

    RETURN regexp_replace(rawtohex(sys_guid())
    , '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
    , '\1-\2-\3-\4-\5');

  END;
/
