Page 1 of 1

Convert Char to Integer in transformer

Posted: Thu Nov 06, 2014 4:50 am
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

Posted: Thu Nov 06, 2014 5:14 am
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

Posted: Thu Nov 06, 2014 7:36 am
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.

Posted: Thu Nov 06, 2014 3:53 pm
by ray.wurlod
Or you could use a lookup in a Modify stage.