Filtering character values in transformer

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
bi_fujitsu
Premium Member
Premium Member
Posts: 46
Joined: Tue Mar 20, 2007 3:30 am
Location: India

Filtering character values in transformer

Post by bi_fujitsu »

We have both character and numeric values in a field. We need to pick only numeric values from this set of values to insert into an oracle table.
Is there any function using which we can apply a constraint on this field in the transformer stage?
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

Do you mean that each record will either have number or character values in the field and you want to load the records with numbers in that field?

In which case use the function "num()" as a constraint on the link

Code: Select all

num(input.field) = 1 and input.field <> ''
returns 1 if a number or an empty string.

If what you mean is that your field contains both letters and numbers and you want to get just the numbers from that field use

Code: Select all

Oconv(input.field, "MCN")
Regards,

Nick.
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

nick.bond wrote:Do you mean that each record will either have number or character values in the field and you want to load the records with numbers in that field?

In which case use the function "num()" as a constraint on the link

Code: Select all

num(input.field) = 1 and input.field <> ''
returns 1 if a number or an empty string.

If what you mean is that your field contains both letters and numbers and you want to get just the numbers from that field use

Code: Select all

Oconv(input.field, "MCN")
Can you use/access Oconv function in parallel job?
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post by nick.bond »

Ah - no sorry, I was thinking in Server mode! Doing night shift and a bit tired! :oops:
Regards,

Nick.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use CONVERT() function to convert every character thats not numeric to an empty space. Something like

Code: Select all

CONVERT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+=-,./;[]\|}{:?><","",in.COL)
You can add any character that i left out in that huge list.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply