Populate all rows in a single column

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
ashik_punar
Premium Member
Premium Member
Posts: 71
Joined: Mon Nov 13, 2006 12:40 am

Populate all rows in a single column

Post by ashik_punar »

Hi All,

I have a requirement in which I have to read all the source rows (only one column in each row) and load them into a single column in target. The no of rows is not fixed.

Example:

Input Data:
A
B
C
D
E
F
G

Output Data:
ABCDEF

Any idea how we can do this. I have done the pivot but it is populating the records into different columns where as i want it to be single column.

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I'd use a stage variable to accumulate the list. Generate a constant "key" column and use LastRecordInGroup() as a constraint, or use a downstream RemoveDuplicates stage set to "Keep Last".

You could use a Pivot stage and a Column Export stage, but that'd be using a sledgehammer to crack a nut.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

If your source is a Sequential File then, read all the rows in a single column i.e. mention final delimiter is "none".
And in the transformer, use Convert function to replace new lines characters.

Code: Select all

Convert(char(10) : char(13),'',<SRC_COL>)
Thanx and Regards,
ETL User
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I didn't actually have to do any of that. DataStage took care of the line terminators while reading the file - the constraint expression did not pass any empty line.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ashik_punar
Premium Member
Premium Member
Posts: 71
Joined: Mon Nov 13, 2006 12:40 am

Post by ashik_punar »

Hi All,

This is done. I used the approach suggested by Ray and as usual it gave the required results. Ray Thank you for that.
Post Reply