Len function issues in VARCHAR columns

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
siva7143
Participant
Posts: 35
Joined: Wed Aug 09, 2006 12:20 am

Len function issues in VARCHAR columns

Post by siva7143 »

Hi,

Need to load the source records which must be 5 or 6 characters long into the target table.

Source field Data Type - VARCHAR (15) NULLABLE column
Target field Data Type - VARCHAR (15) NULLABLE column

When I use the below function,
If (Len(Trim(InputColumn)) = 5 Or Len(Trim(InputColumn)) = 6) Then 1 Else 0

Records with length of 5 are not loaded into the target, where as they're loaded when I change the Len function as
If (Len(Trim(InputColumn)) = 10) Then 1 Else 0

Please let me know the possible resolution for this issue.

Thanks.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Can you try looking at the hex values of data in that field? If it is a file you can try any hex editor to check if there are some trailing non-printable character.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
siva7143
Participant
Posts: 35
Joined: Wed Aug 09, 2006 12:20 am

Len function issues in VARCHAR columns

Post by siva7143 »

Input records are as follows,
TRSCX
TSRPX
TRCPX
TRGIX
W146#
TIKRX
TIIEX
W146#
TRRSX
TIHRX
TIKRX
TRCPX
TRSCX
TIQRX
TRIEX
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

In addition to the list of values, could you output the numer value of "LEN(TRIM(<columnname>))" as well so we can identify which ones don't meet your expectations?
Developer9
Premium Member
Premium Member
Posts: 187
Joined: Thu Apr 14, 2011 5:10 pm

Post by Developer9 »

Hi,

Tried with this statement

If (Len(Trim(InputColumn)) = 5 Or Len(Trim(InputColumn)) = 6) Then 1 Else InputColumn=0

Have Constraints in the transformer (InputColumn=0 OR 1) to verify the output

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Neither of those expressions are valid:

If (Len(Trim(InputColumn)) = 5 Or Len(Trim(InputColumn)) = 6) Then 1 Else 0

InputColumn=0 OR InputColumn=1
-craig

"You can never have too many knives" -- Logan Nine Fingers
siva7143
Participant
Posts: 35
Joined: Wed Aug 09, 2006 12:20 am

Post by siva7143 »

Developer9 wrote:Hi,

Tried with this statement

If (Len(Trim(InputColumn)) = 5 Or Len(Trim(InputColumn)) = 6) Then 1 Else InputColumn=0

Have Constraints in the transformer (InputColumn=0 OR 1) to verify the output

Thanks.
Tried that option as well, seems like we have some special charaters coming from source which we are not able to read that in Datastage.
Is there any other function that can get the exact length value of a string which contains special characters.

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Using what you've done it seems that strings that you think should have a length of 5 or 6 don't; but now you should try to find out what length those strings actually have (according to the LEN() function). The characters don't look like multibyte ones, but there might be hidden and non-displayable characters mixed in there.
Post Reply