首页 > 编程代码 >数据库 > mysql创建存储过程示例 2017年12月31日

mysql创建存储过程示例

应用于火车头采集器入库到数据库,折腾了好几天才成功。

drop procedure mytest;

CREATE PROCEDURE mytest ( IN cid INT (20), IN title VARCHAR (1000), IN tag VARCHAR (1000), IN keywords VARCHAR (1000), IN content VARCHAR (5000), IN picurl VARCHAR (5000), IN cover VARCHAR (5000), IN remark VARCHAR (5000), IN picsize INT (20), IN addtime INT (50))
BEGIN
SET @cover_url = left(cover, 29);
INSERT INTO tutu_article VALUES ( NULL, cid, title, tag, ”, @cover_url, ‘YiZhengFeng’, ”, remark, ”, keywords, remark, 0, 5, 1, 0, 0, addtime);
SET @id =@@IDENTITY;
SET @l_sql = concat( concat( “INSERT INTO tutu_attach VALUES (null,” ,@id, “,1,'”, title, “‘,'”, remark, “‘,”, picsize, “,'”, REPLACE ( picurl, ‘,’, concat( “‘,’jpg’,1,0,0,”, addtime, “),(null,” ,@id, “,1,'”, title, “‘,'”, remark, “‘,”, picsize, “,'” ))), “‘,’jpg’,1,0,0,”, addtime, “)” );
SET @sql=@l_sql;
PREPARE s1 FROM @sql;
EXECUTE s1;
DEALLOCATE PREPARE s1;
END;

call mytest(1,”bt”,”tag”,”key”,”con”,”picurl,111,11″,”cover”,”remark_con”,0,1492681251);


添加新评论

© 2017 听风扯淡 . 由 WordPress 强力驱动 | Theme By Jimmy & PCDotFan