Page 1 of 1

Concatenate multiple rows delimited by comma

Posted: Thu Nov 25, 2010 8:13 am
by ysrini9
Hi Team,

How to Concatenate multiple rows delimited by comma

Ex: I have a column

1025758
1025758-1025759
1025758-1025759-1025758-1025759

Output would be


1025758,1025758-1025759,1025758-1025759-1025758-1025759

Thanks and Regards
SHRINIVAS

Posted: Thu Nov 25, 2010 8:36 am
by chulett
That would basically be a "rows to columns" pivot, a.k.a a "vertical pivot" which an exact search here would reveal many informations on. :wink:

Posted: Thu Nov 25, 2010 9:07 am
by ysrini9
We are using Datastage datastage 8.1 only horizal pivot is possible.

Please let me know is there any other way

Thanks in Advance
SHRINIVAS

Posted: Thu Nov 25, 2010 9:14 am
by chulett
So in other words, you didn't do the search. There are many ways to pivot and not all involve that stage.

Posted: Thu Nov 25, 2010 9:48 am
by swapnilverma
if records are less you can use below simple unix shell script ..




cat filename | while read line do

{

x=$line:,:x

}

done

print $x >> op_file_name



Alternatively using transformer....

stage variable coltorow=''

coltorow=input.columnname:',':coltorow



i hope there are other better way around :wink: :wink: :wink: