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'"); // 參數用雙引號,其實用單引號也行。