SHARE
TWEET

Untitled

a guest Sep 16th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DELIMITER |
  2.  
  3. CREATE FUNCTION bin_to_uuid(b BINARY(16))
  4. RETURNS CHAR(36) DETERMINISTIC
  5. BEGIN
  6.   DECLARE hex CHAR(32);
  7.   SET hex = HEX(b);
  8.   RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12));
  9. END
  10. |
  11.  
  12. CREATE FUNCTION uuid_to_bin(s CHAR(36))
  13. RETURNS BINARY(16) DETERMINISTIC
  14. RETURN UNHEX(CONCAT(LEFT(s, 8), MID(s, 10, 4), MID(s, 15, 4), MID(s, 20, 4), RIGHT(s, 12)))
  15. |
  16.  
  17. DELIMITER ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top