Page 1 of 1

Populate all rows in a single column

Posted: Sun Apr 28, 2013 9:11 pm
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

Posted: Sun Apr 28, 2013 9:59 pm
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.

Posted: Mon Apr 29, 2013 1:16 am
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>)

Posted: Mon Apr 29, 2013 1:57 am
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.

Posted: Wed May 08, 2013 4:08 pm
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.