Varchar to SmallInt

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
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Varchar to SmallInt

Post by Hope »

I have a source feild whose datatype is varchar. I have to convert this to SmallInt in Target. What kind of a function I can use in Transformer.
Please suggest.


Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The chapter on conversions should cover that (I don't have it accessible right now) but I am sure that this is one where an implicit conversion will work, i.e. just drag the VarChar column to an appropriately defined SmallInt output column.
krishobby
Participant
Posts: 20
Joined: Sun Dec 04, 2005 3:23 pm

Post by krishobby »

You can use StringToDecimal(<input port.)

If you want to check before converting you can use the following:

If IsNull(<input port>) Then SetNull()
Else If Trim(<input port>) Then Setnull()
Else Trim(<Input port>)

If you want to check the validity of the data before converting you can also use the IsValid function

If IsValid ("unit32",<input port>) Then StringtoDecimal(<input port>)
Post Reply