I'm trying to run a select query from a java class. The query is built as a simple string based on user's input. However, I get ORA-01843: not a valid month error when I have date values inside where clause.. When I copy the same query and execute in Oracle DB viewer it works perfectly.. What could be the problem?
Herman Schelti
Ranch Hand
Joined: Jul 17, 2006
Posts: 387
posted
0
hi Steve,
the problem is that you did not post any code (yet).
Also: do your java class and the Oracle DB viewer use the same driver?
Herman
Steve Renard
Ranch Hand
Joined: Apr 27, 2007
Posts: 66
posted
0
This is the query: String query="select PRCS_DT from PURCH_TRANS where PRCS_DT='4/5/2007'" ; rs = stmt.executeQuery(query); It works fine when copied and executed in DB viewer.. I'm also sure that both java and Oracle use the same driver.. Please help..
The standard format is: DD-MON-YYYY. Where DD = two digit day number MON = three character month code (localized in your Oracle NLS language) YYYY = four digit year.
In your example: '04-MAY-2007' If you want to use another date format, refer to Oracle's to_date function. Your coud use something like ... to_date('04/05/2007', 'DD/MM/YYYY')...
Regards, Jan [ June 23, 2007: Message edited by: Jan Cumps ]
OCUP UML fundamental
ITIL foundation
Steve Renard
Ranch Hand
Joined: Apr 27, 2007
Posts: 66
posted
0
Thanks Jan, I used tochar function to make the comparison.. It worked great..
Steve Renard
Ranch Hand
Joined: Apr 27, 2007
Posts: 66
posted
0
Thanks Jan, I used tochar function to make the comparison.. It worked great..
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.