Oracle数据库产生Guid的函数
CREATE OR REPLACE FUNCTION GET_GUID
RETURN CHARIS
v_guid CHAR (38);
v_guid_part_one CHAR (8);
v_guid_part_two CHAR (4);
v_guid_part_three CHAR (4);
v_guid_part_four CHAR (4);
v_guid_part_five CHAR (12);
BEGIN
SELECT SYS_GUID ()
INTO v_guid
FROM DUAL;
v_guid_part_one := SUBSTR (v_guid, 0, 8);
v_guid_part_two := SUBSTR (v_guid, 8, 4);
v_guid_part_three := SUBSTR (v_guid, 12, 4);
v_guid_part_four := SUBSTR (v_guid, 16, 4);
v_guid_part_five := SUBSTR (v_guid, 20, 12);
v_guid :=
CONCAT
(CONCAT
('{',CONCAT
(CONCAT
(CONCAT
(CONCAT (CONCAT (CONCAT (CONCAT (CONCAT (v_guid_part_one,
'-'),
v_guid_part_two
),
'-'
),
v_guid_part_three
),
'-'
),
v_guid_part_four
),
'-'
),
v_guid_part_five
)
),
'}'
);
RETURN (v_guid);
END GET_GUID;