Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post the sql query which u r executing
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic