Search code examples
datastage

Trim null spaces and concatenate


I need to concatenate two fields in datastage and one field contains null values and I am using the NVL() function. My requirement is that if there are null values they shouldn't appear as spaces.

I am doing like:

Trim(NullToEmpty(Database.ADDR_2)) : ' ' : Trim(NullToEmpty(Database.ADDR_3))

Here ADDR_3 has null values and if it is null then I should trim the spaces and should display only ADDR_2. Please help me with a solution.


Solution

  • This question is not completely clear - if you used NVL there should not be the need to use NullToEmpty.

    You could use something like this:

    IF IsNull(Database.ADDR_3) THEN Database.ADDR_2 ELSE Database.ADDR_2 : " " : Database.ADDR_3
    

    Add trims if needed.