我正在使用oracle數據庫和spring ibatis。如何選擇具有最小值的列的行
我有一個查詢,將返回兩個結果,我需要獲得一列有最小值的記錄。
在Oracle我做,使用下面的查詢:
SELECT *
FROM ANUMBER$ROOT ROOT
WHERE ROOT.ROOT_NUMBER=1546305
AND ROOT.MOL_WEIGHT = (SELECT MIN(MOL_WEIGHT)
FROM ANUMBER$ROOT
WHERE ROOT_NUMBER=1546305);
我已經轉換此查詢下方喜歡在春季ibatis的
SELECT *
FROM ANUMBER$ROOT ROOT
WHEREe ROOT.ROOT_NUMBER= #value#
AND ROOT.MOL_WEIGHT = (SELECT MIN(MOL_WEIGHT)
FROM ANUMBER$ROOT
WHERE ROOT_NUMBER= #value#);
但是,這將引發我下面的錯誤:
**log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in abbott/gprd/compoundInfo/dao/ibatis/LibraCompoundInformationLookup.xml.--- The error occurred while preparing the mapped statement for execution.
--- Check the selectCompoundInfoByRootNumber.
--- Check the SQL statement.
--- Cause: java.util.NoSuchElementException; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in abbott/gprd/compoundInfo/dao/ibatis/LibraCompoundInformationLookup.xml.--- The error occurred while preparing the mapped statement for execution.
--- Check the selectCompoundInfoByRootNumber.
--- Check the SQL statement.
--- Cause: java.util.NoSuchElementException Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in abbott/gprd/compoundInfo/dao/ibatis/LibraCompoundInformationLookup.xml.--- The error occurred while preparing the mapped statement for execution.
--- Check the selectCompoundInfoByRootNumber.
--- Check the SQL statement.
--- Cause: java.util.NoSuchElementException at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106) at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:243) at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193) at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:241) at abbott.gprd.compoundInfo.dao.ibatis.CompoundInformationDao.getCompoundInformationForRootNumber(CompoundInformationDao.java:66) at abbott.gprd.compoundInfo.dao.ibatis.CompoundInformationDao.main(CompoundInformationDao.java:183) Caused by: java.util.NoSuchElementException at java.util.StringTokenizer.nextToken(StringTokenizer.java:332) at com.ibatis.sqlmap.engine.mapping.sql.simple.SimpleDynamicSql.processDynamicElements(SimpleDynamicSql.java:90) at com.ibatis.sqlmap.engine.mapping.sql.simple.SimpleDynamicSql.getSql(SimpleDynamicSql.java:45) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:168) ... 9 more ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]**
任何人都可以請幫我轉換這個查詢從甲骨文到春季ibatis?
我會改變1546305#值#並嘗試它是否有效。 – Egl
這也沒有幫助 – Prakash