Question posted on Informatica Forum:
Can
you please suggest me logic on how to make single row into multiple rows?
CURRENT
OUTPUT
COLUMN-A COLUMN-B COLUMN-C
ROW1 1 2 MY||SUPPORT||INFORMATICA
EXPECTED OUTPUT
COLUMN-A COLUMN-B COLUMN-C
ROW1 1 2 MY
ROW2 1 2
SUPPORT
ROW3 1 2 INFORMATICA
The
number of rows to be generated depending on COLUMN-C.
in
this example in column-c there are 3 concatenated values so number of rows to
generated are 3 and column-a and column-b should be unique for 3 rows...
like
if there are 4 concatenated values in column-c then number of rows to be
generated are 4.
Solution:
select
CASE WHEN a.l = 1
THEN substr(col, 1, instr(col,',',1,a.l)-1)
ELSE substr(col, instr(col,',',1,a.l-1)+1,
CASE WHEN
instr(col,',',1,a.l)-instr(col,',',1,a.l-1)-1 > 0
THEN
instr(col,',',1,a.l)-instr(col,',',1,a.l-1)-1
ELSE length(col)
END
) END EXPECTED_OUTPUT
from
(select
replace('MY||SUPPORT||INFORMATICA','||',',') col from dual)t,
(SELECT
level l FROM DUAL CONNECT BY LEVEL <=
(SELECT
Max(length(replace('MY||SUPPORT||INFORMATICA','||',',')) -
length(replace('MY||SUPPORT||INFORMATICA','||',''))+1) FROM dual )) a
Oracle
Database as source: Use above SQL query
Flat
File Source: Use above SQL query in SQL Transformation and pass the column
value as input.
Note:- Query is just
for your reference, and you may have to change the query as per your
requirement.
above example is for one value.
ReplyDeletegive some suggestion to do for any data. also give how to use the query in sql transformation
Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!
ReplyDeletesap online training
software online training
sap sd online training
hadoop online training
sap-crm-online-training
This is one awesome blog article. Much thanks again.
ReplyDeleteI really enjoy the blog.Much thanks again. Really Great.
oracle online training
sap fico online training
dotnet online training
qa-qtp-software-testing-training-tutorial