This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes Need to insert 1.5 into a sql colunm on Number(2,2) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need to insert 1.5 into a sql colunm on Number(2,2)" Watch "Need to insert 1.5 into a sql colunm on Number(2,2)" New topic
Author

Need to insert 1.5 into a sql colunm on Number(2,2)

Dave Trower
Ranch Hand

Joined: Feb 12, 2003
Posts: 86
I tried to do the following:


Now the sixth field is NUMBER(2,2)
I am getting the error "ORA-01438: value larger than specified precision allowed for this column"
How can I do this?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

Start by listing the column names in your sql insert query. Who knowns what you are inserting in which column?


OCUP UML fundamental and ITIL foundation
youtube channel
Dave Trower
Ranch Hand

Joined: Feb 12, 2003
Posts: 86
When I do a desribe on the table:
SQL> desc timesheetdata
Name Null? Type
----------------------------------------- -------- ----------------------------
TIMESHEET_ID NOT NULL NUMBER(10)
USERID VARCHAR2(20)
TIME_DATE DATE
CAMIT_ID VARCHAR2(20)
ACTIVITY VARCHAR2(20)
HOURS NUMBER(2,2)
COMMENTS VARCHAR2(256)

I know that the problem is with the sixth field.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

But doesn't that column only allow numbers of the form ".NN"? How would you expect 1.50 to fit into that?
Dave Trower
Ranch Hand

Joined: Feb 12, 2003
Posts: 86
I think Paul disovered the problem.
So if I want to able to store fields like 10.25, would I need the Oracle column to be number(4,2)?
This is suppose to represent the number of hours worked per day (which cannot be higher than 24) and we want two decimal places.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

exactly. 4 digits, of which two are decimals.
 
Don't get me started about those stupid light bulbs.
 
subject: Need to insert 1.5 into a sql colunm on Number(2,2)