首页 > 代码库 > 查询表中有多少行记录

查询表中有多少行记录

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

import com.yd.common.data.CIPPageInfo;
import com.yd.common.data.CIPReqCondition;
import com.yd.common.exception.CIPDaoException;
import com.yd.common.runtime.CIPErrorCode;
import com.yd.iwmsc.data.IWMSC_Order_in_finish_headerData;
import com.yd.iwmsc.data.IWMSC_Order_in_finish_itemData;
import com.yd.wmsc.busi.dao.impl.WMSC_busi_inboundDaoImpl;
import com.yd.wmsc.busi.pojo.data.WMSC_busi_inboundData;
import com.yd.wmsc.busi.pojo.po.WMSC_busi_inboundPO;
import com.yd.wmsc.util.YDAssert;

    @Autowired 
    NamedParameterJdbcTemplate jdbcTemplate;

    public int queryDocNum(String ex_wh_code, String ref_doc_id,String owned_cust_id){
        Integer num =null;
        String sql = "select count(1) from wmsc_busi_inbound where ex_wh_code = :ex_wh_code and ref_doc_id = :ref_doc_id  and owned_cust_id = :owned_cust_id";
        Map<String, String> params = new HashMap<String, String>();
        params.put("ex_wh_code", ex_wh_code);
        params.put("ref_doc_id", ref_doc_id);
        params.put("owned_cust_id", owned_cust_id);
        try {
            num = jdbcTemplate.queryForObject(sql, params,Integer.class);
        } catch (Exception e) {
            log.error(e);
            throw new CIPDaoException(CIPErrorCode.ERROR_DATABASE_TECH_EXCEPTION);
        }
        return num == null? 0:num;
    }

 

查询表中有多少行记录