prepare 准备
using 使用
deallocate 释放
execute 执行
delimiter $ drop procedure if exists proc $ create procedure proc() begin declare p1 int; set p1 = 11; set @p1 = p1; prepare prod from 'select * from log where nid > ?'; execute prod using @p1; deallocate prepare prod; end $ delimiter ; call proc();
delimiter $ drop procedure if exists proc $ create procedure proc(in strsql varchar(128),in p1 int) begin set @strsql = strsql; set @p1 = p1; prepare prod from @strsql; execute prod using @p1; deallocate prepare prod; end $ delimiter ; call proc('select * from log where nid > ?',103);