This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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: 2491
    
    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: 2491
    
    8

exactly. 4 digits, of which two are decimals.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to insert 1.5 into a sql colunm on Number(2,2)
 
Similar Threads
Using Mutilple Cell Editor on single column of JTable
problem in a question about generic?
'mulit-dimensional' arrays in javascript
Future computer science student
Pseudocode and clueless