1.Function声明:
create or replace function getValueFunc(num NVARCHAR2)
return NVARCHAR2 is
fnameRet NVARCHAR2(100);
begin
select fname into fnameRet from t_afl_bd_custrptitem where fnumber = num;
return fnameRet;
end;
2.测试:
select getValueFunc('0500124') from dual
3.JDBC调用:
Connection con = null;
CallableStatement cs = null;
try {
con = ConnectionFacatory.getCon();
cs = con.prepareCall("{? = call getValueFunc(?)}");
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(2, "0500124");
cs.execute();
String retValue = cs.getString(1);
System.out.println(retValue);
} catch (SQLException e) {
throw new BOSException(e);
} finally {
try {
cs.close();
con.close();
} catch (SQLException e) {
throw new BOSException(e);
}
}
2009-10-20
707

被折叠的 条评论
为什么被折叠?



