Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ORA-01722 : invalid number

 
bahri sirine
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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"
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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)
 
Dave Tolls
Ranch Hand
Posts: 2103
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Print out your query before executing it.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • 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.
  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic