【发布时间】:2015-01-13 00:58:16
【问题描述】:
我正在使用 JPA 1 并且有一个本机查询执行以下语句:
select NVL (max (x.some), 0) from (select count (1) as some, service from some_table Where trunc (fh_report) = '09 / 01/2015 'group by service) x
标记错误是:
java.sql.SQLDataException: ORA-01843: 月份无效
但是,如果我在 ORACLE ide 中复制这句话,它运行得很好,我有两个数据库,一个用于测试,一个用于生产,生产标记这个错误,而在测试中不要。
我也想知道,什么比较好??将日期包含在字符串中,然后像这样将其传递给 jpa?
String sql = "select NVL (max (x.some), 0) from (select count (1) as some, service from some_table Where trunc (fh_report) = '09 / 01/2015 'group by service) x ";
Query query = em.createNativeQuery(sql.toString());
还是将日期值作为参数传递?
这可能是错误的原因?
非常感谢。
【问题讨论】:
-
发布实际执行的 SQL 语句,还是按原样执行?日期格式看起来很奇怪。
-
嗨 Chylis 是的,它的执行就像我发布的那样,如果我在 sql developer 或任何其他 sql ide 中运行它,它会完美运行...