Page 1 of 1
Filtering on contents of Integer field
Posted: Thu Feb 28, 2008 4:30 pm
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.
Posted: Thu Feb 28, 2008 4:39 pm
by chulett
What have you tried?
Posted: Thu Feb 28, 2008 4:44 pm
by zendo59
I tried:
FieldName[1:1] = 7
FieldName[1,1] = 7
Don't laugh................... I am an old mainframe programmer....
Posted: Thu Feb 28, 2008 6:13 pm
by chulett
No-one is laughing, we all were a noob at some point.
Your second syntax is correct, as long as the field is defined as a string:
You can then use StringToDecimal (off the top of my head) to properly convert the datatype for downstream consumption.
Posted: Fri Feb 29, 2008 3:54 am
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'
Posted: Fri Feb 29, 2008 3:13 pm
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.