0

オブジェクトのリストを取得するために使用するmysqlストアドプロシージャを使用しています。これは可能ですか?

私はこの記事をフォローしています

質問:

  1. 結果セットを使用してselectステートメントのようにオブジェクトのリストを取得するにはどうすればよいですか?
  2. 結果セットをオブジェクトのリストにマップする方法は?

    CREATE DEFINER = root@ localhostPROCEDURE generateLCRReport(IN countryCodeParamINT、OUT countryCodeINT、OUT dialCodeINT、OUT custPrefixVARCHAR(50)、OUT vendorPrefixVARCHAR(50)、OUT custPriceFLOAT、OUT vendorCostFLOAT、OUT profitFLOAT)言語SQL DETERMINISTIC READS SQL DATA SQL SECURITY DEFINER COMMENT'generateLCRReport' BEGIN c.country_codeをcountryCode、c.dial_codeをdialCode、c.customer_prefixをcustPrefix、c.vendor_prefixをvendorPrefix、max(cust_rate.rate)をcustPrice、min(ven_rate.rate)をvendorCost、round(max(cust_rate.rate) )-min(ven_rate.rate)、3)cdrcからの利益として

    内部結合(選択a.id、r.rate、re.country_code、re.dial_code、ap.prefix from rate r inner join region re on r.region_id = re.id internal join account_prefix ap on r.account_prefix_id = ap.id内部結合アカウントaona.id = ap.account_id where ap.prefix_type = 0)as cust_rate

    c.country_code=cust_rate.country_codeおよびc.dial_code=cust_rate.dial_codeおよびc.customer_prefix=cust_rate.prefixおよびc.customer_id=cust_rate.id

    内部結合(選択a.id、r.rate、re.country_code、re.dial_code、ap.prefix from rate r inner join region re on r.region_id = re.id internal join account_prefix ap on r.account_prefix_id = ap.id内部結合アカウントaona.id = ap.account_id where ap.prefix_type = 1)as ven_rate

    on c.country_code = ven_rate.country_code and c.dial_code = ven_rate.dial_code and c.vendor_prefix = ven_rate.prefix and c.vendor_id = ven_rate.id where c.country_code = countryCodeParam group by c.country_code and c.dial_code orderbyc。 .country_code asc limit 5000;

    終わり

    パブリッククラスLCRReportSPはStoredProcedureを拡張します{

    /**
     * 
     */
    @Autowired
    public LCRReportSP(JdbcTemplate jdbcTemplate, String storedProcName, RowMapper<CostReport> mapper) {
        super(jdbcTemplate, storedProcName);
    
        SqlReturnResultSet rs = new SqlReturnResultSet("", mapper);
        SqlOutParameter outParam = new SqlOutParameter("countryCode", Types.INTEGER);
        SqlOutParameter outParam1 = new SqlOutParameter("dialCode", Types.INTEGER);
        SqlOutParameter outParam2 = new SqlOutParameter("custPrefix", Types.VARCHAR);
        SqlOutParameter outParam3 = new SqlOutParameter("vendorPrefix", Types.VARCHAR);
        SqlOutParameter outParam4 = new SqlOutParameter("custPrice", Types.FLOAT);
        SqlOutParameter outParam5 = new SqlOutParameter("vendorCost", Types.FLOAT);
        SqlOutParameter outParam6 = new SqlOutParameter("profit", Types.FLOAT);
    
        this.declareParameter(rs);
        this.declareParameter(outParam);
        this.declareParameter(outParam1);
        this.declareParameter(outParam2);
        this.declareParameter(outParam3);
        this.declareParameter(outParam4);
        this.declareParameter(outParam5);
        this.declareParameter(outParam6);
    
        this.setFunction(false);
        this.compile();
    }
    
    /**
     * @param countryCode
     * @return
     */
    public Map<String, ?> generateLCRReport(int countryCode) {
    
        Map<String, Object> inParam = new HashMap<String, Object>();
    
        inParam.put("countryCodeParam", new Integer(countryCode));
    
        return this.execute(inParam);
    }
    

    }

助けてください。

ありがとう。

4

1 に答える 1

0

私は RowMapper を使用しており、パラメータ SqlReturnResultSet を宣言しています。

于 2013-03-13T04:05:05.063 に答える