-- 存儲過程作用去除以.cn結尾的url後面的參數
create PROCEDURE g_sp()
begin
declare done int default FALSE;
declare tid int;
declare gurl varchar(255);
-- 聲明遊標
declare cur cursor for select id,url from t_crawler_config;
-- 指定遊標循環結束時的返回值
declare continue handler for not found set done = TRUE;
-- 打開遊標
open cur;
-- while 循環
while done != 1 do
fetch cur into tid,gurl;
if done != 1 and LOCATE('.cn/',gurl)!=0 then
set gurl=substring(gurl,1,LOCATE('.cn/',gurl)+3);
update t_crawler_config set url=gurl where id=tid;
end if;
end while;
-- 關閉遊標
close cur;
end
--調用存儲過程語句
call g_sp();