Identifying alphabets in a numeric 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
Lalitha
Participant
Posts: 2
Joined: Thu Mar 01, 2007 9:07 am
Location: Greenville
Contact:

Identifying alphabets in a numeric field

Post by Lalitha »

I am reading a sequential file with varchars(all fields as varchars inculding numbers) and trying to insert them into a table.The job abended with an "Invalid Number" error.One of the numeric fields contains alphabets or some wierd characters.How can I check in the transformer stage (or any other stage if I have to use one) if the incoming value is a numeric value.
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

There is an IsValid() function that allows you to check, in a Transformer stage, whether an input string is valid as some other data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Welcome Aboard,
There is a function AlNum() in the px transformer that performs Alpha-numeric checks. You can probably use that function.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

On second thought, use IsValid() :oops:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Lalitha
Participant
Posts: 2
Joined: Thu Mar 01, 2007 9:07 am
Location: Greenville
Contact:

Post by Lalitha »

I tried using the Alnum function.Since it checks if the argument contains alphanumeric values, even a value of '1' is getting rejected. And when Nulls are encounted,I am getting the following error:

APT_CombinedOperatorController,1: Requirements Failure: Null string argument.
Requirements Failure: Null string argument.

I also tried using the Isvalid function,but got this error for Nulls:

APT_CombinedOperatorController,1: Expected identifier; got: <eof>

This is the error for a value of '1':

APT_CombinedOperatorController,2: Expected identifier; got: "1".
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Transformer functions are intolerant of nulls. You must handle them separately. NULL is valid for any data type (provided the receiving field is nullable). Therefore you require something like

Code: Select all

If IsNull(InLink.TheColumn) Then 1 Else IsValid("Integer", InLink.TheColumn)
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