Concatenate multiple rows delimited by comma

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ysrini9
Participant
Posts: 108
Joined: Tue Jul 12, 2005 2:51 am

Concatenate multiple rows delimited by comma

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ysrini9
Participant
Posts: 108
Joined: Tue Jul 12, 2005 2:51 am

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So in other words, you didn't do the search. There are many ways to pivot and not all involve that stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Post 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:
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
Post Reply