There is a simple workaround for that restriction, which does not require a wrapper function, simply wrap the boolean function itself in a CASE
statement and use an Integer for binding:
stmt = conn.prepareCall(
"BEGIN"
+ " ? := CASE WHEN (myBooleanFuncInOracle()) "
+ " THEN 1 "
+ " ELSE 0"
+ " END;"
+ "END;");
stmt.registerOutParameter(1, Types.INTEGER);
// exec
stmt.execute();
// get boolean from Integer
boolean myBool = (stmt.getInt(1) == 1);
Very useful if you can't or don't want to change your function or even can't create a wrapper function, i.e. in legacy DBs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…