我有对PL / SQL函数的调用
FUNCTION F_IsDemandeDeLitFromHosp(i_NoMvtHosp IN MVTHOSP.NOMVTHOSP%TYPE
)RETURN BOOLEAN
IS
v_Found NUMBER := 0;
BEGIN
BEGIN
SELECT COUNT(1) INTO v_Found
FROM ICSF.T_DEMANDE_LIT D, MVTUS U, MVTHOSP H
WHERE H.NOMVTHOSP = i_NoMvtHosp
AND H.NOMVTHOSP = U.NOMVTHOSP
AND U.NOMVTUS = D.NOMVTUS
AND U.RANG <> '0000000000'
AND H.RANG = '0000100000'
AND NVL (D.ETAT, ' ') <> 'X'
AND NVL (U.ETAT, ' ') <> 'X'
AND NVL (H.ETAT, ' ') <> 'X'
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
RETURN FALSE;
END;
IF v_Found > 0 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END F_IsDemandeDeLitFromHosp;
我尝试编写一个服务来获取布尔值。 i_NoMvtHosp
是CHAR(10 BYTE)
,这是我的函数调用:
@Override
public DemandeDeLitFromHospit isDemandeDelitFromHosp(String noMvtHosp) {
final ProcedureRequest request = new ProcedureRequest(PK.GET_IS_DEMANDE_DE_LIT_FROM_HOSP.getPackageName(), PK.GET_IS_DEMANDE_DE_LIT_FROM_HOSP.getMethodeName());
request.addInParam("i_NoMvtHosp", noMvtHosp);
DemandeDeLitFromHospit demande = new DemandeDeLitFromHospit();
demande.setIsDemandeDeLitFromHosp((Boolean)callFunction(request, new CallableStatementCallback<Boolean>() {
public Boolean doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
cs.execute();
return Boolean.valueOf(cs.getResultSet().toString());
}
}));
return demande;
}
我有这个错误:
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; Type de colonne non valide: 1111; nested exception is java.sql.SQLException: Type de colonne non valide: 1111
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1032)
at fr.mckesson.framework.persistence.plsql.AbstractProcedureDao.callFunction(AbstractProcedureDao.java:317)
at fr.mckesson.business.venue.clinique.evenement.dao.implementation.DemandeLitDAO.isDemandeDelitFromHosp(DemandeLitDAO.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我哪里错了?
答案 0 :(得分:1)
您的代码在error code [17004]; invalid column type: 1111
上失败了。发生此错误的原因是您的代码使用JDBC无法识别的数据类型。
这可能是因为你的函数返回BOOLEAN。 Boolean不是有效的SQL数据类型。您也无法在简单的Oracle SQL查询中调用该函数。
JDBC确实提供了a mapping of bit
to Java boolean
and Boolean
,但这只适用于支持非标准数据类型的数据库产品,而Oracle不是其中之一。