File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Decimal problem 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 "Decimal problem" Watch "Decimal problem" New topic
Author

Decimal problem

Cheryl Gray
Ranch Hand

Joined: Nov 17, 2000
Posts: 44
I was taking an online class and I saw this,
CREATE TABLE STAFF(STAFFNUM DECIMAL(6,0));

Could we also put this as STAFFNUM INT ? Why are users allowed to specify 0 decimal places?


Anything is possible to those who believe.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Maybe the table creator was trying to specify that the id number cannot be more than six digits?

I suspect this could be a char(6) or varchar(6) column rather than numeric in the first place. Unless it makes sense to do arithmetic or numerical comparisons with ids, they aren't really numbers. They are identifiers that happen to consist of digits.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Jeanne Boyarsky:
Maybe the table creator was trying to specify that the id number cannot be more than six digits?

I suspect this could be a char(6) or varchar(6) column rather than numeric in the first place. Unless it makes sense to do arithmetic or numerical comparisons with ids, they aren't really numbers. They are identifiers that happen to consist of digits.


STAFFNUM is likely similar to my employee number... which happens to be 6 digits as well.

From a data modeling standpoint... it isn't really a number and should be stored as character data.
[ October 19, 2007: Message edited by: Paul Campbell ]
 
wood burning stoves
 
subject: Decimal problem
 
Similar Threads
Correctly specified Identifiers
why the long value print 10 ,not 12 ?
Decimals not converting to correct fractions
Urgent A method in Java which rounds 18 places to 8 places after decimal
How to find number of decimal places?