簡體   English   中英

帶有 3 個 select 語句的存儲過程只返回一個表

[英]Stored Procedure with 3 select statements only returns a single table

當我在 mysql 中使用 3 個選擇查詢調用存儲過程時,它返回 3 個表,但是當我在 spring 中調用它時,它只返回一個表結果。 下面是在 Spring 中調用存儲過程的代碼。

@ResponseBody
    @RequestMapping(value="/", method=RequestMethod.GET, produces="application/json", headers="Accept=application/json")
    public String listProducts() throws ParseException {
        int id=1;
        int days=20;
        Query query = session.createNativeQuery("{call getWalkInInfo(?,?)}", Product.class);
        query.setParameter(1,id);
        query.setParameter(2,days);
        Gson gson=new Gson();
        String jsonArray=gson.toJson(query.getResultList());
        System.out.println(jsonArray);
        return jsonArray;
    }

您需要在存儲過程中創建 3 個 OUTPUT

例如 MSSQL 服務器:

ALTER PROCEDURE [dbo].[Procedure_name]
(
@Id_user int,
@select_one int output,
@select_two decimal(10,2) output,
@select_three decimal(10,2) output 
)
AS

BEGIN

set @select_one = (select * from table1);
set @select_two = (select * from table2);
set @select_three = (select * from table3);

END

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM