DELIMITER // CREATE PROCEDURE count_student_by_score(IN score VARCHAR(20),IN cid VARCHAR(20) ,OUT number VARCHAR(20)) BEGIN SELECT COUNT(*) INTO number FROM score WHERE s_score > score AND c_id = cid; END // DELIMITER // CREATE PROCEDURE `count_teacher_by_name`(IN in_name VARCHAR(20),OUT out_count INT) BEGIN SELECT COUNT(*) INTO out_count FROM teacher WHERE teacher.`t_name` = in_name; END//
<parameterMap id="stuMap" type="java.util.Map"> <parameter property="score" mode="IN" jdbcType="VARCHAR"/> <parameter property="cid" mode="IN" jdbcType="VARCHAR"/> <parameter property="number" mode="OUT" jdbcType="VARCHAR"/> </parameterMap> <select id="countStudentByScore" statementType="CALLABLE" parameterMap="stuMap"> call count_student_by_score(?,?,?) </select>
mapper.java
@Mapper public interface ScoreMapper { void countStudentByScore(Map map); }
<select id="countTeacherByName" statementType="CALLABLE"> { call count_teacher_by_name(#{in_name ,mode=IN ,jdbcType=VARCHAR}, #{out_count ,mode=OUT ,jdbcType=VARCHAR}) } </select>
mapper.java
@org.apache.ibatis.annotations.Mapper public interface TeacherMapper extends Mapper<Teacher> { void countTeacherByName(TeacherVo teacherVo); }