DECLARE done INT DEFAULT 0;
DECLARE fkey INT;
DECLARE fname VARCHAR(255);
DECLARE fpath VARCHAR(255);
DECLARE cur1 CURSOR FOR SELECT FileKey, FileName, FilePath FROM FileTable;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur1;
REPEAT
FETCH cur1 INTO fkey, fname, fpath;
IF NOT done THEN
INSERT INTO FileTable (FileBinary) VALUES (LOAD_FILE(CONCAT(fpath, ' ', fname))) WHERE FileKey=fkey;
END IF;
UNTIL done END REPEAT;
CLOSE cur1;
|