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
Reject Special characters
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 85
- Joined: Fri Jun 04, 2004 2:30 am
- Location: Melbourne, Australia
- Contact:
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 , no point re-inventing the wheel right?
... and no doubt he may add something more profound...
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 , no point re-inventing the wheel right?
... and no doubt he may add something more profound...
Cheers,
Dave Nemirovsky
Dave Nemirovsky
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
To keep only printable characters, your "good" output can have the constraint expression
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.
Code: Select all
InLink.ColumnName = Oconv(InLink.ColumnName, "MCP")
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 85
- Joined: Fri Jun 04, 2004 2:30 am
- Location: Melbourne, Australia
- Contact: