我想将版本db中的数据替换为带有前缀的测试数据库(storeList数组中的每个商店)。
我收到类似"未知系统变量'存储'"
的错误但我不知道为什么会出现这种错误。
DELIMITER
CREATE PROCEDURE `replace_release_to_test_db`(baseUrl VARCHAR(255), substituteDomain VARCHAR(255), IN storeList VARCHAR(255))
BEGIN
DECLARE pos int;
SET storeList = LTRIM(RTRIM(storeList))+ ',';
SET pos = SUBSTRING_INDEX(storeList,',', 1);
WHILE pos > 0 do
SET store = LEFT(storeList, pos - 1);
IF store <> '' THEN
SET oldDomain = CONCAT(store,".",baseUrl);
SET newDomain = CONCAT(substituteDomain,"-",store,".",baseUrl);
UPDATE core_config_data SET value = REPLACE(value, oldDomain, newDomain);
END IF
SET storeList = RIGHT(storeList, LEN(storeList) - pos);
SET pos = SUBSTRING_INDEX(storeList,',', 1);
END WHILE;
UPDATE core_config_data SET value = REPLACE(value, CONCAT("http://",baseUrl), CONCAT("http://"substituteDomain,".",baseUrl));
UPDATE core_config_data SET value = REPLACE(value, CONCAT("https://",baseUrl), CONCAT("https://"substituteDomain,".",baseUrl));
SELECT * FROM core_config_data WHERE value LIKE '%abc.kr%';
END
DELIMITER;
CALL replace_release_to_test_db("abc.kr","test", "my,sg,ph,id,th,us,my-mobile,sg-mobile,ph-mobile,id-mobile,th-mobile,us-mobile")
答案 0 :(得分:1)
您有SET store = LEFT(storeList, pos - 1);
(以及IF store ...
等等),但您尚未声明名为store
的变量。