繁体   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