all repos — moviedb @ 5e82b1b6e63b51d448914dbe5872b5d255b1b594

A Flask web-app to browse movie information from IMDb using imdbpy

mysql/procedure_triggers/split.sql

DELIMITER $$
DROP PROCEDURE IF EXISTS split_string $$
CREATE TABLE if not exists tmp_store (
    id int NOT NULL AUTO_INCREMENT,
    allValues varchar(100) Default NULL,
    PRIMARY KEY(id)
) $$

CREATE PROCEDURE split_string(Value longtext)
BEGIN
DECLARE front TEXT DEFAULT NULL;
DECLARE frontlen INT DEFAULT NULL;
DECLARE TempValue TEXT DEFAULT NULL;
iterator:
LOOP  
IF LENGTH(TRIM(Value)) = 0 OR Value IS NULL THEN
LEAVE iterator;
END IF;
SET front = SUBSTRING_INDEX(Value,',',1);
SET frontlen = LENGTH(front);
SET TempValue = TRIM(front);
INSERT INTO tmp_store (allValues) VALUES (TempValue);
SET Value = INSERT(Value,1,frontlen + 1,'');
END LOOP;
END $$
DELIMITER ;