1、mysql创建存储过程
#结束符号默认;, delimiter $$语句表示结束符号变更为$$
delimiter $$
CREATE PROCEDURE `demo`(IN idno VARCHAR(100), out str VARCHAR(4000))
BEGIN
SET str = '';
set str = concat(str, "SELECT count(DISTINCT `person_adolescent_info`.`adolescent_IDNo`) AS `count`,'重点青少年' AS `name`,'adolescent' AS `typeCode` FROM `person_adolescent_info`");
if (idno != '') then
set str = concat(str, " where adolescent_community like concat('", idno, "','%')");
end if;
END$$
#结束符号修改
delimiter ;
2、mybatis调用
(1)注解方式
@Select("call demo('${orgCode}', #{keypersoninfov, mode=OUT, jdbcType=VARCHAR})")
@Options(statementType = StatementType.CALLABLE)
String getKeypersoninfo(Map map);
(2)xml方式
call demo('${orgCode}', #{keypersoninfov, mode=OUT, jdbcType=VARCHAR})