top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Move to previous available column in informatica

+1 vote
390 views

Hi,
I have a scenario, where in we have a single record and multiple columns like this

Record numer cd1 cd2 cd3 cd4 cd5 cd6 cd7 cd8 cd9
123 12 null 13 14 null 15 16 17 null
Here we have value for cd1 and not for cd2 and we have value for cd3 so cd2 is empty so cd3 should get into cd2 since it was empty so we should move the next available values to previous available spaces.

Does anyone know how to achieve this scenario?

posted Apr 20, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

One approach could be to use an expression transformation as follows:

First concatenate all the ports in a single field using a delimiter (for example ',')

v_CONCAT:= cd1||','||cd2||','||cd3||','||cd4||','||cd5||','||cd6||','||cd7||','||cd8||','||cd9

Now create the output ports using regular expressions

o_cd1:=REG_EXTRACT(v_CONCAT,',*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*)',1)
o_cd2:=REG_EXTRACT(v_CONCAT,',*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*)',2)
o_cd3:=REG_EXTRACT(v_CONCAT,',*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*)',3)
.
. 
and so on.

One approach could be to use an expression transformation as follows:

First concatenate all the ports in a single field using a delimiter (for example ',')

v_CONCAT:= cd1||','||cd2||','||cd3||','||cd4||','||cd5||','||cd6||','||cd7||','||cd8||','||cd9
Now create the output ports using regular expressions

o_cd1:=REG_EXTRACT(v_CONCAT,',*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*)',1)
o_cd2:=REG_EXTRACT(v_CONCAT,',*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*)',2)
o_cd3:=REG_EXTRACT(v_CONCAT,',*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*),*([^,]*)',3)
.
.
and so on.

REG_EXTRACT extracts a substring from the input string that matches the regular expression.

() - a group. There will be as many groups as your ports cd1-cd12

,* - zero or more commas, if a value is null two commas will appear consecutively

[^,] - anything other than comma

[^,]* - zero or more of any character other than comma

The third parameter to REG_EXTRACT denotes which group you want as output. For o_cd1 we want the first non-NULL value, so it is 1 and for o_cd2, it is 2 and so on

answer Apr 29, 2016 by Manikandan J
Similar Questions
+2 votes

Is there any environment variable which holds the value of task ran ?

+1 vote

Is it possible to get the name of previous task from current task in in particular workflow in informatica?
Is there any environment variable which holds the value of task ran?

+1 vote

I have a Time column in my SQL Server table which has data like (14:00:00.0000000).

I am trying to load this type of data in Oracle table which has corresponding column datatype as timestamp. I am trying to convert the time column in SQL server to timestamp column in oracle using Informatica.

Whats the best way to do it?

+1 vote

How to transform rows into column using Normalizer in Informatica?

...