Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Leading zeroes in an Integer  RSS feed

 
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
Sheriff
Posts: 37234
519
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!