Reject Special characters

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
adityaram
Participant
Posts: 14
Joined: Mon Oct 11, 2004 10:01 am

Reject Special characters

Post by adityaram »

I might be dumb but not able to find a simple solution for this problem.
How to reject fields which contain special characters..Say I only need alpha-humeric characters in my field..say 123agb&* should be rejected.
Thanks
AR
davidnemirovsky
Participant
Posts: 85
Joined: Fri Jun 04, 2004 2:30 am
Location: Melbourne, Australia
Contact:

Post by davidnemirovsky »

In a Transformer stage create an extra output link leading to a sequential file stage, call it 'Rejects'.

On your "good" output link have an expression/routine that only allows alphanumeric characters through (for example writing a routine that reads each character and checks it's ASCII value, then returning TRUE if characerts are valid, can't remember if there is one in-built for this!).

On the second output link, either have the logical inverse as a constraint expression or, instead, have no expression but check the "Reject" check box.

Make sure (using output link execution order tool) that the rejects link is executed AFTER the "good" output link(s).

In terms of rows processed, there is no difference between a logical inverse expression and checking the check box. However, the check box will cause a warning message to be logged if any rows flow along the rejects link.

Big thanks to Ray, as I stole most of his reply to another post for this :lol:, no point re-inventing the wheel right?
... and no doubt he may add something more profound...
Cheers,
Dave Nemirovsky
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

To keep only printable characters, your "good" output can have the constraint expression

Code: Select all

InLink.ColumnName = Oconv(InLink.ColumnName, "MCP")
and the "reject" output can have the logical inverse (<>) or simply use the rejected rows check box.

The "MCP" conversion converts any non-printing character to ".". If NLS is enabled, printable characters are defined in the CTYPE category of your locale.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
davidnemirovsky
Participant
Posts: 85
Joined: Fri Jun 04, 2004 2:30 am
Location: Melbourne, Australia
Contact:

Post by davidnemirovsky »

tada!

Simple and effective.
Cheers,
Dave Nemirovsky
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You can also use convert() and compare it to the original field to look for a specific character like "&".

if InLink.ColumnName <> convert("&","", InLink.ColumnName) then @true else @false
Mamu Kim
Post Reply