Created
August 1, 2012 20:55
-
-
Save esasse/3230632 to your computer and use it in GitHub Desktop.
Stored procedure to generate UUID32 in Firebird 2.5+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR ALTER PROCEDURE GEN_UUID32 RETURNS (RESULT CHAR(32)) | |
AS | |
DECLARE VARIABLE UUID36 CHAR(36); | |
BEGIN | |
SELECT | |
UUID_TO_CHAR(GEN_UUID()) | |
FROM RDB$DATABASE | |
INTO :UUID36; | |
SELECT | |
SUBSTRING(:UUID36 FROM 1 FOR 8) || | |
SUBSTRING(:UUID36 FROM 10 FOR 4) || | |
SUBSTRING(:UUID36 FROM 15 FOR 4) || | |
SUBSTRING(:UUID36 FROM 20 FOR 4) || | |
SUBSTRING(:UUID36 FROM 25) | |
FROM RDB$DATABASE | |
INTO :RESULT; | |
SUSPEND; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment