Hi all
I need to find out the last record for a dynamic sequential file(can have
variable count). Is there a built-in routine or transform in datastage to
perform this process???
Thanks in advance
Srini
Find Last record in the file
Moderators: chulett, rschirm, roy
Hi,
you can use basic to open the file then skip to the end of the file in a relative number of rows using the seek statement hence getting to the last line, which can then be read.
all you need is in the basic.pdf in your client install path under docs
another way is to use the filter command in the seq file having tail -1 <file> in it (you might need the full path of the tail command).
another way is to use shell script or command to perform the same tail and redirect the output to a file then read it.
there are perhaps more variations of this so take your pick![Smile :)](./images/smilies/icon_smile.gif)
IHTH,
you can use basic to open the file then skip to the end of the file in a relative number of rows using the seek statement hence getting to the last line, which can then be read.
all you need is in the basic.pdf in your client install path under docs
another way is to use the filter command in the seq file having tail -1 <file> in it (you might need the full path of the tail command).
another way is to use shell script or command to perform the same tail and redirect the output to a file then read it.
there are perhaps more variations of this so take your pick
![Smile :)](./images/smilies/icon_smile.gif)
IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
![Image](http://www.worldcommunitygrid.org/images/logo.gif)
Time is money but when you don't have money time is all you can afford.
Search before posting:)
Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
![Image](http://www.worldcommunitygrid.org/images/logo.gif)
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
The tail -1 filename would be the fastest of those recommended. It could return the row back to the calling routine for processing. tail -1 filename > filename would let you write out the last row to a new file for processing in DataStage.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Use Aggregator and Transformer
Hi
I hope ur record has a primary key
u can use the aggregator stage to find the last value of this column in your file. u can also use some other column that will have a unique value.
Later u can use the transformer stage and place a constaint to add only that record to the output file which has that unique id
I hope this solves your problem
I hope ur record has a primary key
u can use the aggregator stage to find the last value of this column in your file. u can also use some other column that will have a unique value.
Later u can use the transformer stage and place a constaint to add only that record to the output file which has that unique id
I hope this solves your problem