2017-07-21 57 views
0

我請從Java(Toplink的)存儲過程如下:PLSQL存儲過程查詢(排名靠前的)返回的BigDecimal字段而不分數

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」)返回存儲在某個值有小數部分的DB,但在Java中它是沒有它寫

record.get(「some_variable」)。的getClass()返回BigDecimal.class

我怎樣才能獲得存儲在數據庫中的分數值?

回答

0

有必要使用以下方法:

/** 
* 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)); 
} 
相關問題