Interessant, aber PL/Perl gefällt mir besser :)
Ich habe mal versucht die Funktion nachzubauen. Ist aber ungetestet. Ich habe hier kein MySQL laufen:
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
44
45
46
47
48
49
CREATE PROCEDURE "split_string"(
IN string_in VARCHAR(255)
)
BEGIN
DECLARE id INT DEFAULT 0;
DECLARE lang VARCHAR(255);
DECLARE url VARCHAR(255);
DECLARE bez VARCHAR(255);
DECLARE start INT DEFAULT 0;
DECLARE end INT DEFAULT 0;
SET end = LOCATE(",",string_in,start);
SET id = TRIM(LEFT(string_in,end-1));
SET start=end;
the_loop: LOOP
SET end = LOCATE(",",string_in,start);
IF end > 0 THEN
SET url = TRIM(SUBSTRING(string_in,$start,end-start-1));
SET start = end;
SET end = LOCATE(",",string_in,start);
IF end > 0 THEN
SET bez = TRIM(SUBSTRING(string_in,$start,end-start-1));
SET start = end;
END IF
IF LENGTH(url) > 0 AND LENGTH(bez) > 0 THEN
SET lang = LEFT(string_in,LOCATE("_",url,0)-1);
/*
INSERT ... (id,lang,url,bez)...
*/
END IF
SET bez = "";
SET url = "";
SET lang = "";
END IF
if end = 0 OR start = 0 THEN
LEAVE the_loop;
END IF
END LOOP the_loop;
END