java调用oracle函数出错 PLS-00382: 表达式类型错误 10
createorreplacefunctionexchangeFun(p_agencyIdvarchar2)returnvarchar2asv_outvarchar2(1...
create or replace function exchangeFun(p_agencyId varchar2) return varchar2 as
v_out varchar2(1000):='select ';
cursor c is select c.*
from property_type t, property_code c
where t.type_name = 'vv'
and t.uids = c.type_name;
begin
for v_temp in c loop
v_out:=v_out||'(select appraise_result from prj_consulting_agency_appraise a where a.agency_id=t.uuid and appraise_aspect='''||v_temp.property_code||''') appraise'||v_temp.property_code||',';
end loop;
v_out := substr(v_out,0,length(v_out)-1);
v_out := v_out ||' from prj_consulting_agency t where t.uuid='''||p_agencyId||'''';
return v_out;
exception
when others then
return '';
end ;
===========以上是我写的function======================
sql = "{?=call exchangeFun(?) }";
CallableStatement stmt = conn.prepareCall(sql);
stmt.setString(2, p_param);
stmt.registerOutParameter( 1, oracle.jdbc.OracleTypes.CURSOR);
stmt.execute();
==========以上是调用函数的java代码=====================
抛出异常:
java.sql.SQLException: ORA-06550: 第 1 行, 第 13 列:
PLS-00382: 表达式类型错误
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored
我知道了
stmt.registerOutParameter( 1, oracle.jdbc.OracleTypes.CURSOR);
应该改为
stmt.registerOutParameter( 1, oracle.jdbc.OracleTypes.VARCHAR); 展开
v_out varchar2(1000):='select ';
cursor c is select c.*
from property_type t, property_code c
where t.type_name = 'vv'
and t.uids = c.type_name;
begin
for v_temp in c loop
v_out:=v_out||'(select appraise_result from prj_consulting_agency_appraise a where a.agency_id=t.uuid and appraise_aspect='''||v_temp.property_code||''') appraise'||v_temp.property_code||',';
end loop;
v_out := substr(v_out,0,length(v_out)-1);
v_out := v_out ||' from prj_consulting_agency t where t.uuid='''||p_agencyId||'''';
return v_out;
exception
when others then
return '';
end ;
===========以上是我写的function======================
sql = "{?=call exchangeFun(?) }";
CallableStatement stmt = conn.prepareCall(sql);
stmt.setString(2, p_param);
stmt.registerOutParameter( 1, oracle.jdbc.OracleTypes.CURSOR);
stmt.execute();
==========以上是调用函数的java代码=====================
抛出异常:
java.sql.SQLException: ORA-06550: 第 1 行, 第 13 列:
PLS-00382: 表达式类型错误
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored
我知道了
stmt.registerOutParameter( 1, oracle.jdbc.OracleTypes.CURSOR);
应该改为
stmt.registerOutParameter( 1, oracle.jdbc.OracleTypes.VARCHAR); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询