我从Java(Toplink(调用存储过程,如下所示:
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall();
call.setProcedureName("PACK_PORTAL_VIEW.get_payment_details");
call.addNamedArgument("p_order_id", JDBCTypes.NUMERIC_TYPE);
call.addNamedOutputArgument("some_variable", JDBCTypes.NUMERIC_TYPE);
DataReadQuery drQuery = new DataReadQuery();
drQuery.setCall(call);
drQuery.addArgument("p_order_id");
Query query = ((JpaEntityManager) em.getDelegate()).createQuery(drQuery);
query.setParameter("p_order_id", orderId);
DatabaseRecord record = (DatabaseRecord) query.getSingleResult();
record.get("some_variable");
record.get("some_variable"( 返回一些值,该值存储在数据库中带有小数部分,但在 Java 中,它是在没有小数部分的情况下编写
的record.get("some_variable"(.getClass(( 返回 BigDecimal.class
如何获取存储在数据库中的小数值?
有必要使用以下方法:
/**
* PUBLIC: Add a named OUT argument to the stored procedure. The databaseType parameter
* classifies the parameter (JDBCType vs. OraclePLSQLType, simple vs. complex). The extra scale
* and precision parameters indicates that this parameter, when used in an Anonymous PL/SQL
* block, requires scale and precision specification
*/
public void addNamedOutputArgument(String procedureParameterName, DatabaseType databaseType,
int precision, int scale) {
DatabaseType dt = databaseType.isComplexDatabaseType() ?
((ComplexDatabaseType)databaseType).clone() : databaseType;
arguments.add(new PLSQLargument(procedureParameterName, originalIndex++, OUT, dt,
precision, scale));
}