Convert Char to Integer 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
arvindj
Participant
Posts: 1
Joined: Thu Nov 06, 2014 2:44 am

Convert Char to Integer in transformer

Post by arvindj »

Hi All, I have a job in our project. Job reads a flat file into sequential file and load that to a table. Transformer stage is used in between.

Input file has a column of Char(1), Emp_type and incoming values can be "P" or "T" only, for Permanent and Temporary employees. Now client want us to covert that "P" to 1 and "T" to 2 and load that to table. Earlier we were just passing T and P to table.

Please let me how this can be achieved. I'll really appreciate, If someone can provide exact code to perform this, as I'm new to Datastage
Regards,
Arvind
ppalka
Participant
Posts: 118
Joined: Thu Feb 10, 2005 7:25 am
Contact:

Post by ppalka »

The easiest way is to use transformer stage and use such derivation on output column:
if Emp_type='P' then 1 else if Emp_type='T' then 2 else -1
Best regards,
Piotrek

Polish DataStage consulting company:
<a href="http://www.etlpro.pl">ETL PRO</a>
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

or you can use convert function to do character by character replacement. Read the documentation if you don't know how to use this function.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or you could use a lookup in a Modify stage.
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