ServiceImpl中:
Map<String,Object> map=new HashMap<String,Object>(); map.put("bid", bc.getBookId()); map.put("num", bc.getNumber()); pcm.updateBookNumber(map);
Mapper.xml中
<select >
{call updateWords(
#{bid,mode=IN,jdbcType=INTEGER},
#{num,mode=IN,jdbcType=INTEGER},
#{numbers,mode=OUT,jdbcType=INTEGER}
)}
</select>
Mapper.java中
public Integer updateBookNumber(Map<String,Object> map) throws Exception;
数据库中
BEGIN #Routine body goes here... DECLARE tempnumber long; SELECT number INTO tempnumber FROM 表名 WHERE `bookId`=bid; set tempnumber=tempnumber+num; UPDATE 表名 SET number=tempnumber WHERE bookId=bid; END