太阳集团所有网址16877mysql在存储过程中执行拼接

如下代码演示如何在存储过程中执行sql语句:

DROP PROCEDURE IF EXISTS sp_name;
create procedure sp_name()
begin
    declare _userid,_id,no_rs int;
    declare sitelist  CURSOR  for select userid,id from eop_site ;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_rs=1; 
    open sitelist;
    repeat
        fetch sitelist  into _userid,_id;
        set @updatesql  =CONCAT('update  es_menu_', _userid, '_',_id ,' set title ='易族易站' where title='访问易邦' ' );
        PREPARE sqltext from @updatesql;
        execute  sqltext;
        UNTIL no_rs 
    end repeat ;

    CLOSE sitelist;
    SET no_rs=0;
end

本文由太阳集团所有网址16877发布于太阳集团城网址送彩金,转载请注明出处:太阳集团所有网址16877mysql在存储过程中执行拼接

您可能还会对下面的文章感兴趣: