1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
|
/* Use MULTI-QUERY-Option in myway SQL manager */
DROP FUNCTION IF EXISTS IS_UUID;
CREATE FUNCTION IS_UUID(id varchar(128))
RETURNS integer
BEGIN
if id is null then
return null;
else
if char_length(id)=38 then
if substr(id, 1, 1)='{' and substr(id, 38, 1)='}' then
set id=substr(id, 2, 36);
end if;
end if;
if char_length(id)=36 then
if substr(id, 9, 1)='-' and substr(id, 14, 1)='-' and
substr(id, 19, 1)='-' and substr(id, 24, 1)='-' then
set id=replace(id,'-','');
end if;
end if;
if char_length(id)=32 then
if unhex(id) is null then return 0; else return 1; end if;
else
return 0;
end if;
end if;
END;
SELECT IS_UUID('{decb92d4-d5bd-11ed-9a48-0800275588ea}');
SELECT IS_UUID('decb92d4-d5bd-11ed-9a48-0800275588ea');
SELECT IS_UUID('decb92d4d5bd11ed9a480800275588ea');
SELECT IS_UUID('XXXXXXXX-d5bd-11ed-9a48-0800275588ea');
SELECT IS_UUID('decb92d4d5bd-11ed-9a48-0800275588ea');
SELECT IS_UUID('');
SELECT IS_UUID(null);
|