1.准备存储过程
create or replace procedure P_Test(vc_num1 in varchar2, vc_num2 in varchar2, vc_sql out varchar2) is begin //具体操作 end P_Test;
2.在dao文件配置
@Select("{call P_Test(#{map.num1,jdbcType=VARCHAR,mode=IN}," + "#{map.num2,jdbcType=VARCHAR,mode=IN}," + "#{map.sql,jdbcType=VARCHAR,mode=OUT})}") @Result(column = "sql", property = "sql", jdbcType = JdbcType.VARCHAR) @Options(statementType = StatementType.CALLABLE) void getSqlBycondition(@Param("map") Map<String, Object> map);
statementType = StatementType.CALLABLE 表示存储过程
3.在service中调用
String sql = ""; Map<String, Object> mapSql = new HashMap<>(); mapSql.put("num1", "1"); mapSql.put("num2", "2"); mapSql.put("sql", sql); middleService.getSqlBycondition(mapSql);
在通过map.get("sql")获取返回值