How to check for last record

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
nehak
Participant
Posts: 4
Joined: Thu Oct 25, 2007 3:18 am

How to check for last record

Post by nehak »

Hi...
I want to process last record seperately... how to know whether coming record is last or not.. i tried using @INROWNUM but not able to come to any conclusion... plz help me..
Thanks,
Neha
venki
Participant
Posts: 35
Joined: Wed Feb 28, 2007 5:09 am
Location: mumbai,

Post by venki »

If you use @INROWNUM function it give max record in each of the node.
i think this function is not help full to identifying last record.Try with this:

@PARTITIONNUM+(@NUMPARTITION*@INROWNUM-(@NUMPARTITION-1))


Regards,
Venkat.
venki
nehak
Participant
Posts: 4
Joined: Thu Oct 25, 2007 3:18 am

Post by nehak »

Venkat, transformer execution mode i kept as sequential... and the below expression is giving all records except last..

@PARTITIONNUM+(@NUMPARTITION*@INROWNUM-(@NUMPARTITION-1))
Thanks,
Neha
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You won't know that you are processing the last row until you hit the end-of-file, when it is too late. You can pass the number of rows into the job as a parameter and compare against that number in the transform stage.
venki
Participant
Posts: 35
Joined: Wed Feb 28, 2007 5:09 am
Location: mumbai,

Post by venki »

If you use @INROWNUM function it give max record in each of the node.
i think this function is not help full to identifying last record.Try with this:

@PARTITIONNUM+(@NUMPARTITION*@INROWNUM-(@NUMPARTITION-1))


Regards,
Venkat.
venki
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post by OddJob »

@INROWNUM is the inpt row counter, not the max row. As Arnd said, you're not going to know until it's too late. You'll need to pass in a per node row count (or something!!)
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Why do you want to do this in a Transformer stage?

If you want to look at other options, you can use a Tail stage to get the last record in each partition or the last record in any of the partitions. Or if you want a really funky logic, you can hardcode a value in a new column (say dummy='x') and then pass it through a remove duplicates and retain the last row.
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
Post Reply