-
Notifications
You must be signed in to change notification settings - Fork 2
Binding Oracle Booleans
Oracle offers two kinds of booleans, SQL booleans (NUMBER
0/1) and PL/SQL booleans, they have to be bound differently.
SQL booleans are actually just the numbers 0 and 1, much like C booleans. Nevertheless they can be mapped automatically.
void booleanFunction(boolean input);
It is important to note that this only works as long as parameters are not bound by type. If such a binding is used then the type has to be explicitly stated
void booleanFunction(@ParameterType(java.sql.Types.NUMERIC boolean input);
PL/SQL booleans in Oracle have to be mapped to OracleTypes#PLSQL_BOOLEAN.
void booleanFunction(@ParameterType(oracle.jdbc.OracleTypes.PLSQL_BOOLEAN) boolean input);
Alternatively calling #withOracleTypeMapper()
or #withOracleExtensions()
on the ProcedureCallerFactory
will automatically do this for all booleans.
In both cases the type has to be passed to the parameter registration by calling #withParameterRegistration(ParameterRegistration.INDEX_AND_TYPE)
A full example may look like this, this does not require the @ ParameterType
annotation
procedure = ProcedureCallerFactory.of(OracleProcedures.class, dataSource)
.withParameterRegistration(ParameterRegistration.INDEX_AND_TYPE)
.withOracleTypeMapper() // withOracleExtensions() enables all extensions
.build();
This requires at least the 12.2c JDBC driver, if you check the interoperability matrix the 12.2c driver can be used with the 11.2g database.
-
Usage
-
Integration