Checking leading zeroes.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
saraswati
Premium Member
Premium Member
Posts: 149
Joined: Thu Feb 28, 2008 4:25 pm

Checking leading zeroes.

Post by saraswati »

I have following values for a varchar column:

36804629891, 083647382718

How to find the length of the values ?

How to check if there is any leading zeroes for the values ?

How to take first 10 digits of the numbers?
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Checking leading zeroes.

Post by SURA »

1. Len(Column_Name) will give you the length.

2. Do you need to know how may 0's or you need to takeout the 0.
If you want to take out, then you can make the mapped column as Int (You can use the function AsInteger(ColumnName)).

3. Column_Name [1,10] will give you the first 10 char.


DS User
saraswati
Premium Member
Premium Member
Posts: 149
Joined: Thu Feb 28, 2008 4:25 pm

Post by saraswati »

I want to check if there is any leading zeroes......it might be one or two.

How is AsInteger function going to help?
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Post by SURA »

My comment 2 is to remove the 0 and not to find. Hope i mentioned that !

Let me know your DS Version.

DS User
deeplind07
Participant
Posts: 31
Joined: Mon Jun 28, 2010 5:15 am
Location: pune

Post by deeplind07 »

If you read the response properly, SURA said 'If you want to take out, then you can make the mapped column as Int (You can use the function AsInteger(ColumnName)). '

Asinteger() will remove the leading zeroes.

This may not be the best method but you can do
Len(Column_Name)-Len(AsInteger(ColumnName)) to find the number of leading Zeroes.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If there are leading zeroes the first digit in the number will be 0. It is sufficient to test for this.

Code: Select all

Left(InLink.TheNumber,1) = "0"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply