Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Leading zeroes in an Integer

 
albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic