converting row to single column(i.e to a single row)

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
dsstarter
Participant
Posts: 10
Joined: Wed Mar 29, 2006 10:32 pm

converting row to single column(i.e to a single row)

Post by dsstarter »

Hi All,
let me know if you could advise me on below question.

I have a table called tab1 with a column called name1 and this is a reference table, so it may not have records more than 1000 any time.

when i do select name1 from tab1 it will give some rows in output but i need to make all those row into one single row and use it for my processing......please let me know how can i do this.....
with out any basic routine

for ex: out put of my sql is(5) rows
AISHWARYA
MADHURI
SRIDEVI
PRIYANKA
RAANI

out put should be like below
AISHWARYAMADHURISRIDEVIPRIYANKARAANI
or
AISHWARYA,MADHURI,SRIDEVI,PRIYANKA,RAANI

both these formats are ok for me.....note: no of records in tab1 are not fixed..............

Starter
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

So, you want an OCI/ODBC based reference lookup that will collapse an indeterminate number of values into a comma separated list?

Best answer: stored procedure

Second best answer: pre-collapse the reference rows via a job into a hashed file containing the required results

Reasons:

1. SQL cannot produce your result without help, meaning something like a function or a stored procedure is required
2. On a multi-row lookup (ODBC stage), you'll have to deal with aggregating the cartesian effect of the lookup to keep your primary input stream distinct (ugly exercise)
3. Nothing like you want exists in DS in any single stage.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

try this post
Click on me

I tried to do something similar.
In your case, you need to do your select as you are, let it pass through the transformer, and add a dummy column with a constant value, say 1.
go through my post (link is above). you can achieve what you are looking for.
cheers :lol:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kris_daredevil
Participant
Posts: 20
Joined: Mon Dec 05, 2005 8:07 pm
Contact:

Post by kris_daredevil »

use row merger to get the output u specified and the delimiter would be ,
KRIS
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

i highly doubt that a row merger would help, as a row merger just merges multiple columns into a single column on a single row.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Are you all sure that your solutions will serve for a reference lookup?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

well, the original poster can do the ref. lookup in the sql itself, get the result in multiple rows. The solution advised by me is to merge the multiple rows into a single row.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply