Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: ORA-01722: invalid number

 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am trying to do a query to a oracle database and process the information into a vector.
Here id the code:
"rs = stmt.executeQuery(comando); con.commit();
Vector vectorHab = new Vector();
while(rs.next())
{
Hashtable hashtableHab = new Hashtable();
hashtableHab.put("codigo", rs.getString("codigo"));
hashtableHab.put("nome", rs.getString("nome"));
vectorHab.addElement(hashtableHab);
}"
Unfortunately i am getting the error
"java.sql.SQLException: ORA-01722: invalid number"
I don�t understand why. Can anyone help me....
Thanks
Claudia Vaz
 
prabhat kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
post the sql query which u r executing
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
taken from here
ORA-01722 invalid number
Cause: The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates.
Action: Check the character strings in the function or expression. Check that they contain only numbers, a sign, a decimal point, and the character "E" or "e" and retry the operation.
Jamie
 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The query is:
"select * from HL where codigo>=100000 and codigo<1000000 and codigo not like '99999%'"
Thanks
Claudia Vaz
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Claudia Vaz:
Hi
The query is:
"select * from HL where codigo>=100000 and codigo<1000000 and codigo not like '99999%'"
Thanks
Claudia Vaz

I don't think you can't compare a String value with and number. codigo is a number and '99999%' can not be properly converted to a number for comparison. What you want to do is convert codigo to character data so you can do the comparison. So try this:
"select * from HL where codigo>=100000 and codigo<1000000 and TO_CHAR(codigo) not like '99999%'"
Jamie
[ March 04, 2002: Message edited by: Jamie Robertson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic