Hi guys,

7. how to get this output
i/p
col1,col2
101,a
102,b
103,c
104,d


o/p
col1,col2
101,d
102,c
103,b
104,a

Thanks

Answer Posted / ankit gosain

Hi all,

For this scenario, construct a job like:


SeqFile------>Transformer------>Transformer----->SeqFile


Firstly, Change the execution mode of both the transformers
from default(parallel) to sequential.
Now, create a stage variable of varchar type in 1st
Transformer (say temp) & assign a default value to it
(say 'Ankit').
Now write in its derivation:
if temp='Ankit' then col2 else temp:',':col2

Now give the o/p derivation for the two columns as:
col1---col1
temp---col2

Now go to the 2nd Transformer & go to input tab and mention
the sorting on col1 as descending, create 3 stage variables
in it:
count1 of integer type with 0 as default value,
temp1 of varchar type with 'Ankit' as default value,
temp2 of varchar type.
then write in their derivation:

count1+1----------------------------------count1
if temp1='Ankit' then col2 else temp2-----temp1
temp1-------------------------------------temp2

Now write in O/p derivation of the columns:

col1-----------------------col1
field(temp2,',',count1)----col2

Now, do the sorting (ascending) on col1 in the o/p seqFile,
and drag & drop both the columns to the o/p link derivation
and you wil get the desired result.

If you have further queries, mail me on
ankitgosain@gmail.com

Cheers,
Ankit :)

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is quality stage?

566


how can we validate the flat files using the date in the header and number of records in the flat file? Using both conditions at a time.

2722


Differentiate between operational datastage (ods) and data warehouse?

670


What is developer responsibilities in UAT (user acceptance testing and Post implementation phase?

1633


What are the different plug-ins stages used in your projects?

619






sed,awk,head

963


What are the functionalities of link collector?

623


Define Routines and their types?

618


How do you schedule or monitoring the job?

661


Define repository tables in datastage?

698


options available in sequence job to run,validate?

832


What are datastage sequences?

663


On which interface you will be working as a developer?

631


If you want to use the same piece of code in different jobs, how will you achieve it?

630


What is job control?

620