-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `selectCount`(
IN pcsId int,
IN drId int,
IN partnerId int,
IN customerId int,
OUT pcsCount int,
OUT drCount int
)
BEGIN
select count(md.id) into @pcsC from mdm_device md
left join mdm_device_security mds on mds.device_id = md.id
where mds.device_rooted = pcsId
and md.partner_id = partnerId and md.customer_id = customerId;
set pcsCount = @pcsC;
select count(md.id) into @drC from mdm_device md
where md.managed_status = drId and DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(md.un_manage_date)
and md.partner_id = partnerId and md.customer_id = customerId;
set drCount = @drC;
@Override
public HomeVO selectHomeCount(HomeVO home) throws Exception {
HomeVO vo = new HomeVO();
vo.setPcsId(0);
vo.setDrId(0);
vo.setPartnerId(25);
vo.setCustomerId(50);
vo.setPcsCount(0);
vo.setDrCount(0);
selectOne("com.polysaas.mdm.device.mapper.MdmDeviceMapper.selectForHome2", vo);
return vo;
}
遇到异常很多。。记得的写下
1.通过javaBean的时候,#{pcsId, mode=IN, javaType=INTEGER},javaType这个属性是必须的。
2.使用javaBean传递。输出参数不需要初始值。个人喜好并建议使用javaBean,因为定义更清晰,封装性。
3.map可以用占位符问号,javaBean不可以。 会有异常 No value specified for parameter 1
4. 说不认识某个参数。。可能是没有创建存储过程,这个发生在多个库的时候
5. read Only 这个可能是事务控制只读。。我是因为存储过程有set 语句,而方法叫做selectAaaa()。