• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ORA-01722 : invalid number

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why when I'm trying to insert a double or a long ( with insert into table in java ) in a column type number(20) always I obtained an error : "ORA-01722 : unvalid number"
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you share the code you are using to insert these values?
 
bahri sirine
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

stm0.executeUpdate("insert into test values ('"+i+"','"+j+"','"+k+"','"+t0+"')");

such that in the data base the first column is number(10), the second is number(20) the thirs is number(20) and the fourth is number (20)
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Print out your query before executing it.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
  • Like Dave says, print out the actual SQL your Java code is trying to execute. Right now you do not know what is in the string that is being sent to the database, so you don't know what is causing the problem.
  • When you have the actual SQL string that is being sent to the database, execute that SQL directly via your SQL*Plus or SQL Developer client.
  • If you do not have a proper SQL client (e.g. SQL*Plus, SQL Developer, etc) then you do not have the tools to do your job properly, so install one ASAP and start using it to test your SQL before you put it into your Java code.
  • Incidentally, you don't need single-quotes around your values if they are numbers.
  • Finally, do not build SQL strings like this, but use prepared statements instead - see the Oracle JDBC docs.
  •  
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic