Copy Code code as follows:
Call Procedure_split (' share, code, fragment ', ', ', ');
SELECT * from SplitTable;
Copy Code code as follows:
Drop PROCEDURE if exists procedure_split;
CREATE PROCEDURE ' Procedure_split ' (
InputString varchar (1000),
Delim char (1)
)
Begin
DECLARE strlen int DEFAULT length (inputstring);
DECLARE last_index int DEFAULT 0;
DECLARE cur_index int DEFAULT 1;
DECLARE Cur_char VARCHAR (200);
declare len int;
Drop temporary table if exists splittable;
Create temporary table splittable (
Value VARCHAR (20)
) ;
while (Cur_index<=strlen) do
Begin
If substring (inputstring from Cur_index for 1) =delim or Cur_index=strlen Then
Set len=cur_index-last_index-1;
If Cur_index=strlen Then
Set len=len+1;
End If;
Insert into splittable (' value ') VALUES (substring (inputstring from (last_index+1) for Len);
Set Last_index=cur_index;
End If;
Set cur_index=cur_index+1;
End;
End while;
End;