任何人都可以告诉我这个SQL查询有什么问题。
select
USERNAME, DATECREATED, CREDTYPE, USAGETYPE, OPERATIONID, TXNID, CALLERID
from
arwfissuanceauditlog
where
OPERATIONID in (2104,2107)
and datecreated >= 'to_date('2010/06/21', 'yyyy/MM/dd HH24:MI:SS')'
and datecreated < 'to_date('2010/08/03', 'yyyy/MM/dd HH24:MI:SS')'
我在SQL开发人员中运行它时收到此消息
Unknown Command
Bind Variable "MI" is NOT DECLARED
我是这样用java来调用它的
try {
stmt = conn.createStatement();
results = stmt.executeQuery(queryToExecute);
} catch (SQLException e) {
CredChangeReportSVC.DEFAULTLOGGER.error("An exception occurred while executing query: " + queryToExecute, e);
}
在日志中我收到此消息
ERROR 03 Aug 2010 14:51:06,939 - An exception occurred while executing query: "select USERNAME, DATECREATED, CREDTYPE, USAGETYPE, OPERATIONID, TXNID, CALLERID from arwfissuanceauditlog where OPERATIONID in (2104,2107) and datecreated >= 'to_date('2010/06/21', 'yyyy/MM/dd HH24:MI:SS')' and datecreated < 'to_date('2010/08/03', 'yyyy/MM/dd HH24:MI:SS')'"
java.sql.SQLException: Invalid SQL type
提前致谢。
答案 0 :(得分:0)
您的日期格式指定了时间部分,但您在日期时间字符串中省略了这一点。从日期字符串中删除“HH24:MI:SS”并再试一次