Length issue

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
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Length issue

Post by scorpion »

Hi All,

Could any one help me to solve below request:

I have a input column in my input table like 'XXX'.

I need to map this to an output column as per below reqrmnt:

if length of column XXX < 9 then need output like 'AAA'

Else out put like (7-9)of the xxx COLUMN VALUE.



Tx in advance
Thanx&Regards
scorpion
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

7-9 as in the substring of XXX? And "length of column" as in field length or data length? if first is yes and second is data length see if this helps.

If Len(XXX) <9 Then 'AAA' Else XXX[7,3]
sas
Charter Member
Charter Member
Posts: 13
Joined: Sun Mar 05, 2006 12:37 am

Post by sas »

Maveric solution will work based on the assumption that column data type is CHAR not VARCHAR.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Position based transformation logic always works well and predictable with Fixed length or as mentintioned Char datatype in Datastage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
scorpion
Participant
Posts: 144
Joined: Thu May 12, 2005 4:19 am

Post by scorpion »

hi Mavrec/sas

Thanks for the reply,but both my input and output columns are varchar.

So how to proceed in this case?
Thanx&Regards
scorpion
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Its not that the given logic doesn't work for Varchar type data. It is assumed that if the data contains trailing empty space will be truncated with the Varchar datatype.
Based on the given condition, it is expected to have varying field length value for that field. Its ok to have the given condition with the Varchar field. Infact CHAR will not help you in the current scenario, as Len(field) will always return the length of the field.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Like Kumar_s Said if the field is a varchar then you will have to use trimleading trailing function to strip all spaces.
Post Reply