mysql存储过程传字符串参数的示例:
存储过程:
create procedure Pro_GetUserInfo(in szEmpName varchar(1000))-> begin
-> declare strSql varchar(1000);
-> set strSql = concat('insert into TmpTable_UserInfo(EmpName,PcName,IP) select EmpName,PcName,IP from T_SC_UserManager where EmpName in (', szEmpName, ')');
-> drop table if exists TmpTable_UserInfo;
-> create temporary table TmpTable_UserInfo(EmpName varchar(32) not null, PcName varchar(32) not null, IP varchar(32) not null);
-> set @sql1 = strSql;
-> prepare stmt_p from @sql1;
-> execute stmt_p;
-> end
->
调用:
call Pro_GetUserInfo("'192.168.0.1','192.168.0.11'"); // 参数用双引号,其实用单引号也行。