Filtering on contents of Integer field

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
zendo59
Participant
Posts: 6
Joined: Tue Feb 05, 2008 11:32 pm

Filtering on contents of Integer field

Post by zendo59 »

We have a pipe-delimited source file.

One of the fields is defined as integer.

We want to filter the file and only keep records where the 1st character of this integer field is 7 e.g 7, 777, 700000

I can't seem to get this to work in a Filter stage.

Can anyone give me some tips?

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

Post by chulett »

What have you tried?
-craig

"You can never have too many knives" -- Logan Nine Fingers
zendo59
Participant
Posts: 6
Joined: Tue Feb 05, 2008 11:32 pm

Post by zendo59 »

I tried:

FieldName[1:1] = 7

FieldName[1,1] = 7


Don't laugh................... I am an old mainframe programmer....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No-one is laughing, we all were a noob at some point. :wink:

Your second syntax is correct, as long as the field is defined as a string:

Code: Select all

FieldName[1,1] = '7'
You can then use StringToDecimal (off the top of my head) to properly convert the datatype for downstream consumption.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'm not at a DS client to check this, but the indexing in transform starts at position 1 (for Server compatibility) while everywhere else strings start at position 0, so the correct form might be FieldName[0,1] = '7'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Zero-based in Modify stage, one-based in Transformer stage.

This is because they wanted the Transformer stage to use BASIC-like expressions, which the compiler would translate into C constructs.
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