aspose file tools*
The moose likes JDBC and the fly likes Leading zeroes in an Integer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Leading zeroes in an Integer" Watch "Leading zeroes in an Integer" New topic
Author

Leading zeroes in an Integer

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 247
My data field allows leading zeroes with a maximum length of 3.
e.g. "001", "1", "123", "456" are all valid but "1234", "0001" are not valid.
One solution is to define the data field as CHAR(3) in the DB2 database.
Is it possible that the data field in the DB2 database be defined as INTEGER so that the leading zeroes are still preserved (i.e. “001” is different from “1”)?
If that is possible, how to manipulate the data field by Java?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

albert kaoIs it possible that the data field in the DB2 database be defined as INTEGER so that the leading zeroes are still preserved (i.e. “001” is different from “1”)?[/quote wrote:
No. You need to use char if you want to differentiate between the two.


[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
 
 
subject: Leading zeroes in an Integer