I am using JPA 1 and have a native query executing the following statement:
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
marking the error is:
java.sql.SQLDataException: ORA-01843: not a valid month
However, if I copy the sentence in ORACLE ide this runs perfectly, I have two databases, one for testing and one for production, production marks this mistake and in testing dont.
I want to know also, what is better?? include the dates into string and then pass it to jpa like this?
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());
or pass the date value as parameter?
This could be the reason from error?
Thanks a lot.
Implicit date conversion may depend on both your client and your server settings. The same code will often run in one environment but not another.
One solution is to use an ANSI date literal, in the ISO 8601 format:
I'm guessing the original code uses the American date format. The advantage of ISO 8601 is that no person or computer needs to guess, it is unambiguous.