Columns into values

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
srinivas143
Participant
Posts: 30
Joined: Tue Feb 19, 2008 11:02 pm

Columns into values

Post by srinivas143 »

Hi All,
I have the following requirement some one please help me out..

I am Having a source records as followed.

ID,ID1,2400,2500,2600
-------------------------------------------
1234,1,100,,102


and I have a reference table with the following data

NAME,VALUE
---------------
2400,BANK
2500,EDU
2600,FIN


I need an out put as following

NAME,VALUE
----------
ID,1234
ID1,1
BANK,100
EDU,,
FIN,102

Actually I need to transform the column name into actual values by using reference data table.
Iam using reference data because these values will vary dynamically

Any help is appreciated.

Kind Regards
jdmiceli
Premium Member
Premium Member
Posts: 309
Joined: Wed Feb 22, 2006 10:03 am
Location: Urbandale, IA

Post by jdmiceli »

Do you have any quarantees that your datatypes between columns and data are always going to be consistent (treatable as varchar)? Even if this is true, I see you having great difficulty doing this with a metadata based tool like DataStage.

You could possibly consider kicking the information you want out to an object relational data model, but reporting/extracting from that format can get sticky.

Hope that helps!
Bestest!

John Miceli
System Specialist, MCP, MCDBA
Berkley Technology Services


"Good Morning. This is God. I will be handling all your problems today. I will not need your help. So have a great day!"
uegodawa
Participant
Posts: 71
Joined: Thu Apr 27, 2006 12:46 pm

Post by uegodawa »

Hi,
You can acheive this by using a server Job. Read your first line in source file and store data in a hash file like follows;

Name : HSH_FILE
Fields : NAME,REF,VALUE
KEY : NAME
Once you process the first line hash table should look like below, you can use lookup to populate REF column.

NAME REF VALUE
----- ---- --------
ID ID
ID1 ID1
2400 BANK
2500 EDU
2600 FIN


Once you done this part read your next line and populate VALUE column accodingly in the same hash file. I hope this will solve your problem.

Thanks
Upul
Thanks,
Upul
srinivas143
Participant
Posts: 30
Joined: Tue Feb 19, 2008 11:02 pm

Post by srinivas143 »

Hi,
I tried with your option but I am not able to do the same.

source:
ID,COUNTRY,2400

Ref data:

NAME,VALUE
2400,BANK
2500,CON

I was able to read the source columns as a record using hashfile and when I am trying to match it with lookup colunm name ..it gives me the result as below

RESULT:
ID,COUNTRY,VALUE
COUNTRY,2400,NULL

my lookup condition is 2400=NAME(I tried giving the same name as source field name also),but still I am not able to generate the required output.

Pls Help me out..

Kind Regards
Post Reply