Page 1 of 1

Finding the last record in a transformer

Posted: Wed Dec 08, 2010 1:29 am
by venkates.dw
Is there any way to find the last record in a transformer?

Posted: Wed Dec 08, 2010 3:46 am
by laxman.ds
Get last record as max valued @INROWNUM (System Variable). But you need to take care about partitions per enabled for that job.

Posted: Wed Dec 08, 2010 3:51 am
by ray.wurlod
You can use the LastRecord() function. (I think that's what it's called.)

To use this you need to be running version 8.5.

@INROWNUM = 2 is not working in datastage 8.5

Posted: Mon Aug 29, 2011 12:40 am
by Immaculin
criteria:

data in the file: (has only 2 rows)

ABCDEFGHI
123456789

In the output I want it as :

00000ABCDEFGHI00000123456789


stage variables:

alphabet:@INROWNUM = 1
number:@INROWNUM = 2


The constraint in the transformer to print the second row is not working (@INROWNUM = 2).

Where will we find the partitions per enabled for a job?

Re: @INROWNUM = 2 is not working in datastage 8.5

Posted: Mon Aug 29, 2011 2:09 am
by ray.wurlod
Immaculin wrote: Where will we find the partitions per enabled for a job?
Everywhere.
Parallel execution is enabled by default in the parallel Transformer stage.

Open up the stage properties. On the Advanced tab you will be able to change the execution mode to Sequential.

Do consider using a server job for this task. It will be finished while the parallel job is still thinking about starting.

Posted: Mon Aug 29, 2011 3:19 am
by Immaculin
I will not be able to view the premium content.

Posted: Mon Aug 29, 2011 4:44 am
by ray.wurlod
Immaculin wrote:I will not be able to view the premium content.
You can if you get yourself a premium membership. By doing so you will be helping to keep this site alive; premium membership is the main way that hosting and bandwidth costs are met.

Re: @INROWNUM = 2 is not working in datastage 8.5

Posted: Mon Aug 29, 2011 7:48 am
by chulett
Immaculin wrote:data in the file: (has only 2 rows)
Server job.

use this, it worked for me

Posted: Thu Dec 15, 2011 11:35 am
by babbu9
For flat files:
First you need to know the rowcount for your file:
In the job properties use before job subroutine command execsh and type
"cat filename | wc -l > rowcount.txt"

Have a lookup in your job that looksup the file rowcount.txt and gets the rownum value. Generate rownum using @INROWNUM for the source records. Use the rownum as the key for both the source and lookup data. Set lookup condition to continue on condition not met and lookup failure. Add a transformer after the lookup and add condition where src.rownum=lkp.rownum and divert this record. This is your last record in the source.

For database sources your lookup needs to have "select count(1) from src_table" to find the table rowcount and repeat the same logic.