BEGIN
DECLARE zid INT DEFAULT 0;
DECLARE fid INT DEFAULT 0;
DECLARE a VARCHAR(30);
DECLARE b VARCHAR(30);
DECLARE s int default 0;
DECLARE sj int default 0;
DECLARE cursor_name CURSOR FOR select SERVICE_NAME ,SERVICE_CODE from s_service;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s=1;
start transaction;
SELECT MAX(ID) INTO fid
FROM ibmall_ecms_news_index;
SELECT FLOOR(7 + (RAND() * 6)) INTO sj;
INSERT into ibmall_ecms_news(classid,ttid,onclick,newspath,filename,userid,username,isgood,truetime,lastdotime,havehtml,titleurl,title,newstime,titlepic,ftitle,smalltext)
VALUES(cid,0,sj,CURDATE(),fid+1,'2','collector',0,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),1, CONCAT('/wmxy/',cname,'/',CURDATE(),'/',fid,'.html'),title,UNIX_TIMESTAMP(Stime),'','副标题','简介');
if row_count() < 1 then
rollback;
end if;
INSERT into ibmall_ecms_news_index (classid,checked,newstime,truetime,lastdotime,havehtml) VALUES (cid,1,UNIX_TIMESTAMP(Stime),UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),1);
if row_count() < 1 then
rollback;
end if;
SELECT MAX(ID) INTO zid
FROM ibmall_ecms_news;
OPEN cursor_name;
fetch cursor_name into a,b;
while s <> 1 do
SET newstext= REPLACE(newstext, a, CONCAT('<a class="font_color01" href=\'http://www.ibmall.cn/cat/', b, '.html\' target=\'_blank\' title=\'',a,'\'>', a,'</a>')) ;
-- and newstext not LIKE CONCAT('%',a,'</a>%') ;
#读取下一行的数据
fetch cursor_name into a,b;
end while;
#关闭游标
CLOSE cursor_name ;
INSERT into ibmall_ecms_news_data_1 (id,classid,newstempid,writer,befrom,newstext) VALUES (zid,cid,1,writer,befrom,newstext);
if row_count() < 1 then
rollback;
end if;
commit;
END
DECLARE zid INT DEFAULT 0;
DECLARE fid INT DEFAULT 0;
DECLARE a VARCHAR(30);
DECLARE b VARCHAR(30);
DECLARE s int default 0;
DECLARE sj int default 0;
DECLARE cursor_name CURSOR FOR select SERVICE_NAME ,SERVICE_CODE from s_service;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s=1;
start transaction;
SELECT MAX(ID) INTO fid
FROM ibmall_ecms_news_index;
SELECT FLOOR(7 + (RAND() * 6)) INTO sj;
INSERT into ibmall_ecms_news(classid,ttid,onclick,newspath,filename,userid,username,isgood,truetime,lastdotime,havehtml,titleurl,title,newstime,titlepic,ftitle,smalltext)
VALUES(cid,0,sj,CURDATE(),fid+1,'2','collector',0,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),1, CONCAT('/wmxy/',cname,'/',CURDATE(),'/',fid,'.html'),title,UNIX_TIMESTAMP(Stime),'','副标题','简介');
if row_count() < 1 then
rollback;
end if;
INSERT into ibmall_ecms_news_index (classid,checked,newstime,truetime,lastdotime,havehtml) VALUES (cid,1,UNIX_TIMESTAMP(Stime),UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),1);
if row_count() < 1 then
rollback;
end if;
SELECT MAX(ID) INTO zid
FROM ibmall_ecms_news;
OPEN cursor_name;
fetch cursor_name into a,b;
while s <> 1 do
SET newstext= REPLACE(newstext, a, CONCAT('<a class="font_color01" href=\'http://www.ibmall.cn/cat/', b, '.html\' target=\'_blank\' title=\'',a,'\'>', a,'</a>')) ;
-- and newstext not LIKE CONCAT('%',a,'</a>%') ;
#读取下一行的数据
fetch cursor_name into a,b;
end while;
#关闭游标
CLOSE cursor_name ;
INSERT into ibmall_ecms_news_data_1 (id,classid,newstempid,writer,befrom,newstext) VALUES (zid,cid,1,writer,befrom,newstext);
if row_count() < 1 then
rollback;
end if;
commit;
END