SSM调用数据库存储过程


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 id="updateBookNumber" parameterType="java.util.HashMap" statementType="CALLABLE" resultType="Integer">           
    {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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM