简体   繁体   中英

In Informatica How to Handle nulls coming from SQL Query and Replace the same length of Column Space in Flat Files

For example I have SQL data like this:

Col1    Col2    Col3
-----------------------
0010    01P98   UA500
0010    NULL    UA500

I need output in a flat file like this:

在此处输入图像描述

But I am getting output as below if I use isnull , is_Spaces , ReplaceString etc. functions.

在此处输入图像描述

Please suggest some code in Informatica.

You need to use lpad along with isnull() check.

lpad(IIF(isnull(col2),'',col2),' ',5)

This will pad with 5 spaces if its null and if its not null, then it will simply left pad spaces until col2 length is 5.

Although Koushik's answer will work just fine, in fact you should define your output as a fixed-width file and let Informatica do the job.

Once the target is a fixed-width file with proper pors length definition, Informatica will pad the values for all ports appropriately and there will be no LPAD functions required for any of the output ports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM