Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make a number deafult length of 9

Status
Not open for further replies.
Aug 13, 2009
29
US
Friends I have a number and I am converting this to chat to conc with other stirnf field.

But the when i convert the number it strips of 0's before number

suppose number is 001234598 when i convert it to string it strips of 00 and gives me 1234598, any way to fix this?. THanks in advance
Lori
 
001234598 looks pretty much like a string to me..

Ties Blom

 
Hi Lori,
It depends on what the format of the column is that you are looking at as 'numeric'. In DB2 numeric has two flavours - Integer and Decimal and to get the leading zeroes when converting to a string, you need different functions.

If the column is an integer use DIGITS(colname) whereas if the column is decimal use CHAR(colname).

Hope this helps.

Marc
 
Solution:

select right(digits(your_integer), 9)
from sysibm.sysdummy1

Lenny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top