mybatis调取oracle execute immediate动态拼接存储过程返回结果

1:存储过程
--动态过程
create or replace procedure dynamic_pro(pro in varchar2,res out varchar2)  is
  vSQL   varchar2(200);
begin
  vSQL := 'BEGIN '||pro||'; END;';
  execute immediate vSQL using out res;
end dsm_dynamic_pro;
--调取过程
create or replace procedure test_len (filed varchar2,res out varchar2) is
/**
**描述
**/
begin
  if(length(filed)>10) then
      res:='error';
      dbms_output.put_line('error');
    else
      res:='success';
      dbms_output.put_line('success');
    end if;
end test_len;
2:mybatis xml

             
       

 
3:dao
public String ardoData(Map paramMap);
4:service实现类
public String ardoData(String pro) {
Map paramMap = new HashMap();
paramMap.put("pro", pro);
dao.ardoData(paramMap);
System.out.println(paramMap.get("res"));
return paramMap.get("res");
}
5:调取过程
String pro = " test_len (‘铜雀深宫锁二乔’,:res)";
System.out.println("调用的存储过程:"+pro);
String result = service.ardoData(pro);
System.out.println("结果:"+ result);



你可能感兴趣的:(mybatis,mybatis)