SQL 日期格式绑定变量
谁能告诉我这个 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 Developer 中运行它时,我收到此消息
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
提前致谢。
Can anyone please tell me what is wrong with this SQL 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')'
I got this message when I ran it in SQL developer
Unknown Command
Bind Variable "MI" is NOT DECLARED
I am calling this from java like this
try {
stmt = conn.createStatement();
results = stmt.executeQuery(queryToExecute);
} catch (SQLException e) {
CredChangeReportSVC.DEFAULTLOGGER.error("An exception occurred while executing query: " + queryToExecute, e);
}
In the logs I get this message
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
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的日期格式指定了时间部分,但您在日期时间字符串中省略了它。从日期字符串中删除“HH24:MI:SS”,然后重试
Your date format specifies a time part, but you have omitted this in your datetime strings. Drop the "HH24:MI:SS" from the date strings and try again